Repository navigation
iOSのバックグラウンドTTS停止を修正しプレイヤー再利用をAndroid限定にする - #6252
Conversation
Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LDHsud95ANfDLbbCpAJUYz
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesTTS プレイヤープラットフォーム別再利用
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/useTTS.test.ts`:
- Around line 527-529: The test for iOS "generate fresh each time" functionality
uses mockReturnValue which returns the same player instance for all calls to
createAudioPlayer, making it impossible to verify that new instances are
actually created on each call. Replace mockReturnValue with
mockImplementationOnce to return different mock player instances for the 1st and
2nd calls to createAudioPlayer. Additionally, verify that the first player
instance's remove method is called to ensure proper cleanup and confirm that
instances are not being reused across multiple invocations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 80b5e9d7-c35b-4148-962a-92c4c7ea6c3d
📒 Files selected for processing (2)
src/hooks/useTTS.test.tssrc/hooks/useTTS.ts
Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LDHsud95ANfDLbbCpAJUYz
概要
iPhone (iOS 26) でバックグラウンド時に TTS が再生されなくなる不具合を修正します。原因は #6235 で導入したプレイヤーの永続再利用 (
replace()) で、iOS のバックグラウンドでは再生を開始できないためです。プレイヤー再利用を Android 限定にし、iOS は従来どおり発話ごとに生成・破棄して背景再生を維持します。expo-audioネイティブ実装 (AudioPlayer.swiftのreplaceCurrentSource) は「差し替え時点で再生中だった場合のみ」ロード完了後 (onReady) に再生を再開します。JS (ttsAudioPlayer.ts) はreplace()の直前にpause()するためwasPlaying = falseとなり自動再開されず、直後に呼ぶplay()はまだreadyToPlayでない差し替え後アイテムへの呼び出しになります。フォアグラウンドでは間に合うものの、バックグラウンドの iOS では再生が始まりません。新規createAudioPlayer(従来の iOS 挙動)はこの問題が無いため、iOS では発話ごとの生成に戻します。AudioTrack 枯渇は Android 固有の問題のため、Android は #6235 の再利用パスを維持します。変更の種類
変更内容
useTTS.tsにreusePlayers = Platform.OS === 'android'を導入し、プレイヤー再利用を Android 限定に変更。cleanupAllPlayers/stopJa/stopEnでプレイヤーをネイティブごと破棄 (remove) し、発話ごとにcreateAudioPlayerで新規生成する従来挙動へ復帰。Android は永続インスタンスを一時停止してreplace()で使い回す挙動を維持。releaseAllPlayers(アンマウント時)で永続プレイヤーと再生中ハンドルのプレイヤー双方を確実に解放するよう調整。replaceではなく新規生成されること、ストール時にプレイヤーが破棄されることを追加検証。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること根本原因はネイティブ音声リソースの挙動のため、最終確認は実機 iOS (iOS 26) でのバックグラウンド・オートモード長時間再生での検証を推奨します。
関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit
リリース ノート
Bug Fixes
Tests