Skip to content

feat(recording): enhance audio session management #349

Merged
morepriyam merged 1 commit into
mainfrom
fix/recording-audio-session
May 20, 2026
Merged

feat(recording): enhance audio session management #349
morepriyam merged 1 commit into
mainfrom
fix/recording-audio-session

Conversation

@morepriyam
Copy link
Copy Markdown
Collaborator

Summary

Fixes missing audio in recorded segments. Several distinct issues compounded into the same symptom (silent video on segments 2+, or after backgrounding / preview return), all stemming from how the audio-focus PR (#317) interacted with the camera's AVAudioSession.

Fixes

1. Race between activate and recordAsync
handleRecordingStart previously did await activateRecordingSession(), but RecordButton doesn't await onRecordingStart — so recordAsync could begin before the session was reconfigured. Activation moved to useFocusEffect on the camera screen so the session is ready before the user can tap record.

2. Mid-session audio thrashing
The audio session activation lived in the same useFocusEffect as draft reload, with deps like currentDraftId and maxDurationLimitSeconds. Each state change (e.g. new draft created after recording) ran the cleanup + re-ran the effect, deactivating and reactivating AVAudioSession mid-session. This killed mic input on segments 2+. Split into a dedicated focus effect whose deps are only stable useCallbacks.

3. Mic not reattaching after preview
Returning from preview-new (which uses expo-video) leaves AVAudioSession in a playback configuration. Our hook flips it back to record, but the already-mounted CameraView doesn't re-attach to the mic on category change. Extended the existing camera-remount flag from Android-only to both platforms so the capture session is rebuilt against the freshly-recording-configured session.

4. Session lost after backgrounding / interruption
Incoming calls, Siri, or switching apps cause iOS to reclaim the audio session. useFocusEffect doesn't fire on app-foreground (only navigation focus), so the next record after resume was silent. Added an AppState listener inside the audio focus effect: when transitioning background/inactiveactive, we re-activate and remount the camera.

5. Reorder remount removed
app/reordersegments.tsx doesn't use any video player, so the audio session is untouched. Removed the unnecessary remount flag.

Drive-by

Cleaned up Swift warnings in VideoConcatModule.swift: removed unused naturalSize, preferredTransform, trackTimescale locals and the extraneous try on the non-throwing exporter.export().

@morepriyam morepriyam changed the title feat(recording): enhance audio session management during recording an… feat(recording): enhance audio session management May 20, 2026
@morepriyam morepriyam merged commit dae1095 into main May 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant