fix(macOS): Converterを入力セッション間で共有する - #346
Draft
ensan-hcl wants to merge 4 commits into
Draft
Conversation
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.
概要
ConverterServer 内で
KanaKanjiConverterを入力セッションごとに生成せず、全実行レーンから1つの Converter を共有するようにします。入力途中の状態は AZKKC の変換セッションで分離します。あわせて、XPC の reply 欠落時にクライアントの順序付きキューが永久停止しないための復旧処理と、アプリ切替時の入力待ちを起こしていた学習データ保存処理の遅延・省略を追加します。
原因
openSessionのたびにKanaKanjiConverter.withDefaultDictionary()を生成していました。OrderedAsyncCommandQueueは XPC reply が欠落すると先頭処理を完了できず、以降の入力がすべて待ち続ける構造でした。NSXPCConnectionを参照から外すだけで明示的に invalidate しておらず、接続が残るケースがありました。activateServerが設定同期・言語同期・activateを別々のXPCとしてキー入力より先に直列化していました。openSessionの応答後に改めてキーを送る2往復になっていました。deactivateは非同期でServerへ送られますが、Server上では学習データを同期保存していました。クライアント側では切替が完了しているため、新アプリの最初のキーが共有Serverの保存完了を待つ状態になっていました。変更内容
KanaKanjiConverterを1回だけ生成SegmentsManagerのみ保持deactivateでは入力状態だけ即時リセットし、学習データの永続化は入力が2秒途切れるまで遅延依存 PR
現時点では上記 PR のコミット
67ec8e68d17a534b5b9929b920995ef3811e89feを参照しています。テスト
swift test --package-path Core(67 tests passed)swift test --filter LearningMemoryTests(5 tests passed)xcodebuild -project azooKeyMac.xcodeproj -scheme azooKeyMac -configuration Debug test CODE_SIGNING_ALLOWED=NO -only-testing:azooKeyMacTests(9 tests passed)swiftlint lint --strictgit diff --check./install.sh --dry-run(archive succeeded)codesignで確認実機への再インストールはこの更新では行っていません。