Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 97b38365f939f8106f648fa6182b8de823bb83a6
      
https://github.com/WebKit/WebKit/commit/97b38365f939f8106f648fa6182b8de823bb83a6
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-08-17 (Mon, 17 Aug 2026)

  Changed paths:
    A 
LayoutTests/media/media-source/media-source-real-webm-blockgroup-presentation-times-expected.txt
    A 
LayoutTests/media/media-source/media-source-real-webm-blockgroup-presentation-times.html
    M LayoutTests/media/media-source/webm-generator.js
    M Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp

  Log Message:
  -----------
  BlockGroup-wrapped WebM Blocks get compounding presentation times
https://bugs.webkit.org/show_bug.cgi?id=297781
rdar://problem/158943997

Reviewed by Jean-Yves Avenard.

WebMParser::m_currentDuration accumulates the duration of each frame consumed
within a single Block, so that laced frames sharing one Matroska timecode are
spaced out correctly. WebMParser::OnSimpleBlockBegin() and OnSimpleBlockEnd()
reset it to zero, but OnBlockBegin() and OnBlockEnd() did not, so for Blocks
carried inside a BlockGroup the accumulated duration was never cleared and
leaked into the next block's presentation time in OnFrame(), which computes
MediaTime(block->timecode + m_currentTimecode, m_timescale) + m_currentDuration.

The error compounds: with 20ms Opus packets, 50 back-to-back frames covering one
second of audio were timestamped 0, 0.04, 0.08, ... 1.96, so the track spanned
two seconds instead of one and every frame after the first was out of sync.

Reset m_currentDuration in OnBlockBegin() and OnBlockEnd(), mirroring the
SimpleBlock path. Only audio tracks are affected, since only
AudioTrackData::consumeFrameData() returns a frame duration for OnFrame() to
accumulate; VideoTrackData::consumeFrameData() returns a webm::Status.

Added a layout test that appends the same 50 Opus packets twice through the
synthesized WebM generator, once as bare SimpleBlocks and once wrapped in
BlockGroups, and checks that both produce the same one-second buffered range.
Taught webm-generator.js to emit SimpleBlock so the unaffected path can serve
as the baseline; it previously only ever emitted BlockGroup(Block).

* 
LayoutTests/media/media-source/media-source-real-webm-blockgroup-presentation-times-expected.txt:
 Added.
* 
LayoutTests/media/media-source/media-source-real-webm-blockgroup-presentation-times.html:
 Added.
* LayoutTests/media/media-source/webm-generator.js:
* Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::WebMParser::OnBlockBegin):
(WebCore::WebMParser::OnBlockEnd):

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



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

Reply via email to