Skip to content

fix(editor): keep window focus refresh off the main thread - #1465

Draft
haranishi wants to merge 1 commit into
CoplayDev:betafrom
haranishi:fix/window-focus-refresh-1238
Draft

haranishi wants to merge 1 commit into
CoplayDev:betafrom
haranishi:fix/window-focus-refresh-1238

Conversation

@haranishi

@haranishi haranishi commented Oct 11, 2026 •

Copy link
Copy Markdown

Description

MCP for Unityウィンドウにフォーカスを戻したとき、TCP接続確認、実行ファイル探索、uv検証、クライアント設定の読み取りがEditorのメインスレッドを止める問題を修正します。更新処理は必要な設定をメインスレッドで取得し、I/Oをワーカーで実行してから表示を更新します。

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Test update

Changes Made

  • フォーカス時と定期更新時の接続確認、パス検証、クライアント状態確認、コマンド表示を非同期化します。
  • キャッシュと実行中のリクエスト共有により、同じ確認の連続実行を抑えます。
  • 設定変更、切断、新しい接続セッション、ウィンドウの閉鎖後に、古い結果が表示や接続判定を上書きしないようにします。接続失敗は新しい確認結果ごとに数えます。
  • 状態確認には設定のコピーを使い、フォーカス更新によるクライアント設定ファイルの書き換えを防ぎます。
  • 既存のIPathResolverServiceを維持し、ワーカー用のパス解決は任意のIWindowPathResolverに分離します。
  • 遅い実行ファイルとTCP確認、キャッシュ期限、設定変更、セッション変更、破棄済みウィンドウ、各クライアントの読み取り専用更新を回帰テストで確認します。

Compatibility / Package Source

  • Unity version(s) tested: 6000.3.20f1、Unity Test Framework 1.6.0。
  • Package source used (#beta, #main, tag, branch, or file:): betaから作成した本ブランチを、独立したテストプロジェクトのfile:参照で検証しました。
  • Resolved commit hash from Packages/packages-lock.json (if using a Git package URL): 該当なし(file:参照)。ベースは142ea0af4890337f0ff6658df61db23982313717です。

Testing/Screenshots/Recordings

  • Python tests (cd Server && uv run --extra dev pytest -q tests): 1,575 passed、18 skipped。
  • Unity EditMode tests: ウィンドウ、パス解決、クライアント設定、サーバーコマンドの関連96件が合格しました。
  • Unity PlayMode tests
  • Package import/compile check
  • Not applicable (explain why in Additional Notes)

修正前は遅い実行ファイルの検証により約505msかかり、応答時間の回帰テストが失敗しました。修正後は同じテストが合格しました。実ウィンドウでも1秒かかる実行ファイルを使ってフォーカス更新を12回確認し、更新呼び出しの最大時間は約0.38msでした。Editor更新の継続、設定ファイルの不変、検証用設定の復元、500・768・1000幅での表示も確認しました。

bash tools/check-unity-versions.shを実行しました。指定の2021.3.45f2、2022.3.62f1、6000.0.75f1、6000.4.8f1はいずれも未インストールのためskipです。

Documentation Updates

  • I have added/removed/modified tools or resources
  • If yes, I have updated all documentation files using:
    • The LLM prompt at tools/UPDATE_DOCS_PROMPT.md (recommended)
    • Manual review of the generated changes

Related Issues

Fixes #1238

Additional Notes

報告環境のWindows 11での実機検証は行えていません。実行したネイティブ検証はmacOS上の上記Unityで、Editorの処理を対象としています。新しいUnityバージョン分岐やMCPツールの変更はありません。

forkでのCI検証

同一コミット b9345fa8dbd890338d9ffd0a83e87af6a7fa78ea の検証結果をGitHub Actionsで確認しました。Pythonテストと、Unityを使わないハーネステストが成功しています。

C#コンパイルもUnity 6000.0.75f1で成功しました。Windows・macOS・Linuxの各条件でRuntimeとEditorをコンパイルしています。

ライセンスが必要なE2EとUnity Editor実テストはスキップされています。

@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

This branch has not been deployed

No deployments
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.

[Bug] Editor freezes on MCP for Unity window focus: synchronous process spawns and TCP probes in OnFocus refresh

1 participant