Skip to content

fix: keep dynamic-code compiler settings on the Unity main thread#1831

Merged
hatayama merged 2 commits into
fix/macos-e2e-integrationfrom
fix/capture-dynamic-code-compilation-settings
Jul 18, 2026
Merged

fix: keep dynamic-code compiler settings on the Unity main thread#1831
hatayama merged 2 commits into
fix/macos-e2e-integrationfrom
fix/capture-dynamic-code-compilation-settings

Conversation

@hatayama

@hatayama hatayama commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Dynamic-code compilation now captures Unity compiler settings before asynchronous work can resume on a worker thread.
  • The compiler pipeline receives an immutable settings snapshot instead of reading UnityEditor APIs after ConfigureAwait(false).

User Impact

  • Dynamic-code compilation no longer fails intermittently with main-thread exceptions when PlayMode or scene loading causes an await to yield.

Changes

  • Switch to the Unity main thread at the compilation entry point and capture active defines plus unsafe-code configuration.
  • Pass the snapshot through the assembly builder and Roslyn backend.
  • Add pure C# coverage for define filtering, empty input, null validation, and snapshot isolation.

Verification

  • Native uloop compile: Success true, ErrorCount 0, WarningCount 0.
  • Targeted EditMode tests: TestCount 3, PassedCount 3, FailedCount 0.
  • Full EditMode tests: TestCount 2163, PassedCount 2156, FailedCount 0, SkippedCount 7; runner status Skipped because existing tests were skipped.
  • Unity API reference check: only DynamicCodeCompiler reads EditorUserBuildSettings.activeScriptCompilationDefines and PlayerSettings.allowUnsafeCode; GetActiveDefineSymbols was removed.

Refs: Mac POSIX E2E recovery/readiness fix specification, To-Dos 7-9.

Review in cubic

hatayama added 2 commits July 18, 2026 15:14
Switch to the Unity main thread before reading script defines and unsafe-code settings, then pass an immutable snapshot through the asynchronous compilation pipeline. This prevents UnityEditor APIs from being accessed after ConfigureAwait(false) resumes on a worker thread.
Cover whitespace filtering, empty define sets, null input validation, and input-array isolation so the captured settings preserve the previous compiler behavior without Unity API access.
@coderabbitai

coderabbitai Bot commented Jul 18, 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: 32 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: 6b5f5a5c-1b45-4805-bb56-c6be2da52365

📥 Commits

Reviewing files that changed from the base of the PR and between 378a831 and b733699.

⛔ Files ignored due to path filters (2)
  • Assets/Tests/Editor/DynamicCodeToolTests/RoslynCompilerOptionsTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/RoslynCompilerOptions.cs.meta is excluded by none and included by none
📒 Files selected for processing (8)
  • Assets/Tests/Editor/DynamicCodeToolTests/ExternalCompilerPathResolverTests.cs
  • Assets/Tests/Editor/DynamicCodeToolTests/RoslynCompilerOptionsTests.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Compilation/ICompiledAssemblyBuilder.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/CompiledAssemblyBuilder.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/DynamicCodeCompiler.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/DynamicCompilationBackend.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/RoslynCompilerBackend.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/RoslynCompilerOptions.cs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/capture-dynamic-code-compilation-settings

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 9ad54aa into fix/macos-e2e-integration Jul 18, 2026
2 checks passed
@hatayama
hatayama deleted the fix/capture-dynamic-code-compilation-settings branch July 18, 2026 06:23
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