Repository navigation
media: Add SourceBuffer.appendTransferredBuffer() for in-place MSE parsing - #13521
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the MP4StreamParser and WebMStreamParser to support in-place parsing in both copy and borrow modes under the kCobaltInPlaceMediaSourceParser feature flag. It also renames SourceBufferWriteHead to SourceBufferExtensions and exposes appendTransferredBuffer to the SourceBuffer IDL interface. The review feedback highlights critical use-after-free vulnerabilities that can occur if the copying and borrow-mode overloads of AppendToParseBuffer are mixed after the segmented queue is initialized. To mitigate this, it is recommended to track the queue's borrow mode using a member variable and enforce strict checks in both overloads.
|
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
…rsing Expose `SourceBuffer.appendTransferredBuffer(ArrayBuffer)` and `SourceBuffer.appendTransferredBuffer(ArrayBufferView)` as a Cobalt-only MSE extension that unconditionally retains the appended `ArrayBuffer` and passes a release closure down the append path, allowing the stream parser to borrow the buffer in place regardless of feature flags. For standard `SourceBuffer.appendBuffer()`, only retain the appended `ArrayBuffer` and pass a release closure when both `kCobaltInPlaceMediaSourceParser` and `kCobaltInPlaceMediaSourceParserBorrowMode` are enabled. In `MP4StreamParser` and `WebMStreamParser`: - The 2-arg `AppendToParseBuffer(buf, release_runner)` overload now unconditionally initializes `segmented_queue_` in borrow mode (`borrow_mode=true`) without checking `kCobaltInPlaceMediaSourceParser` or `kCobaltInPlaceMediaSourceParserBorrowMode`. - The 1-arg `AppendToParseBuffer(buf)` overload checks if `kCobaltInPlaceMediaSourceParser` is enabled, and if so, initializes `segmented_queue_` in copy mode (`borrow_mode=false`). Bug: 558350763 TAG=agy CONV=af5995e6-aeff-480f-8031-f5d6b3b58791
f6c473f to
e5eade9
Compare
|
Reply for #13521 (comment), I added explict |
The copy mode experiment will be run with Finch experiment. |
andrewsavage1
left a comment
There was a problem hiding this comment.
purely reviewed blink files, but those LGTM
…r() for in-place MSE parsing Refer to original PR: #13521 Expose `SourceBuffer.appendTransferredBuffer(ArrayBuffer)` and `SourceBuffer.appendTransferredBuffer(ArrayBufferView)` as a Cobalt-only MSE extension that unconditionally retains the appended `ArrayBuffer` and passes a release closure down the append path, allowing the stream parser to borrow the buffer in place regardless of feature flags. For standard `SourceBuffer.appendBuffer()`, only retain the appended `ArrayBuffer` and pass a release closure when both `kCobaltInPlaceMediaSourceParser` and `kCobaltInPlaceMediaSourceParserBorrowMode` are enabled. In `MP4StreamParser` and `WebMStreamParser`: - The 2-arg `AppendToParseBuffer(buf, release_runner)` overload now unconditionally initializes `segmented_queue_` in borrow mode (`borrow_mode=true`) without checking `kCobaltInPlaceMediaSourceParser` or `kCobaltInPlaceMediaSourceParserBorrowMode`. - The 1-arg `AppendToParseBuffer(buf)` overload checks if `kCobaltInPlaceMediaSourceParser` is enabled, and if so, initializes `segmented_queue_` in copy mode (`borrow_mode=false`). Bug: 558350763 TAG=agy CONV=af5995e6-aeff-480f-8031-f5d6b3b58791 (cherry picked from commit 6caedb2)
…r() for in-place MSE parsing Refer to original PR: #13521 Expose `SourceBuffer.appendTransferredBuffer(ArrayBuffer)` and `SourceBuffer.appendTransferredBuffer(ArrayBufferView)` as a Cobalt-only MSE extension that unconditionally retains the appended `ArrayBuffer` and passes a release closure down the append path, allowing the stream parser to borrow the buffer in place regardless of feature flags. For standard `SourceBuffer.appendBuffer()`, only retain the appended `ArrayBuffer` and pass a release closure when both `kCobaltInPlaceMediaSourceParser` and `kCobaltInPlaceMediaSourceParserBorrowMode` are enabled. In `MP4StreamParser` and `WebMStreamParser`: - The 2-arg `AppendToParseBuffer(buf, release_runner)` overload now unconditionally initializes `segmented_queue_` in borrow mode (`borrow_mode=true`) without checking `kCobaltInPlaceMediaSourceParser` or `kCobaltInPlaceMediaSourceParserBorrowMode`. - The 1-arg `AppendToParseBuffer(buf)` overload checks if `kCobaltInPlaceMediaSourceParser` is enabled, and if so, initializes `segmented_queue_` in copy mode (`borrow_mode=false`). Bug: 558350763 TAG=agy CONV=af5995e6-aeff-480f-8031-f5d6b3b58791 (cherry picked from commit 6caedb2)
Expose
SourceBuffer.appendTransferredBuffer(ArrayBuffer)andSourceBuffer.appendTransferredBuffer(ArrayBufferView)as a Cobalt-only MSE extension that unconditionally retains the appendedArrayBufferand passes a release closure down the append path, allowing the stream parser to borrow the buffer in place regardless of feature flags.For standard
SourceBuffer.appendBuffer(), only retain the appendedArrayBufferand pass a release closure when bothkCobaltInPlaceMediaSourceParserandkCobaltInPlaceMediaSourceParserBorrowModeare enabled.In
MP4StreamParserandWebMStreamParser:AppendToParseBuffer(buf, release_runner)overload now unconditionally initializessegmented_queue_in borrow mode (borrow_mode=true) without checkingkCobaltInPlaceMediaSourceParserorkCobaltInPlaceMediaSourceParserBorrowMode.AppendToParseBuffer(buf)overload checks ifkCobaltInPlaceMediaSourceParseris enabled, and if so, initializessegmented_queue_in copy mode (borrow_mode=false).Bug: 558350763
TAG=agy
CONV=af5995e6-aeff-480f-8031-f5d6b3b58791