Repository navigation
Fix flaky RecompileScripts examples caused by a delayed domain reload - #46
Merged
Merged
Conversation
RecompileScripts returns once compilation finishes, but the domain reload can still be pending; the test then resumes on the old assemblies and fails (seen on CI with Unity 6.3 and 6.5, and locally with 6.0). Wait until the reload actually happens, and log the reload state so CI runs show whether the delay occurred. Create the generated script and csc.rsp under the APIExamples assembly instead of Assets/ so that only that assembly is recompiled, not every assembly in the project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The logging was added to see whether the delayed domain reload occurs on CI. Five reruns across all Unity versions never showed it, so the log no longer earns its noise; the wait itself stays as a safeguard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code Metrics Report
Details | | master (e28f85f) | #46 (66192af) | +/- |
|---------------------|------------------|---------------|--------|
| Coverage | 39.0% | 39.0% | 0.0% |
| Files | 25 | 25 | 0 |
| Lines | 476 | 476 | 0 |
| Covered | 186 | 186 | 0 |
+ | Code to Test Ratio | 1:4.0 | 1:4.0 | +0.0 |
| Code | 1256 | 1255 | -1 |
+ | Test | 5111 | 5125 | +14 |
+ | Test Execution Time | 8m34s | 5m40s | -2m54s |Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RecompileScriptsでリコンパイルを実行する例_リコンパイルされたクラスのメソッドを呼び出せるintermittently fails on CI withMissingMethodException: Default constructor not found for type Foo(seen on Unity 6000.3.18f1 and 6000.5.1f1).Trigger Conditions
It runs right after
..._csc_rspで追加したスクリプティングシンボルが有効になる(added in e28f85f), whose TearDown deletescsc.rsp.The next
RecompileScriptsthen recompiles every assembly.Root Cause
RecompileScriptswaits only untilEditorApplication.isCompilingbecomes false; it does not wait for the domain reload.The reload usually completes before the test resumes, but sometimes it is still pending (the log shows
domain reloads=0for that refresh).The test then reflects on the old
Assembly-CSharp, which still holds thestatic class Foofrom the previous test.Solution
RecompileScripts, wait on a static flag set before the yield. Static fields reset on domain reload, so the flag shows whether the reload has happened yet.WaitForDomainReload: it throws when the reload has already completed insideRecompileScripts, which is the usual case.InternalEditorUtility.IsScriptReloadRequested(): it is internal.csc.rspunderAssets/APIExamples/Scripts/Runtimeinstead ofAssets/, so that only theAPIExamplesassembly is recompiled. Thecsc_rsptest takes 4–9 s instead of 27–49 s.Verification
RecompileScripts), so it is not specific to Unity 6.3 and later.🤖 Generated with Claude Code