Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6a4f6ef25f273ad58f645939a38050097967e1aa
      
https://github.com/WebKit/WebKit/commit/6a4f6ef25f273ad58f645939a38050097967e1aa
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2026-06-09 (Tue, 09 Jun 2026)

  Changed paths:
    A 
LayoutTests/media/media-source/media-managedmse-adts-aac-remove-expected.txt
    A LayoutTests/media/media-source/media-managedmse-adts-aac-remove.html
    M LayoutTests/platform/glib/TestExpectations
    M Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm
    M Source/WebCore/platform/graphics/cocoa/CMUtilities.h
    M Source/WebCore/platform/graphics/cocoa/CMUtilities.mm

  Log Message:
  -----------
  [MSE][Cocoa] MediaSampleAVFObjC methods other than divide() failed on 
CMSampleBuffers without a sample-size array
https://bugs.webkit.org/show_bug.cgi?id=316467
rdar://178866459

Reviewed by Jer Noble.

For some compressed audio (e.g. ADTS-framed AAC), AVStreamDataParser
emits multi-packet CMSampleBuffers whose CMSampleBufferGetSampleSizeArray
returns kCMSampleBufferError_BufferHasNoSampleSizes; per-packet sizes
are carried in the audio stream packet description array instead.

webkit.org/b/316425 fixed MediaSampleAVFObjC::divide() (the no-arg form
used by the IPC encode path) for that shape via an inline
packet-description walk. The other methods that consume the underlying
CMSampleBufferRef were not addressed: isDivisable() returned false for
the shape, divide(time, useEndTime) and divideIntoHomogeneousSamples()
called PAL primitives that required a populated sample-size array, and
createCopyWithAdjustedStartTime duplicated the same timing-array boilerplate
that divide() carried.

The visible consequence was that TrackBuffer could not subdivide these
samples at an arbitrary presentation time. SourceBuffer.remove(start, end)
and the appendWindow trim path therefore treated each multi-packet
sample atomically: removing a sub-range that landed inside one of them
erased the entire sample (or kept it whole when only a tail
should have remained), and SourceBuffer.buffered jumped to the next
sample boundary instead of the requested time.

The BufferHasNoSampleSizes handling now lives in shared helpers in
CMUtilities, and the MediaSampleAVFObjC consumers route through them so
both CMSampleBuffer shapes are handled uniformly. forEachSample replaces
PAL::CMSampleBufferCallBlockForEachSample, and copySampleBufferForRange
replaces PAL::CMSampleBufferCopySampleBufferForRange. For the
BufferHasNoSampleSizes case they walk the packet description array and
synthesize per-packet (or per-range) sub-CMSampleBuffers that reference
the source block buffer via CMBlockBufferAppendBufferReference (zero-copy);
for the normal shape they delegate. getSampleTimingInfoArray collapses
the two-call CMSampleBufferGetSampleTimingInfoArray dance.

* LayoutTests/media/media-source/media-managedmse-adts-aac-remove-expected.txt: 
Added.
* LayoutTests/media/media-source/media-managedmse-adts-aac-remove.html: Added.
* Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::isDivisable const): Stopped rejecting the
BufferHasNoSampleSizes shape; only the single-sample case is rejected now.
(WebCore::MediaSampleAVFObjC::divide): Replaced the inline
BufferHasNoSampleSizes block and the CMSampleBufferCallBlockForEachSample
call with a single forEachSample walk.
(WebCore::MediaSampleAVFObjC::divide): Routed through forEachSample +
copySampleBufferForRange so the time-based split works on both shapes.
(WebCore::MediaSampleAVFObjC::createCopyWithAdjustedStartTime const):
Routed timing-array fetch through getSampleTimingInfoArray.
(WebCore::MediaSampleAVFObjC::divideIntoHomogeneousSamples): Routed
through copySampleBufferForRange.
* Source/WebCore/platform/graphics/cocoa/CMUtilities.h:
* Source/WebCore/platform/graphics/cocoa/CMUtilities.mm:
(WebCore::getSampleTimingInfoArray): Added.
(WebCore::forEachSample): Added.
(WebCore::copySampleBufferForRange): Added.

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



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

Reply via email to