Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a18b470687811b29dc54c960dd2d1ef0b0680555
      
https://github.com/WebKit/WebKit/commit/a18b470687811b29dc54c960dd2d1ef0b0680555
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2026-02-25 (Wed, 25 Feb 2026)

  Changed paths:
    M 
LayoutTests/http/wpt/mediarecorder/MediaRecorder-matroska-AV-audio-video-dataavailable.html
    A 
LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-small-expected.txt
    A 
LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-small.html
    M 
LayoutTests/http/wpt/mediarecorder/MediaRecorder-webm-AV-audio-video-dataavailable.html
    M LayoutTests/platform/mac/TestExpectations
    M Source/WebCore/platform/mediarecorder/MediaRecorderPrivateEncoder.cpp
    M Source/WebCore/platform/mediarecorder/MediaRecorderPrivateEncoder.h
    M Source/WebCore/platform/mediarecorder/MediaRecorderPrivateWriter.cpp
    M Source/WebCore/platform/mediarecorder/MediaRecorderPrivateWriter.h
    M 
Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterAVFObjC.h
    M 
Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterWebM.h

  Log Message:
  -----------
  REGRESSION (Safari 26): MediaRecorder emits empty Blobs for small timeslice 
values
https://bugs.webkit.org/show_bug.cgi?id=301507
rdar://163489898

Reviewed by Jer Noble.

The MediaRecorderPrivateWriter would ensure that a generated segment is always
at least one second long.
This decision was made due to two requirements:
1- a call to MediaRecorder's requestData always generate a valid segment and 
the complete
   media generated is playable.
2- AVAssetWriter requires all segments to start with a keyframe and can't 
generate partial progressive segments.

It wasn't reasonable to allow very small segments that would ultimately only
be made of video keyframes, so a minimum output of 1s was chosen.

The webm recorder due to the nature of webm (no sample table) allows to output
content progressively, with each frames gathered so far.
As MP4 requires a samples table to be produced at the start of the segment,
that segment must be finalized first before being output.

We now separate the behaviour between the WebM recorder and the mp4 one.
The WebM writer will now generate 10s long media segments, and will return
partial content whenever requestData() is called (including when the slicing 
interval has been reached).

The MP4 writer, when recording only audio, will generate a new media segment
with all the samples collected since the last request.
When recording contains video, the old behaviour of only ever generating
segment with a minimum length of 1s is retained.

Test: http/wpt/mediarecorder/MediaRecorder-start-timeSlice-small.html

* 
LayoutTests/http/wpt/mediarecorder/MediaRecorder-matroska-AV-audio-video-dataavailable.html:
 Test would have only worked earlier as dataavailable would have been called 
after 1s of data only. Amend
* 
LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-small-expected.txt:
 Added.
* LayoutTests/http/wpt/mediarecorder/MediaRecorder-start-timeSlice-small.html: 
Added.
* 
LayoutTests/http/wpt/mediarecorder/MediaRecorder-webm-AV-audio-video-dataavailable.html:
 Test would have only worked earlier as dataavailable would have been called 
after 1s of data only. Amend
* Source/WebCore/platform/mediarecorder/MediaRecorderPrivateEncoder.cpp:
(WebCore::MediaRecorderPrivateEncoder::audioSamplesAvailable):
(WebCore::MediaRecorderPrivateEncoder::appendVideoFrame):
(WebCore::MediaRecorderPrivateEncoder::segmentsMustStartWithVideoKeyframe 
const):
(WebCore::MediaRecorderPrivateEncoder::enqueueCompressedAudioSampleBuffers):
(WebCore::MediaRecorderPrivateEncoder::encodePendingVideoFrames):
(WebCore::MediaRecorderPrivateEncoder::processVideoEncoderActiveConfiguration):
(WebCore::MediaRecorderPrivateEncoder::flushToEndSegment):
(WebCore::MediaRecorderPrivateEncoder::interleaveAndEnqueueNextFrame):
(WebCore::MediaRecorderPrivateEncoder::flushPendingData):
* Source/WebCore/platform/mediarecorder/MediaRecorderPrivateEncoder.h:
* Source/WebCore/platform/mediarecorder/MediaRecorderPrivateWriter.cpp:
(WebCore::MediaRecorderPrivateWriter::writeFrames):
* Source/WebCore/platform/mediarecorder/MediaRecorderPrivateWriter.h:
* 
Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterAVFObjC.h:
* Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterWebM.h:

Canonical link: https://commits.webkit.org/308266@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to