fix(MediaRecorder): guard pause/resume against inactive recorder to prevent InvalidStateError#3217
Conversation
β¦revent InvalidStateError
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the βοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
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 |
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-v13 #3217 +/- ##
===============================================
+ Coverage 80.86% 80.97% +0.10%
===============================================
Files 506 506
Lines 10563 10570 +7
Branches 2482 2484 +2
===============================================
+ Hits 8542 8559 +17
+ Misses 1586 1578 -8
+ Partials 435 433 -2 β View full report in Codecov by Harness. π New features to boost your workflow:
|
π― Goal
Closes REACT-789
π Implementation details
Root cause
In
MediaRecorderController,pause()guards only against the controller's internal state subject, then calls the native API unconditionally:The internal recordingState
BehaviorSubjectcan drift out of sync with the nativemediaRecorder.state. On iOS Safari the native MediaRecorder can transition to inactive on its own (interruptions, the stop button's nativestop(), track ending) while the React-driven recordingState subject still reads RECORDING. When the user taps stop then immediately pause,pause()passes its internal-state guard butthis.mediaRecorder.pause()hits an inactive recorder β InvalidStateError: The MediaRecorder's state cannot be inactive.Note the inconsistency:
stop()already guards against the nativethis.mediaRecorder?.state, butpause()/resume()guard only against the internal subject. That asymmetry is the bug.