Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e448a8292b724c70d880956c2bc56c647070d287
      
https://github.com/WebKit/WebKit/commit/e448a8292b724c70d880956c2bc56c647070d287
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2023-04-07 (Fri, 07 Apr 2023)

  Changed paths:
    M LayoutTests/media/media-source/media-mp4-h264-partial-abort-expected.txt
    M LayoutTests/media/media-source/media-mp4-h264-partial-abort.html
    M Source/WebCore/platform/graphics/SourceBufferPrivate.cpp
    M Source/WebCore/platform/graphics/SourceBufferPrivate.h
    M 
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
    M 
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
    M Source/WebCore/platform/graphics/cocoa/SourceBufferParser.h
    M 
Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp
    M 
Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h
    M Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
    M Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h
    M Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp
    M Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h

  Log Message:
  -----------
  SourceBufferPrivate::ResetParserState shouldn't synchronously dispatch tasks
https://bugs.webkit.org/show_bug.cgi?id=255120
rdar://107729258

Reviewed by Youenn Fablet.

The MSE's Reset Parser State algorithm [1] alongside the `abort()` [2]
operation is racy at best and leads to a non-deterministicc behaviour as
the buffer append algorithm started by the `appendBuffer()` [3] operation
runs asynchronously.

As such, having parsed the entire input buffer when the `abort()` method
is called is a valid behaviour, and we make this behaviour the default.

We now consider all operations to be sequential and we queue them to run
sequentially.
We actually abort and reset the parser only once the previous operations
have completed, all while allowing `appendBuffer()` to be called immediately
after `abort()`
As `abort()` use case is designed to be able to append a new buffer regardless
of the operation that was run before (such as a partial init or media segment)
and we continue to fullfill this requirement.

This allows to remove the need to actually abort a currently running append
operation.
This will also help when we implement MSE in a worker as the possibility
of the race allowed by the spec does no longer exists.

[1] https://w3c.github.io/media-source/#sourcebuffer-reset-parser-state
[2] https://w3c.github.io/media-source/#dom-sourcebuffer-abort
[3] https://w3c.github.io/media-source/#dom-sourcebuffer-appendbuffer

* LayoutTests/media/media-source/media-mp4-h264-partial-abort-expected.txt:
* LayoutTests/media/media-source/media-mp4-h264-partial-abort.html: Ensure that 
if abort is called
then `update` event isn't fired.

* LayoutTests/media/media-source/media-mp4-h264-partial-abort-expected.txt:
* LayoutTests/media/media-source/media-mp4-h264-partial-abort.html:
* Source/WebCore/platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::advanceOperationState):
(WebCore::SourceBufferPrivate::rewindOperationState):
(WebCore::SourceBufferPrivate::appendCompleted):
(WebCore::SourceBufferPrivate::processOperation):
(WebCore::SourceBufferPrivate::didReceiveInitializationSegment):
(WebCore::SourceBufferPrivate::didReceiveSample):
(WebCore::SourceBufferPrivate::append):
(WebCore::SourceBufferPrivate::queueOperation):
(WebCore::SourceBufferPrivate::processPendingOperations):
(WebCore::SourceBufferPrivate::abortPendingOperations):
(WebCore::SourceBufferPrivate::processError):
(WebCore::SourceBufferPrivate::abort):
(WebCore::SourceBufferPrivate::resetParserState):
(WebCore::SourceBufferPrivate::processInitOperation): Deleted.
(WebCore::SourceBufferPrivate::processMediaSamples): Deleted.
* Source/WebCore/platform/graphics/SourceBufferPrivate.h:
* 
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* 
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):
(WebCore::SourceBufferPrivateAVFObjC::appendInternal):
(WebCore::SourceBufferPrivateAVFObjC::abort):
(WebCore::SourceBufferPrivateAVFObjC::resetParserStateInternal):
(WebCore::SourceBufferPrivateAVFObjC::append): Deleted.
(WebCore::SourceBufferPrivateAVFObjC::resetParserState): Deleted.
* 
Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp:
(WebCore::SourceBufferPrivateGStreamer::appendInternal):
(WebCore::SourceBufferPrivateGStreamer::resetParserStateInternal):
(WebCore::SourceBufferPrivateGStreamer::append): Deleted.
(WebCore::SourceBufferPrivateGStreamer::abort): Deleted.
(WebCore::SourceBufferPrivateGStreamer::resetParserState): Deleted.
* Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h:
* Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockSourceBufferPrivate::appendInternal):
(WebCore::MockSourceBufferPrivate::resetParserStateInternal):
(WebCore::MockSourceBufferPrivate::append): Deleted.
(WebCore::MockSourceBufferPrivate::abort): Deleted.
* Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h:
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::appendInternal):
(WebKit::SourceBufferPrivateRemote::resetParserStateInternal):
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h:

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to