ホームに戻ると稀に真っ白になる不具合を修正 - #67
Merged
Merged
Conversation
- 遷移アニメーション中の二重タップでバックスタックが空になり何も描画されなくなる問題を、RESUMED 中のみ遷移を受け付けるガードで防ぐ - 戻る操作を popBackStack(settings, inclusive) にして意図しない main のポップを防ぐ - Activity 再生成時にスプラッシュ保持で白い背景が露出する問題を初回作成時のみの保持に変更 - 設定の永続化を viewModelScope からアプリケーションスコープへ移し、書き込み直後に画面を離れてもモード変更が失われないようにする - 設定の読み取り失敗や壊れた値で購読側が落ちないよう既定値へフォールバックする - ドロワーの設定項目は閉じ切ってから遷移するようにする - 上記の回帰テストを追加
Contributor
UI差分基準画像との差分はありません。 全画面スクリーンショット |
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.



















背景
練習モードから本番モードに切り替えてホームに戻ると、たまに画面が真っ白になるという報告を受けて調査した。再現条件が「たまに」であることから、タイミング依存の欠陥を洗い出した。
原因と修正
1. 戻る操作の二重実行でバックスタックが空になる(真っ白の主因)
AppNavHost の戻るコールバックに多重呼び出しのガードが無く、遷移アニメーション中にもう一度戻る矢印を押せてしまう。二度目の popBackStack が設定画面に続けてホームまでポップし、バックスタックが空になると NavHost は何も描画しないため画面が真っ白になる。
2. Activity 再生成時にスプラッシュ保持で白い背景が露出する
MainActivity は onCreate のたびに 2 秒間の描画停止を掛けていた。構成変更やプロセス復帰による再生成ではシステムのスプラッシュが描かれないため、白い window background がそのまま見えていた。初回作成時だけ保持するようにした。
3. モード切り替えが保存されないことがある
設定の永続化を viewModelScope で行っていたため、書き込み直後に画面を離れると ViewModel が破棄されてスコープが取り消され、モード変更が黙って失われていた。アプリケーションスコープでの書き込みに変更した。ホームの店舗選択とスタッフ設定も同じ理由で移した。
4. 保存値が壊れていると購読側が例外で落ちる
SettingsRepository は保存済み JSON のデコード失敗や DataStore の読み取り失敗をそのまま流していた。購読しているホームの collect には try/catch が無く、そのままアプリが落ちる経路になっていた。リポジトリ側で既定値へフォールバックするようにした。
5. ドロワーの設定項目が閉じるアニメーションを中断する
閉じる処理の完了を待たずに遷移していたため、rememberCoroutineScope が取り消されて閉じるアニメーションが中断し、開いた状態が復元され得た。閉じ切ってから遷移するようにした。
テスト
Generated by Claude Code