Skip to content

feat: Warn when patching methods called from physics callbacks - #1911

Merged
hatayama merged 1 commit into
feature/round6-pause-point-improvementsfrom
feat/round6-physical-callback-callsite-warning
Jul 21, 2026
Merged

feat: Warn when patching methods called from physics callbacks#1911
hatayama merged 1 commit into
feature/round6-pause-point-improvementsfrom
feat/round6-physical-callback-callsite-warning

Conversation

@hatayama

@hatayama hatayama commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • enable-pause-point now warns about the same cached-dispatch risk even when the target line is a helper method called from a physics callback, not just when the target itself is named OnCollisionEnter2D/OnTriggerEnter2D/etc.
  • The PAUSE_POINT_EXPIRED timeout diagnosis now includes the same non-firing-pattern guidance the plain timeout diagnosis already had.

User Impact

  • Before: patching a private helper method that a physics callback (e.g. OnCollisionEnter2D) calls into produced no warning at enable time, even though it can silently miss a GameObject that already existed when the pause point was enabled. Agents only discovered this the hard way, via a confusing HitCount == 0 timeout.
  • After: enable-pause-point's response Warning field flags this case up front and suggests the same workarounds (recreate the GameObject, or embed UloopPausePoint.Pause("id") directly). Additionally, when a marker expires (PAUSE_POINT_EXPIRED) before being hit, the CLI now surfaces the same non-firing-pattern checklist that a plain timeout already showed, instead of a much shorter message.

Changes

  • Added SourcePausePointPhysicalCallbackCallSiteScanner: reads the compiled assembly with Mono.Cecil and checks (one call level deep) whether any Unity physics message method in the same assembly calls the patch target.
  • Wired it into SourcePausePointPatcher.BuildPatchWarning as a fallback when the direct name/type check doesn't match, adding a new PhysicalCallbackIndirectCallMayMissExistingInstanceWarning constant.
  • Extended the Go-side pausePointExpiredHint with the same non-firing-pattern guidance already present in pausePointTimeoutHint, extracting the shared text into a pausePointNonFiringPatternsHint constant so the two hints can't drift apart.
  • Scan scope: the whole compiled assembly (not just the patched method's declaring class), since this only runs once per enable-pause-point call rather than on a hot path.

Verification

  • dist/darwin-arm64/uloop compile --project-path <repo>: 0 errors, 0 warnings.
  • dist/darwin-arm64/uloop run-tests (EditMode, filter PausePoint): 225/225 passed (was 223 before this PR; +2 new tests).
  • Confirmed the new call-site-scan test actually exercises the new code path: disabled the new branch, recompiled, and observed it fail (1/27 in SourcePausePointPatcherTests) before re-enabling it, which then passed 27/27 again.
  • sh scripts/check-go-cli.sh: format/vet/lint (0 issues) and tests all passed, including the updated project-runner test package.

Review in cubic

enable-pause-point's cached-dispatch warning previously fired only when
the patched method itself was named after a Unity physics message
method (OnCollisionEnter2D etc.). A method that is merely called from
one hits the exact same dispatch-caching risk but got no warning at
all, so agents had no signal before hitting a silent miss.

- Add SourcePausePointPhysicalCallbackCallSiteScanner: reads the
  compiled assembly with Mono.Cecil and checks whether any physics
  message method in the same assembly calls the patch target one
  level deep.
- Wire it into SourcePausePointPatcher.BuildPatchWarning as a fallback
  when the direct name/type check does not match, surfacing a new
  PhysicalCallbackIndirectCallMayMissExistingInstanceWarning.
- Extend the Go-side PAUSE_POINT_EXPIRED hint
  (pausePointExpiredHint) with the same non-firing-pattern guidance
  already present in the timeout hint, extracted into a shared
  pausePointNonFiringPatternsHint constant so the two hints cannot
  drift apart.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@hatayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3ac85d31-8bd8-43c2-abc8-4b27983100ec

📥 Commits

Reviewing files that changed from the base of the PR and between 570f18a and 32eef72.

⛔ Files ignored due to path filters (2)
  • Assets/Tests/Editor/SourcePausePointPatcher/Fixtures/PatcherPhysicalCallbackHelperMethodFixture.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointPhysicalCallbackCallSiteScanner.cs.meta is excluded by none and included by none
📒 Files selected for processing (7)
  • Assets/Tests/Editor/SourcePausePointPatcher/Fixtures/PatcherPhysicalCallbackHelperMethodFixture.cs
  • Assets/Tests/Editor/SourcePausePointPatcher/SourcePausePointPatcherTests.cs
  • Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointConstants.cs
  • Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointPatcher.cs
  • Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointPhysicalCallbackCallSiteScanner.cs
  • cli/project-runner/internal/projectrunner/pause_point_errors.go
  • cli/project-runner/internal/projectrunner/pause_point_wait_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/round6-physical-callback-callsite-warning

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hatayama
hatayama merged commit 5cc6932 into feature/round6-pause-point-improvements Jul 21, 2026
1 of 2 checks passed
@hatayama
hatayama deleted the feat/round6-physical-callback-callsite-warning branch July 21, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant