| Summary: | MediaRecorder.stop() fires an additional dataavailable event with bytes after MediaRecorder.pause() | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | David Mannion <dmannion> |
| Component: | WebRTC | Assignee: | youenn fablet <youennf> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | eric.carlson, jer.noble, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 15 | ||
| Hardware: | iPhone / iPad | ||
| OS: | iOS 15 | ||
|
Description
David Mannion
2022-08-11 11:42:20 PDT
Hi David, As I see it, when calling pause, we stop recording any data. But there is still some data in transit. For instance, we do not flush audio/video encoders so there might still be some data being encoded and not yet written. Ditto for the writer that gets the compressed buffer and creates the actual media stream from it. When stopping, we actually flush encoders and writer to get all available data. This probably explains why there is some remaining data available when stop is being called. Can you describe what the impact of this behavior is? Youenn, thanks for being so responsive. I figured it was a stream/buffer not getting flushed correctly, but I think its the requestData(), not pause() that is not flushing correctly. We use pause() and then requestData() so our users can continue recording if they want to (I can provide more details if you'd like). The user has the option to save/send their recording any time after pausing. They don't necessarily have to stop(). In fact, we only use the stop() method when they transition to the next section/page or if they Clear out their existing recording and want to start over and overwrite their previous recording. This works correctly in other browsers, and according to the MediaStream Recording spec, after requestData() the mediaRecoder must fire the dataavailable event passing the current blob of all the data collected so far, then create a new blob. In this sequence, start() pause() requestData() stop() The requestData() call must send all data collected up until the pause() and there should be no more data collected after the pause() because there is no call to resume(), so stop() should call dataavailable with an empty blob. The impact is that the recorded video file is truncated and missing a variable number of seconds at the end. In addition, because Webkit iOS is not spec compliant, we'd have to write custom code to handle Safari. Pull request: https://github.com/WebKit/WebKit/pull/3399 Committed 253529@main (f2967879748b): <https://commits.webkit.org/253529@main> Reviewed commits have been landed. Closing PR #3399 and removing active labels. |