Skip to content

fix: Unity startup recovery avoids premature readiness timeouts - #1296

Merged
hatayama merged 1 commit into
v3-betafrom
feature/launch-error
Jun 9, 2026
Merged

fix: Unity startup recovery avoids premature readiness timeouts#1296
hatayama merged 1 commit into
v3-betafrom
feature/launch-error

Conversation

@hatayama

@hatayama hatayama commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Unity startup and reload recovery now waits for compile, import, and domain reload work to finish before running the project IPC readiness check.
  • Recovery still fails within a bounded timeout if the Editor never becomes idle, so startup recovery does not hang silently.

User Impact

  • Projects that open while Unity is still busy are less likely to show a readiness probe timeout immediately after the project IPC endpoint binds.
  • If Unity remains stuck in a busy state, recovery reports a bounded timeout instead of leaving startup recovery pending indefinitely.

Changes

  • Delay readiness probing while the Editor reports compiling, updating, or domain reload in progress.
  • Bound the idle wait with the existing readiness timeout.
  • Add focused EditMode coverage for delayed readiness and never-idle timeout behavior.

Verification

  • cli/dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"
  • cli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type exact --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.UnityCliLoopServerControllerRecoveryTests.StartRecoveryIfNeededAsync_WhenEditorNeverBecomesIdle_ShouldFailWithoutReadinessProbe"
  • cli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "UnityCliLoopServerControllerRecoveryTests|UnityCliLoopServerStartupProtectionTests"
  • git diff --check HEAD~1 HEAD
  • codex-review v3-beta clean

Avoid spending the project IPC readiness timeout while Unity is still compiling, updating, or completing domain reload work after the endpoint has already bound. The idle wait stays bounded by the readiness timeout so recovery fails instead of hanging when Unity never becomes ready.
@coderabbitai

coderabbitai Bot commented Jun 9, 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: f750abed-eb52-4443-9612-e59732e671a6

📥 Commits

Reviewing files that changed from the base of the PR and between 1125db9 and 4653d01.

📒 Files selected for processing (2)
  • Assets/Tests/Editor/UnityCliLoopServerControllerStartupLockTests.cs
  • Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs

📝 Walkthrough

Walkthrough

The PR adds an "editor idle" gate to the server readiness-probe flow. The controller now waits until the Unity editor is not busy before running the readiness probe, with configurable timeout and injectable predicates for determining busy state and retry delay.

Changes

Editor Idle Wait Gate

Layer / File(s) Summary
Editor idle wait configuration
Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs
New fields and constructor parameters enable injectable predicates for detecting editor-busy state, a retry-delay async function, and a configurable idle-timeout duration.
Editor idle wait implementation
Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs
MarkServerReadyAsync calls the new WaitForEditorIdleBeforeReadinessProbeAsync method, which polls until the editor is idle using the injected predicates and delay, or throws TimeoutException if the idle timeout elapses.
Editor idle behavior tests
Assets/Tests/Editor/UnityCliLoopServerControllerStartupLockTests.cs
Two test cases verify that the readiness probe does not run while the editor is busy (only after it becomes idle), and that recovery fails with a timeout exception if the editor never becomes idle.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • hatayama/unity-cli-loop#1136: Both PRs modify the server readiness-probe flow in UnityCliLoopServerControllerService—this PR adds an editor-idle wait gate before probing, while the retrieved PR refactors the recovery flow around persisted readiness state.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Unity startup recovery avoids premature readiness timeouts' directly and concisely summarizes the main change: preventing readiness probe timeouts by waiting for the editor to become idle before running readiness checks.
Description check ✅ Passed The description provides a comprehensive, well-structured explanation of the changes including summary, user impact, implementation details, and verification steps—all directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 feature/launch-error

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.

No issues found across 2 files

Re-trigger cubic

@hatayama
hatayama merged commit 1d3d2b6 into v3-beta Jun 9, 2026
8 checks passed
@hatayama
hatayama deleted the feature/launch-error branch June 9, 2026 06:17
@github-actions github-actions Bot mentioned this pull request Jun 9, 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