Skip to content

Conversation

@asurdej-comcast
Copy link

@asurdej-comcast asurdej-comcast commented Jan 19, 2026

…0 and PTS > 0.

In the absence of an edit list, ensure that WebKit’s AppendPipeline extends only a single sample.

This fixes the handling of invalid streams with multiple DTS = 0 samples. Modifying PTS values for all of them results in unexpected behavior, playback issues, PTS reordering, etc.

The problem was spotted in a video web application that uses TS -> MSE transmuxing.

…0 and PTS > 0.

In the absence of an edit list, ensure that WebKit’s AppendPipeline extends only a single sample.

This fixes the handling of invalid streams with multiple DTS = 0 samples.
Modifying PTS values for all of them results in unexpected behavior,
playback issues, PTS reordering, etc.

The problem was spotted in a video web application that uses TS -> MSE transmuxing.
@asurdej-comcast
Copy link
Author

Alternatively, since Edit lists are supported, we can consider removing that code block or enable it for GST < 1.16 only

This was spot in AFV app with dailymotion/hls.js transmuxer. There were two samples with DTS=0 and PTS > 0

Jan 16 11:33:12 hisense-v2 HtmlApp-0[5557]: 0:00:15.350182055    26   0x931d20 DEBUG              webkitmse AppendPipeline.cpp:538:appsinkNewSample: Extending first sample of track '1' to make it start at PTS=0 buffer: 0xc77738, pts 0:00:00.023222222, dts 0:00:00.000000000, dur 0:00:00.000000000, size 37548, offset none, offset_end none, flags 0x4040
...
Jan 16 11:33:12 hisense-v2 HtmlApp-0[5557]: 0:00:15.350812617    26   0x931d20 DEBUG              webkitmse AppendPipeline.cpp:538:appsinkNewSample: Extending first sample of track '1' to make it start at PTS=0 buffer: 0x9f818800, pts 0:00:00.089888888, dts 0:00:00.000000000, dur 0:00:00.023222222, size 18350, offset none, offset_end none, flags 0x6000
...
Jan 16 11:33:12 hisense-v2 HtmlApp-0[5557]: [WPEWebKit:MediaSource:-] SourceBufferPrivateGStreamer::didReceiveSample(FEB30001) {"pts":{"value":0.056555,"numerator":56555,"denominator":1000000,"flags":1},"dts":{"value":0.023222,"numerator":23222,"denominator":1000000,"flags":1},"duration":{"value":0.033333,"numerator":33333,"denominator":1000000,"flags":1},"flags":0,"presentationSize":{"width":1920,"height":1080}}

@modeveci modeveci requested a review from eocanha January 20, 2026 14:05
eocanha added a commit to eocanha/WebKit that referenced this pull request Jan 20, 2026
…0 and PTS > 0

https://bugs.webkit.org/show_bug.cgi?id=305858

Reviewed by NOBODY (OOPS!).

In the absence of an edit list, ensure that WebKit’s AppendPipeline
extends only a single sample.

This fixes the handling of invalid streams with multiple DTS = 0
samples. Modifying PTS values for all of them results in unexpected
behavior, playback issues, PTS reordering, etc.

The problem was spotted in a video web application that uses TS -> MSE
transmuxing.

See: WebPlatformForEmbedded/WPEWebKit#1601

Original author: Andrzej Surdej <101130014+asurdej-comcast@users.noreply.github.com>

* Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::AppendPipeline::appsinkNewSample): Only extend first sample if no other sample has ever been extended before, or since the last parser reset. Set the hasExtendedFirstSample flag for the track on first extension.
(WebCore::AppendPipeline::resetParserState): Reset the hasExtendedFirstSample for all tracks.
* Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:
(WebCore::AppendPipeline::Track::Track): Add hasExtendedFirstSample flag.
@eocanha
Copy link
Member

eocanha commented Jan 20, 2026

I think it's better to try to introduce this patch, since it may also benefit upstream, where edit list support is reverted (but should be eventually reintroduced).

The patch looks good, although having two (or more) samples with DTS=0 can cause other problems (regardless of this patch): Since both DTS are equal, we don't have much guarantees about the stability of the DecodeOrderSampleMap in SourceBufferPrivate holding the samples. Any of the two samples with DTS=0 could be returned earlier than the other one depending on storage ordering or just luck.

Patch submitted upstream for review as https://bugs.webkit.org/show_bug.cgi?id=305858 / WebKit/WebKit#56917.

@eocanha eocanha added the upstream Related to an upstream bug (or should be at some point) label Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream Related to an upstream bug (or should be at some point) wpe-2.46

Development

Successfully merging this pull request may close these issues.

3 participants