-
-
Notifications
You must be signed in to change notification settings - Fork 66
fix: Chromium 系アプリの IME activateServer 時のハングを回避 #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ensan-hcl
merged 2 commits into
azooKey:main
from
mtane0412:fix/chromium-ime-deadlock-workaround-upstream
Apr 21, 2026
+92
−26
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /// Chromium IME deadlock workaround に関する回帰テスト。 | ||
| /// | ||
| /// Chrome 等の Chromium 系ブラウザで大規模 JS バンドルのページを開いた直後、 | ||
| /// azooKey の activateServer 内で `client.attributes(forCharacterIndex:)` を呼ぶと | ||
| /// deadlock が発生する問題(Chromium issue 503787240)を回避するための変更を保護する。 | ||
| /// | ||
| /// 安全性の根拠: | ||
| /// - activateServer が渡す候補配列は空であるため、BaseCandidateViewController の | ||
| /// `resizeWindowToFitContent` は `numberOfVisibleRows == 0` で早期 return し、 | ||
| /// cursorLocation は window 位置計算に使われない。 | ||
| /// - この事実が変わらない限り、activateServer 時の client 問い合わせを削除しても | ||
| /// 機能に影響がない。 | ||
|
|
||
| import XCTest | ||
| import Core | ||
| import KanaKanjiConverterModuleWithDefaultDictionary | ||
| @testable import azooKeyMac | ||
|
|
||
| @MainActor | ||
| final class ChromiumDeadlockRegressionTests: XCTestCase { | ||
| /// 空の候補配列で updateCandidatePresentations を呼んだ後、 | ||
| /// numberOfVisibleRows が 0 であることを確認する。 | ||
| /// | ||
| /// これにより、resizeWindowToFitContent の `numberOfVisibleRows == 0` での | ||
| /// 早期 return が継続的に機能することを保護する。 | ||
| func test空配列でupdateCandidatePresentationsを呼ぶとnumberOfVisibleRowsが0になる() { | ||
| let vc = CandidatesViewController() | ||
| _ = vc.view // loadView を強制実行 | ||
| vc.updateCandidatePresentations([], selectionIndex: nil, cursorLocation: .zero) | ||
| XCTAssertEqual( | ||
| vc.numberOfVisibleRows, | ||
| 0, | ||
| "空の候補配列では numberOfVisibleRows は 0 でなければならない" | ||
| ) | ||
| } | ||
|
|
||
| /// 空の候補配列で updateCandidatePresentations を呼んだ後、 | ||
| /// candidates プロパティが空であることを確認する。 | ||
| func test空配列でupdateCandidatePresentationsを呼ぶとcandidatesが空になる() { | ||
| let vc = CandidatesViewController() | ||
| _ = vc.view | ||
| vc.updateCandidatePresentations([], selectionIndex: nil, cursorLocation: .zero) | ||
| XCTAssertTrue(vc.candidates.isEmpty, "空の候補配列を渡した後、candidates は空でなければならない") | ||
| } | ||
|
|
||
| /// 0 より多い候補配列を渡した後に空配列で更新すると、 | ||
| /// numberOfVisibleRows が 0 に戻ることを確認する。 | ||
| func test候補が存在する状態から空配列に更新するとnumberOfVisibleRowsが0になる() { | ||
| let vc = CandidatesViewController() | ||
| _ = vc.view | ||
| let dummy = CandidatePresentation( | ||
| candidate: Candidate( | ||
| text: "テスト", | ||
| value: 0, | ||
| composingCount: .surfaceCount(3), | ||
| lastMid: 0, | ||
| data: [] | ||
| ) | ||
| ) | ||
| vc.updateCandidatePresentations([dummy], selectionIndex: nil, cursorLocation: .zero) | ||
| XCTAssertEqual(vc.numberOfVisibleRows, 1, "候補が1件の状態を前提とする") | ||
|
|
||
| vc.updateCandidatePresentations([], selectionIndex: nil, cursorLocation: .zero) | ||
| XCTAssertEqual( | ||
| vc.numberOfVisibleRows, | ||
| 0, | ||
| "空配列に更新した後は numberOfVisibleRows が 0 でなければならない" | ||
| ) | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests instantiate and drive AppKit view controllers (
CandidatesViewController,vc.view,NSTableView.reloadData()etc.). XCTest doesn’t guarantee test methods run on the main thread, and AppKit is not thread-safe, so this can become flaky or crash under parallel testing. Consider marking the test class (or each test method) as@MainActor, or wrapping the body inawait MainActor.run { ... }to ensure all UI interactions happen on the main thread.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応しました。テストクラスに
@MainActorを追加し、すべての AppKit 操作がメインスレッドで実行されることを保証しました。