Repository navigation
fix(chat): keep a voice recording running over a screen rotation - #6817
ToteMeiSter wants to merge 1 commit into
Conversation
A rotation stops the chat activity. ChatViewModel.onStop then stopped the MediaRecorder, while the locked and in-progress state of the recording stayed. The screen still showed a running recording and a truncated file was sent. The view model now keeps the recorder running when the stopping activity is changing its configuration. It reads this from the lifecycle owner: ON_STOP reaches the observer before the body of Activity.onStop runs (API 29+), so a flag set by the activity in onStop would come too late. The recorder is still stopped when the user leaves the chat. Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru> Assisted-by: Claude-Code:claude-opus-5-5
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The change keeps a voice recording running through screen rotation while still stopping it when the user leaves the chat. No concrete merge-blocking risk was found. The change has not yet been tested on a device, so a quick manual rotation check is worthwhile. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change preserves an already authorized voice recording through screen rotation. Normal stopping and cancellation controls remain, but interrupted recreation and exceptional cleanup are not fully established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
|
Hi @ToteMeiSter thank you for your contributions. |
|
This is a bug fix and all CodeRabbit review threads are resolved. Once it is approved and merged, would it be possible to backport it to Suggested command for a maintainer after merge: This comment was drafted with AI assistance (Claude Code). |
🖼️ Screenshots
Problem
Record a voice message, lock it (slide up) and rotate the screen. The UI keeps showing a running recording, but the audio is cut off at the moment of the rotation. What is sent is a truncated file.
Cause
On
masterthe stop of the chat lifecycle always stops the recorder:app/src/main/java/com/nextcloud/talk/chat/viewmodels/ChatViewModel.kt,onStop()(around line 478):mediaRecorderManager.handleOnStop()app/src/main/java/com/nextcloud/talk/chat/data/io/MediaRecorderManager.kt,handleOnStop()(line 168) callsstop(), which stops and releases theMediaRecorder.A rotation recreates
ChatActivityand therefore also runsonStop. The ViewModel survives and keeps thelockedandinProgressstate, so the UI and the recorder disagree.Change
ChatViewModel.onStop()skipshandleOnStop()when the stopping lifecycle owner is an activity that is changing its configuration (isChangingConfigurations). The check is read from the owner on purpose:ON_STOPreaches the observer fromonActivityPreStopped(API 29+), before the body ofChatActivity.onStop()runs, so a flag set there would come too late.Leaving the chat still stops the recording as before.
Unit test
None. The changed code is the lifecycle callback of
ChatViewModel(heavy dependency graph and aninitblock that collects repository flows) andMediaRecorderitself, neither of which can be exercised in a plain JVM unit test without large mocking scaffolding that is not used forChatViewModelelsewhere. The change is a single guarded call.How to check on a device
The symptom and the fix were checked by the author on a Huawei DEL-LX9 with a fork build. In the fork the same check is wired differently (its chat view model observes a lifecycle of its own), so this exact change was built and unit-tested here, but not yet run on a device.
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)
The change was written with the help of Claude Code (Anthropic). The author reviewed the code, built it and ran the unit tests. The behavior was checked on a device with the fork variant of the fix.