Skip to content

fix: Keep dynamic code execution responsive by default#1331

Merged
hatayama merged 7 commits into
v3-betafrom
fix/execute-dynamic-code-unity2022-busy
Jun 13, 2026
Merged

fix: Keep dynamic code execution responsive by default#1331
hatayama merged 7 commits into
v3-betafrom
fix/execute-dynamic-code-unity2022-busy

Conversation

@hatayama

@hatayama hatayama commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Dynamic code execution now avoids waiting for Unity domain reloads unless a command explicitly opts in.
  • Unity-bundled compiler discovery is more robust across Unity 2022.3 and Unity 6 layouts.

User Impact

  • Short inspection snippets can return promptly instead of waiting for reload recovery that they did not trigger.
  • Projects using older or newer Unity editor layouts have a safer path for dynamic code compilation.

Changes

  • Make execute-dynamic-code reload waiting opt-in through --wait-for-domain-reload and update the generated skill guidance.
  • Track the selected Unity compiler layout and skip unsafe legacy Roslyn fallback paths.
  • Bump the CLI contract and beta metadata to include the new behavior.
  • Add regression coverage for compiler path resolution, dynamic code execution, CLI wait defaults, and Unity 6 TestMode compatibility.

Verification

  • Not rerun in this PR creation turn.
  • Reviewed the committed diff with git diff origin/v3-beta...HEAD --stat and git diff origin/v3-beta...HEAD --name-status.

Review in cubic

hatayama added 6 commits June 13, 2026 17:25
Classify Unity-bundled compiler layouts so Unity 2022 legacy Roslyn roots use one-shot compilation instead of the shared worker path that can leave execute-dynamic-code busy.

Also align the uGUI package version with Unity 2022 so compile validation resolves UnityEngine.UI, and keep the intentional legacy skip out of the Unity Console error stream.
Unity 2022.3のContents直下Roslynレイアウトでも共有Roslyn workerを試すように戻し、workerが利用不能な場合だけone-shot Roslynへフォールバックする。
あわせてキャンセル後にforeground実行枠が残らないことと、worker故障時にフォールバックが完了することをテストで固定する。
通常のdynamic code実行は軽量な状態確認やEditor操作が中心なので、Domain Reload待ちをデフォルトで入れず低レイテンシを優先する。
必要なスクリプトreload/import系の操作だけ --wait-for-domain-reload で待てるよう、CLI定義とskill説明を揃える。
execute-dynamic-codeの待機挙動変更に合わせて最低CLIバージョンを更新し、
Unity Test Runner上でキャンセル検証や外部コンパイラ呼び出しが固まった場合も
短時間で失敗として戻るようにする。
最低CLIバージョンをbeta32へ上げた変更に合わせてrelease metadataを揃え、
フォールバックcompile smoke testもタイムアウト付きキャンセルで失敗できるようにする。
Unity 6000系では UnityEngine.TestTools.TestMode も参照に入るため、Test Runner API の TestMode を alias で明示してテスト用 adaptor の実装型を固定する。
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8cde8d8d-dcf0-4137-bfa5-1035abd83fb0

📥 Commits

Reviewing files that changed from the base of the PR and between da1d8ca and 28bb83b.

📒 Files selected for processing (2)
  • Assets/Tests/Editor/DynamicCodeToolTests/ExternalCompilerPathResolverTests.cs
  • Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/RoslynCompilerBackend.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • Assets/Tests/Editor/DynamicCodeToolTests/ExternalCompilerPathResolverTests.cs

📝 Walkthrough

Walkthrough

This PR makes execute-dynamic-code domain-reload waiting opt-in, records resolved compiler layout kinds for telemetry, adds async/cancellation-safe test helpers and tests, and bumps CLI/tool metadata to 3.0.0-beta.32 with matching docs.

Changes

Domain Reload Wait: Opt-In Behavior

Layer / File(s) Summary
Compiler layout classification system
Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/ExternalCompilerPaths.cs, .../ExternalCompilerPathResolver.cs
Adds ExternalCompilerLayoutKind, exposes ExternalCompilerPaths.LayoutKind, and adds ResolveCompilerLayoutKind plus path-normalization helpers used by resolver.
Schema and CLI defaults: wait becomes opt-in
Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/ExecuteDynamicCodeSchema.cs, cli/internal/cli/dynamic_code_wait.go, cli/internal/tools/default-tools.json
Change WaitForDomainReload default from truefalse in schema and make CLI decision use explicit false default, making --wait-for-domain-reload opt-in.
CLI domain reload wait tests and flag handling
cli/internal/cli/compile_wait_test.go, cli/internal/cli/tools_test.go, cli/internal/cli/completion_test.go
Update tests to assert no waiting by default and that explicit --wait-for-domain-reload enables waiting; update completion to list the positive flag.
Unity schema tests
Assets/Tests/Editor/DynamicCodeToolTests/FirstPartyToolSchemaMetadataTests.cs
Assert ExecuteDynamicCodeSchema.WaitForDomainReload defaults to false.
Test infrastructure: async compilation & cancellation handling
Assets/Tests/Editor/DynamicCodeToolTests/CompiledAssemblyLoaderTests.cs, DynamicCodeExecutionFacadeTests.cs
Add async stdout/stderr with process timeout, blocking executor path and cancellation-bounded helpers, and a regression test verifying cancelled foreground execution releases scheduler slot.
Compiler layout classification and fallback tests
Assets/Tests/Editor/DynamicCodeToolTests/ExternalCompilerPathResolverTests.cs
Add tests for layout-kind classification and an async test that simulates shared-worker failure and verifies fallback to one-shot Roslyn and produced DLL.
Telemetry: include compiler layout in fallback reporting
Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/DynamicCompilation/RoslynCompilerBackend.cs
Emit layout_kind in health/fallback telemetry payloads; reformat some initializers without changing invocation behavior.
Documentation, metadata, and version updates
.agents/skills/uloop-execute-dynamic-code/SKILL.md, .claude/skills/uloop-execute-dynamic-code/SKILL.md, Packages/src/Editor/FirstPartyTools/ExecuteDynamicCode/Skill/SKILL.md, cli/CHANGELOG.md, cli/contract.json, Packages/src/Editor/Domain/CliConstants.cs, .release-please-manifest.json
Document --wait-for-domain-reload, bump CLI version to 3.0.0-beta.32, and add changelog entry describing the opt-in reload wait behavior.
Test type fixes and dependency updates
Assets/Tests/Editor/RunTestsTestFrameworkResultTests.cs, Packages/manifest.json, Packages/packages-lock.json
Add using alias for TestRunnerMode, adjust FakeTestAdaptor return type, and change com.unity.ugui dependency from 2.0.01.0.0 with matching lockfile update.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making dynamic code execution responsive (not wait) by default.
Description check ✅ Passed The description is related to the changeset, covering the main objectives and user impact of keeping dynamic code execution responsive by default.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/execute-dynamic-code-unity2022-busy

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 and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 24 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Add the selected Unity compiler layout to one-shot compiler start-failure and infrastructure fallback diagnostics so all dynamic compilation fallback reports carry the same context.

Cover the infrastructure fallback report with an Editor test that asserts layout_kind is emitted in the diagnostic log.
@hatayama
hatayama merged commit 148c109 into v3-beta Jun 13, 2026
9 checks passed
@hatayama
hatayama deleted the fix/execute-dynamic-code-unity2022-busy branch June 13, 2026 20:45
@github-actions github-actions Bot mentioned this pull request Jun 13, 2026
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