Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine srcObject's MediaSourceHandle behavior #306

Merged
merged 9 commits into from
Jul 26, 2022

Conversation

wolenetz
Copy link
Member

@wolenetz wolenetz commented Mar 31, 2022

Current description of this PR:
Overall intent for a MediaSourceHandle is that it should be
[Transferable], and be restricted to "at most one" successful attachment
to the underlying MediaSource by a handle. Further, if a Window
MediaSource was previously attached using a legacy MSE object URL,
subsequent attempts to use that MediaSource instance's
MediaSourceHandle for attachment must also fail.

  • Changes MediaSource.getHandle() to be a [SameObject] readonly attribute named handle.

  • Adds HTMLMediaElement.srcObject extension subsection.

  • Updates MediaSourceHandle transfer and related attachment text to more
    clearly indicate that transferring a handle prevents re-transfer of
    that instance due to the [[Detached]] internal slot's logic, and that
    transfer is also synchronously prevented if the handle instance's
    [[has ever been assigned as srcobject]] internal slot is true. Also
    adds multiple notes to describe intent and to clarify.

  • Updates the "attaching to a media element" text to indicate that a
    MediaSourceHandle can be attached successfully to at most one media
    element ever.
    Note that legacy MSE object URL attachments similarly already achieve
    the same intent in existing implementations. This change includes a
    clarification for MSE object URL attachments, since it was never the
    intent even for main-thread MediaSource attachments for them to be
    successfully attached to more than one HTMLMediaElement at a time.
    The switch to more clear srcObject usage for worker MSE attachment
    affords the spec an opportunity to be more clear about this intent.

This refinement originates from discussion on the previous PR with
@karlt (#305) and from lengthy
discussion on this change itself at
#306.

This work is associated with the MSE-in-Worker spec issue:
#175

Original description of this PR (updated more recently per #306 (comment)):

Adds text intending to help prevent using one or more
MediaSourceHandle for the same underlying MediaSource for
simultaneous, concurrent attachments to media elements:

  • Updates MediaSource.getHandle() to succeed at most once per
    MediaSource instance.
  • Updates MediaSourceHandle transfer section to more clearly indicate
    that transferring a handle out of a context makes that handle
    unavailable for transferring again out of the same context (unless it
    is first transferred back to that context).
  • Updates the "attaching to a media element" text to indicate that a
    MediaSourceHandle can be attached successfully to at most one media
    element at a time, and with the previous 2 clarifications, ensures
    that the underlying worker context MediaSource can only be attached
    successfully to at most one media element at a time.

Note that legacy MSE object URL attachments similarly already achieve
the same intent in existing implementations. This change includes a
clarification for those similar to the third bullet, but for a
MediaSource in the "attaching to a media element" text, since it was
never the intent even for main-thread MediaSource attachments for them
to be successfully attached to more than one HTMLMediaElement at a
time. The switch to more clear srcObject usage for worker MSE
attachment affords the spec an opportunity to be more clear about this
intent.

This refinement originates from discussion on the previous PR with
@karlt: #305

This work is associated with the MSE-in-Worker spec issue:
#175


Preview | Diff

@wolenetz wolenetz requested a review from mwatson2 March 31, 2022 18:19
@wolenetz
Copy link
Member Author

@mwatson2, please review. Also, @karlt, please take a look to ensure I've addressed the issues we discussed in #305.

Thank you!

Copy link

@karlt karlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear on the best way to deal with a transfer of the MediaSourceHandle while it is set on a srcObject attribute. Alternatives to consider:

  1. Allow the transfer and error on the media element.
  2. Block transfer while on the srcObject attribute.
    The "transfer steps" caller is expecting a possible exception from DetachArrayBuffer(transferable) in the [[ArrayBufferData]] case, so I guess "transfer steps" could also throw an exception.
  3. Set [[Detached]] to true and transfer the underlying MediaSource reference "during setup worker attachment communication".
    This approach might be tricky to extend to the scenario of unsetting from this media element attribute and setting on another media element.
  4. Transfer the underlying MediaSource reference in the srcObject setter and transfer back when unset.

There is a slight difference in timing of options 3 and 4 due to awaiting stable state in the resource selection algorithm, and either of these timings could be applied to option 2.

Comment on lines 809 to 821
<dt>If the media provider object is a {{MediaSourceHandle}} or a {{MediaSource}} that is already being used
beyond this point as the media provider object in a different {{HTMLMediaElement}}'s
<a def-id="resource-fetch-algorithm"></a></dt>
<dd>Run the <a def-id="media-data-cannot-be-fetched"></a> steps of the <a
def-id="resource-fetch-algorithm"></a>'s <a def-id="media-data-processing-steps-list"></a>.</dd>
<dt>If {{MediaSource/readyState}} is NOT set to {{ReadyState/""closed""}}</dt>
<dd>Run the <a def-id="media-data-cannot-be-fetched"></a> steps of the <a
def-id="resource-fetch-algorithm"></a>'s <a def-id="media-data-processing-steps-list"></a>.</dd>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the same kind of error path, as you describe, for multiple attachments of a single MediaSource, regardless of whether from Window or Worker context, makes sense.

If a MediaSourceHandle's [[Detached]] slot is true, then would this same path be taken?
(Consider transfer out of this Window context.)
If so, then explicitly saying here would be helpful.
But the decision here may depend on the choice of direction with the transfer-while-attached scenario.

I guess the alternative is to throw in the srcObject setter, but there is no precedent for that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your analysis and presentation of options. While I think each of those options are viable, I like options 1 and 2 best. They seem to be the simplest in concept and in implementation complexity. For option 1, the resulting MediaError.message could more readily indicate the reason for the error in that case. What are the timing considerations you mentioned might apply to option 2?

Note that initial prototype implementation in Chrome might just forgo some of the complexity involved in allowed sequential re-use of the same MediaSourceHandle (and add that later). The app can always create one or more extra MediaSource instances in the worker and get those handle(s) over to the main thread for readiness to use later as a workaround in the interim.

Copy link

@karlt karlt Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider the following two commands running under the same event (i.e. without a stable state between them):

video.srcObject = handle;
port.postMessage(null, [handle]);

With option 4, the postMessage() would fail and the video would keep playing.
With option 3, [[Detached]] is not set to true until the next stable state, and so the postMessage() would succeed and the video would error.

Option 2 may be spec'd by marking the handle as in use either in the srcObject setter for similar behavior to option 4 or in the "setup worker attachment communication" steps for similar behavior to option 3.

I haven't looked into the when exactly the handle would become unused if unset from srcObject, so there may be similar timing issues there for

video.srcObject = null; // previous value was handle
port.postMessage(null, [handle]);

Perhaps option 1 is immune to these subtleties.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ #306 (comment) :

I haven't looked into the when exactly the handle would become unused if unset from srcObject, so there may be similar timing issues there for. [...]

Examining the current html5 spec, upon setting srcObject, synchronous execution of the media element load algorithm is done, which has a step that synchronously detaches MediaSource if one is the current assigned media provider object. So it seems that an implementation could readily know on the main/window thread whether or not a particular MediaSourceHandle object is currently assigned to any HTMLMediaElement as srcObject.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. Thanks for identifying that.
So, if choosing to block transfer while in use (i.e. not option 1), then for some consistency with main-thread MediaSource detach, I guess a postMessage() should succeed immediately after a handle is unset through srcObject.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karlt, yes, I think I would prefer that.
I discussed this during today's Media Working Group Call, and also have shared this thread on the media WG mailing list to get wider input.
Previously, my preference was option 2 (throw exception if currently in use as srcObject value), however I have just now observed an issue with that option (perhaps this is what you were trying to point out, too):

video.srcObject = handle;
port.postMessage(null, [handle]);

While the handle is immediately set to be the media element's assigned media provider object, the synchronous portion of this setter (which runs the load algorithm, which then starts the resource selection algorithm) begins the actual attachment in an asynchronous set of steps once the next stable state has been reached. Therefore, the postMessage transfer mechanism, invoked synchronously before that stable state has been reached, does not know that handle is in a state preventing transfer. So neither option 3 or 4 can enable option 2 to prevent transfer before that stable state has been reached.

Does this mean option 2 is infeasible? Maybe, unless we update the srcObject setter spec for when a MediaSourceHandle is set as the assigned media provider object in the synchronous section of the steps following that assignment (for example, in the load algorithm). If we did that, then we could reliably know when the handle is assigned (or not) at any attempt to transfer it. (Note, unsetting the handle as assigned media provider object is already synchronously running MSE detachment as I noted earlier today.)

Overall, my preference is to lean towards giving application synchronous awareness of failure to transfer due to handle being in-use as srcObject already. I think this would help web authors avoid having to debug additional asynchronous error transitions that are already quite overloaded with various kinds of HTMLMediaElement and MSE errors.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that, if choosing to block transfer while in use, then marking the handle as in use synchronously from the srcObject setter would produce the behavior with probably the least surprise.

@ #306 (comment) :
Examining the current html5 spec, upon setting srcObject, synchronous execution of the media element load algorithm is done, which has a step that synchronously detaches MediaSource if one is the current assigned media provider object.

FWIW I was assuming this detach was for the old/previous assigned media provider object. Perhaps that was intended, but that's not what the spec currently says. The srcObject setter "must set the element's assigned media provider object to the new value, and then invoke the element's media element load algorithm.", so the media element load algorithm detaches the new MediaSource object.

Still a synchronous release of the handle from in use when cleared from srcObject would be the least surprise behavior here.

Comment on lines 1199 to 1195
<p class="note">For example, once a worker transfers a {{MediaSourceHandle}} to another context, it cannot
transfer that handle again unless the another context first transfers it back to the worker. This prevents
ability to clone {{MediaSourceHandle}} objects and helps prevent simultaneous attachment to distinct media
elements using handles to the same underlying {{MediaSource}}.</p>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [[Detached]] internal slot provides single transfer for us, so your choice as to whether to have additional text here or not.

@wolenetz
Copy link
Member Author

wolenetz commented Jun 1, 2022

The intent is to prevent making more than one usable copy of a MediaSourceHandle for each MediaSource. Transfer semantics restrictions may not be sufficient, since basic serialization without transfer might be attempted.

I propose trying something like this (adding to my current rough prototype in Chrome):

  • Change MediaSourceHandle to be just "Serializable" (https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects)
  • For the serialization steps for MediaSourceHandle:
    • if the instance has already been serialized (e.g. some internal slot like [[AlreadySerialized]] is true), then throw exception.
    • Similarly, if forStorage is true, then throw exception.
    • If this instance is currently set as srcObject on any HTMLMediaElement, then throw exception. Note that this requires extension of HTMLMediaElement's srcObject setter synchronously update a handle internal slot, e.g., [[CurrentlyAttached]] to be true during setting srcObject to the handle (including resetting that slot to be false first for the previous srcObject if that object were also a handle.
    • Otherwise, serialize the internal state of the instance, set the instance's [[AlreadySerialized]] true. Note that this internal slot's value is reset false on the new instance resulting from deserialization.

Hopefully this adds clarity to the intent. I'll now try updating the Chrome prototype to do this and see how it goes and respond further here. @karlt and others, if you see any blockers or concerns, please report them here ASAP. Thanks!

@wolenetz
Copy link
Member Author

wolenetz commented Jun 1, 2022

e.g., [[CurrentlyAttached]] to be true during setting srcObject to the handle (including resetting that slot to be false first for the previous srcObject if that object were also a handle.

Note the HTMLMediaElement.srcObject setter doesn't have option to throw exception, but we need to synchronously let the handle know it's in the process of starting a load even before the asynchronous load operation starts. We also need to be careful to protect against the following situation:

// On main thread, handle is initially an unattached MediaSourceHandle
// just received from the worker that owns the underlying MediaSource.

media_element1.srcObject = handle;

// Would throw exception now, since handle is CurrentlyAttached:
// worker.postMessage(handle); 

// But this cannot throw exception. Rather, the mediasource attachment
// steps should later run the failure steps for media_element2:
media_element2.srcObject = handle;

// The following demonstrates that [[CurrentlyAttached]] cannot be a
// boolean since if it were, it would have been doubly set on the
// assignment of |handle| to media_element2, above:
media_element2.srcObject = null;
worker.postMessage(handle);  // If boolean, this would succeed, but shouldn't.

Based on that example, I propose changing [[CurrentlyAttached]] to be a counter
that is incremented when the handle is set to a srcObject on an HTMLMediaElement,
and decremented when the handle is explicitly unset from a srcObject on an
HTMLMediaElement. The attachment steps can then just fail if this value is not
precisely 1, and the serialization steps could throw exception if this value is not
precisely 0.

@karlt
Copy link

karlt commented Jun 1, 2022

The intent is to prevent making more than one usable copy of a MediaSourceHandle for each MediaSource. Transfer semantics restrictions may not be sufficient, since basic serialization without transfer might be attempted.

I propose trying something like this (adding to my current rough prototype in Chrome):

* Change MediaSourceHandle to be just "Serializable" (https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects)

While I assume it is possible to specify a serialize-once behavior, I always thought of such a behavior where the object becomes unusable after message passing to fit better with the [Transferable] concept rather than [Serializable].

"Transferring is effectively recreating the object while sharing a reference to the underlying data and then detaching the object being transferred."

Serialization "allows them to be stored on disk and later restored".

Was there a benefit to making the object [Serializable] rather than [Transferable]?

@wolenetz
Copy link
Member Author

wolenetz commented Jun 1, 2022

Was there a benefit to making the object [Serializable] rather than [Transferable]?

Mostly this was due to the existing Chrome transferable infrastructure is clunky and might not do the required transfer steps in a completely interoperable order (from my brief reading).
Secondly, this simplifies postMessage to be just serialization, not making developers also put the object in a transfer list.
The conditional failure if "forStorage" part of the serialization steps allows prevention of usage for other purposes.

@wolenetz
Copy link
Member Author

wolenetz commented Jun 1, 2022

Regarding the specific postMessage exception:
If [[CurrentlyAttached]] > 0 or if [[AlreadySerialized]] is true, then a postMessage attempt including that handle should throw exception. If this condition is found first among other items being posted, then the exception should be a DataCloneError.

@wolenetz
Copy link
Member Author

wolenetz commented Jun 1, 2022

I've updated the chromium prototype change for this (circa patch set 28):

  • handle copying disallowed. serialization of an instance can happen at most once (but can post a handle back and forth, assuming not currently attached).
  • srcObject setter decrements previous handle (if any) attachment counter, and increments new handle (if any) attachment counter.
  • loading steps in HTMLMediaElement do failure steps if loading via the handle and the attachment counter isn't precisely 1.
  • Note: sequential use of the same handle in the same media element (or unset on one and set on another) fails on subsequent attempts, similarly to what might happen if attempting to load a revoked mediasource object URL.
  • Note: the prototype doesn't yet disable dedicated worker MSE object URL creation, but that is the next part I'll add before getting it reviewed for landing in Chromium (along with tests).

I've tested the basic scenarios manually and it seems to be working.

@wolenetz
Copy link
Member Author

wolenetz commented Jun 1, 2022

@jernoble @karlt - I plan to proceed with getting the prototype in Chromium landed in parallel with updating this PR per the details as of #306 (comment)
Please raise any concerns you might have ASAP to prevent further delay on this highly-desired feature. Thanks!

@wolenetz
Copy link
Member Author

wolenetz commented Jun 2, 2022

@jernoble @karlt - I plan to proceed with getting the prototype in Chromium landed in parallel with updating this PR per the details as of #306 (comment)
Please raise any concerns you might have ASAP to prevent further delay on this highly-desired feature. Thanks!

Thanks to @sandersdan I am now aware of potential further complications:
It may not be interoperable to prevent postMessage(handle) from creating more than one handle, since this might actually be implicitly a broadcast on some implementations or on implementations where extensions might get a copy of messages. Achieving true move semantics is not possible. As a result, the window thread might eventually have multiple distinct handles referencing internally the same underlying worker-thread-owned MediaSource. It falls to the implementation to prevent simultaneous attachments (during the asynchronous media element load algorithm) from proceeding successfully, allowing at most 1 of them to attach successfully.
tldr: Keeping the [[IsAlreadySerialized]] proposed internal slot is not sufficient to prevent copies, but does help early detection of some of those scenarios. The media element load algorithm must fail if the same underlying MediaSource is already not 'closed'. The latter isn't a change to the spec.
Overall, Serializable is simpler ergonomically than Transferable, especially when there is potential for underlying broadcast or lack of true move semantics.

@karlt
Copy link

karlt commented Jun 3, 2022

Browser implementations are free to use different approaches if they can produce the same observable behavior. Extensions can modify behavior in any way the browser lets them, if they are prepared to expect consequences, so browsers can't expect to maintain interoperable behavior in the presence of arbitrary extensions.

But what behavior would content see from passing a MediaSourceHandle to BroadcastChannel#postMessage(), if it were serializable?

While merely transferable and not serializable, MediaSourceHandle cannot be transferred through BroadcastChannel, which is consistent with transfer of MessagePort. "transferring does not make sense in multi-destination situations." MessagePort is similar to MediaSourceHandle in that it is a transferable object used for two-directional message-passing communication between threads and processes.

@sandersdan
Copy link

sandersdan commented Jun 3, 2022

browsers can't expect to maintain interoperable behavior in the presence of arbitrary extensions.

As I understand it, all major browser implement the same behavior for message posting, which is broadcasting to all content script realms.

In WebCodecs we wanted to be able to have move semantics for VideoFrame but this detail made it impossible to implement in practice.

The situation with MediaSourceHandle is simpler because the resources it holds are less scarce, but I do want to recommend against inventing a new model for object ownership. If you don't follow the JS-like path (cloneable objects that are GC'd), there are surprising roadblocks.

But what behavior would content see from passing a MediaSourceHandle to BroadcastChannel#postMessage(), if it were serializable?

I would recommend that each receiver gets a valid handle, and that all valid handles are invalidated when one is attached.

While merely transferable and not serializable, MediaSourceHandle cannot be transferred through BroadcastChannel, which is consistent with transfer of MessagePort.

I don't think this is an option. Transferable isn't its own concept (or even an IDL attribute any more), it's a detail of the structured clone algorithm. If you can't serialize it, you can't transfer it either.

If there is a way to accomplish this combination, note that it would also prevent passing these handles through a TransferableStream.

@wolenetz
Copy link
Member Author

wolenetz commented Jun 3, 2022

I would recommend that each receiver gets a valid handle, and that all valid handles are invalidated when one is attached.

I agree. Further, for a particular handle instance, if it has ever been assigned to an HTMLMediaElement srcObject (even if the subsequent asynchronous load was interrupted and the underlying MediaSource hadn't ever been attached successfully), then that handle instance can never be successfully serialized again.

However, I think instantaneous serialization prevention of any handle instance in any realm with the same underlying MediaSource (such multiple instances can happen if extensions/broadcasts cause clones of the original single handle retrieved from MediaSource.getHandle()) upon any of those handles ever being assigned as srcObject to an HTMLMediaElement would risk security (could enable malicious high-resolution timer attacks).

So I think the following may be the best approach. If we find later that these restrictions can be relaxed, we can update the spec and implementations further:

  • prevent a handle instance from being serialized if either it has already been serialized or if it has ever been assigned as srcObject to an HTMLMediaElement (regardless of whether or not that actually resulted in successful attachment+load)
  • prevent the underlying MediaSource from being used (successfully loaded) more than once via srcObject on any HTMLMediaElement (similar to the existing object URL attachment mechanism immediately revoking the object URL on attachment start).

aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 8, 2022
Adds core MediaSourceHandle interface and modules implementation.
Later changes will enable apps to get a handle from a dedicated worker
MediaSource, post it to the main thread and attach it to an
HTMLMediaElement via the srcObject attribute; they will also include
test updates.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I9a3b47ea02d2755a9860999e245eafc26f864977
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3687146
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012115}
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 8, 2022
Adds ability for apps to get a MediaSourceHandle from a dedicated worker
MediaSource instance, gated by RuntimeEnabledFeature
"MediaSourceInWorkersUsingHandle". Updates the PassKey required for
creation of a concrete MediaSourceAttachmentSupplement to allow that
only from either URLMediaSource::createObjectURL or the new
MediaSource::getHandle method. This specificity is enabled by a new
AttachmentCreationPassKeyProvider type.
Later changes will enable apps to post the handle to the main thread and
attach it to an HTMLMediaElement via the srcObject attribute; they will
also include test updates.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

crbug.com/506273 is somewhat related, but not fixed by this change (it
refers to directly setting MediaSource on Window context to the media
element's srcObject attribute.) This change sequence is specific to
enabling MSE-in-Worker attachment via srcObject using a handle object.

BUG=878133,506273

Change-Id: Ic61f4cc4193080bdbc39234b98897d9a789778d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688613
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012129}
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 8, 2022
Adds ability to serialize a MediaSourceHandleImpl, conditionally failing
with DataCloneError if the handle is_serialized() already or if the
handle is_used() (both of those are initialized to be false
in the new instance created during deserialization.)
Later changes will enable apps to attach the handle to a main thread
HTMLMediaElement via the srcObject attribute; they will also include
test updates.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I19cc8a450423964aef78e8e468776e8cd912503a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688599
Reviewed-by: Will Cassella <cassew@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012132}
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 8, 2022
Adds ability to attach a dedicated-worker-owned MediaSource to an
HTMLMediaElement using a MediaSourceHandle for that MediaSource instance
that the app has posted over to the main thread and assigned to the
srcObject attribute on the media element. Previously, only a MediaStream
could be set as a srcObject in Chrome. This change adds the relevant
MediaProvider IDL union type and makes it the type of that srcObject
attribute. For historical reasons, the srcObject attribute of an
HTMLMediaElement is implemented in modules as a partial interface; this
change updates that partial interface as well as the media element
implementation to enable the scenario without regressing existing
ability to use MediaStream as media element's srcObject.

The attachment of the worker MediaSource using the handle does not
involve lookup into a URL registry; rather, an internal blob URL is
built into the handle when it was retrieved from the MediaSource and
that URL is used to satisfy existing media element load safety checks as
well as provide the underlying WebMediaPlayer a URL that it can use when
logging to devtools.

Later changes will add further test updates and remove the previous
ability to attach a worker MediaSource using a registered object URL.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

crbug.com/506273 is somewhat related, but not fixed by this change (it
refers to directly setting MediaSource on Window context to the media
element's srcObject attribute.) This change sequence is specific to
enabling MSE-in-Worker attachment via srcObject using a handle object.

BUG=878133,506273

Change-Id: I86cddd87bafae1c7cbae9e94ea4614418067012f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688740
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Elad Alon <eladalon@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012202}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 9, 2022
If the MediaSourceInWorkersUsingHandle feature is enabled, this change
prevents successful ability of obtaining an objectURL that would succeed
in loading a worker-owned MediaSource.

It changes the wpt tests to use handle for attachment and verifies
expected new behavior of getHandle and that worker objectURL attachment
fails (these tests run on experimental builds of Chromium with
currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
just like the currently-experimental MediaSourceInWorkers feature.)

References:
Full prototype CL for the parts 1-4 that have already landed:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 9, 2022
If the MediaSourceInWorkersUsingHandle feature is enabled, this change
prevents successful ability of obtaining an objectURL that would succeed
in loading a worker-owned MediaSource.

It changes the wpt tests to use handle for attachment and verifies
expected new behavior of getHandle and that worker objectURL attachment
fails (these tests run on experimental builds of Chromium with
currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
just like the currently-experimental MediaSourceInWorkers feature.)

References:
Full prototype CL for the parts 1-4 that have already landed:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012712}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 9, 2022
If the MediaSourceInWorkersUsingHandle feature is enabled, this change
prevents successful ability of obtaining an objectURL that would succeed
in loading a worker-owned MediaSource.

It changes the wpt tests to use handle for attachment and verifies
expected new behavior of getHandle and that worker objectURL attachment
fails (these tests run on experimental builds of Chromium with
currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
just like the currently-experimental MediaSourceInWorkers feature.)

References:
Full prototype CL for the parts 1-4 that have already landed:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012712}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 9, 2022
If the MediaSourceInWorkersUsingHandle feature is enabled, this change
prevents successful ability of obtaining an objectURL that would succeed
in loading a worker-owned MediaSource.

It changes the wpt tests to use handle for attachment and verifies
expected new behavior of getHandle and that worker objectURL attachment
fails (these tests run on experimental builds of Chromium with
currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
just like the currently-experimental MediaSourceInWorkers feature.)

References:
Full prototype CL for the parts 1-4 that have already landed:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012712}
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 10, 2022
…bjectURL"

This reverts commit 6315549.

Reason for revert: This is causing failures on the WebKit Linux Leak builder
i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/WebKit%20Linux%20Leak/39394/overview

Original change's description:
> MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL
>
> If the MediaSourceInWorkersUsingHandle feature is enabled, this change
> prevents successful ability of obtaining an objectURL that would succeed
> in loading a worker-owned MediaSource.
>
> It changes the wpt tests to use handle for attachment and verifies
> expected new behavior of getHandle and that worker objectURL attachment
> fails (these tests run on experimental builds of Chromium with
> currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
> just like the currently-experimental MediaSourceInWorkers feature.)
>
> References:
> Full prototype CL for the parts 1-4 that have already landed:
>     https://chromium-review.googlesource.com/c/chromium/src/+/3515334
> MSE spec issue:
>     w3c/media-source#175
> MSE spec feature updates switching from worker MSE attachment via
>   object URL to attachment via srcObject MediaSourceHandle:
>   * w3c/media-source#305
>   * further clarifications in discussion at
>     w3c/media-source#306 (comment)
>
> BUG=878133
>
> Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Will Cassella <cassew@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1012712}

Bug: 878133
Change-Id: I1e405ae1de146d1f3183592b00a43bd3c38d849d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3695890
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012823}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 10, 2022
…bjectURL"

This reverts commit 6315549b8c2ece3dbbf3062c1a87347589a5e115.

Reason for revert: This is causing failures on the WebKit Linux Leak builder
i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/WebKit%20Linux%20Leak/39394/overview

Original change's description:
> MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL
>
> If the MediaSourceInWorkersUsingHandle feature is enabled, this change
> prevents successful ability of obtaining an objectURL that would succeed
> in loading a worker-owned MediaSource.
>
> It changes the wpt tests to use handle for attachment and verifies
> expected new behavior of getHandle and that worker objectURL attachment
> fails (these tests run on experimental builds of Chromium with
> currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
> just like the currently-experimental MediaSourceInWorkers feature.)
>
> References:
> Full prototype CL for the parts 1-4 that have already landed:
>     https://chromium-review.googlesource.com/c/chromium/src/+/3515334
> MSE spec issue:
>     w3c/media-source#175
> MSE spec feature updates switching from worker MSE attachment via
>   object URL to attachment via srcObject MediaSourceHandle:
>   * w3c/media-source#305
>   * further clarifications in discussion at
>     w3c/media-source#306 (comment)
>
> BUG=878133
>
> Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Will Cassella <cassew@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1012712}

Bug: 878133
Change-Id: I1e405ae1de146d1f3183592b00a43bd3c38d849d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3695890
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012823}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 10, 2022
…bjectURL"

This reverts commit 6315549b8c2ece3dbbf3062c1a87347589a5e115.

Reason for revert: This is causing failures on the WebKit Linux Leak builder
i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/WebKit%20Linux%20Leak/39394/overview

Original change's description:
> MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL
>
> If the MediaSourceInWorkersUsingHandle feature is enabled, this change
> prevents successful ability of obtaining an objectURL that would succeed
> in loading a worker-owned MediaSource.
>
> It changes the wpt tests to use handle for attachment and verifies
> expected new behavior of getHandle and that worker objectURL attachment
> fails (these tests run on experimental builds of Chromium with
> currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
> just like the currently-experimental MediaSourceInWorkers feature.)
>
> References:
> Full prototype CL for the parts 1-4 that have already landed:
>     https://chromium-review.googlesource.com/c/chromium/src/+/3515334
> MSE spec issue:
>     w3c/media-source#175
> MSE spec feature updates switching from worker MSE attachment via
>   object URL to attachment via srcObject MediaSourceHandle:
>   * w3c/media-source#305
>   * further clarifications in discussion at
>     w3c/media-source#306 (comment)
>
> BUG=878133
>
> Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Will Cassella <cassew@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1012712}

Bug: 878133
Change-Id: I1e405ae1de146d1f3183592b00a43bd3c38d849d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3695890
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012823}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jun 13, 2022
…ionally fail worker objectURL, a=testonly

Automatic update from web-platform-tests
MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL

If the MediaSourceInWorkersUsingHandle feature is enabled, this change
prevents successful ability of obtaining an objectURL that would succeed
in loading a worker-owned MediaSource.

It changes the wpt tests to use handle for attachment and verifies
expected new behavior of getHandle and that worker objectURL attachment
fails (these tests run on experimental builds of Chromium with
currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
just like the currently-experimental MediaSourceInWorkers feature.)

References:
Full prototype CL for the parts 1-4 that have already landed:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012712}

--

wpt-commits: 3fec1e386568b78c390acee2307b5a07b75e3d30
wpt-pr: 34364
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jun 13, 2022
…: Conditionally fail worker objectURL", a=testonly

Automatic update from web-platform-tests
Revert "MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL"

This reverts commit 6315549b8c2ece3dbbf3062c1a87347589a5e115.

Reason for revert: This is causing failures on the WebKit Linux Leak builder
i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/WebKit%20Linux%20Leak/39394/overview

Original change's description:
> MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL
>
> If the MediaSourceInWorkersUsingHandle feature is enabled, this change
> prevents successful ability of obtaining an objectURL that would succeed
> in loading a worker-owned MediaSource.
>
> It changes the wpt tests to use handle for attachment and verifies
> expected new behavior of getHandle and that worker objectURL attachment
> fails (these tests run on experimental builds of Chromium with
> currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
> just like the currently-experimental MediaSourceInWorkers feature.)
>
> References:
> Full prototype CL for the parts 1-4 that have already landed:
>     https://chromium-review.googlesource.com/c/chromium/src/+/3515334
> MSE spec issue:
>     w3c/media-source#175
> MSE spec feature updates switching from worker MSE attachment via
>   object URL to attachment via srcObject MediaSourceHandle:
>   * w3c/media-source#305
>   * further clarifications in discussion at
>     w3c/media-source#306 (comment)
>
> BUG=878133
>
> Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Will Cassella <cassew@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1012712}

Bug: 878133
Change-Id: I1e405ae1de146d1f3183592b00a43bd3c38d849d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3695890
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012823}

--

wpt-commits: 9589b7d7210eb65f30af294f454912a5e90a7d53
wpt-pr: 34371
@karlt
Copy link

karlt commented Jun 14, 2022

As I understand it, all major browser implement the same behavior for message posting, which is broadcasting to all content script realms.

That sounds very inefficient, especially for something large like a VideoFrame, at least unless there's shared memory access involved. But efficiency is much less an issue for transferring MediaSourceHandle.

In WebCodecs we wanted to be able to have move semantics for VideoFrame but this detail made it impossible to implement in practice.

I would guess that ReadableStream.tee() support requires a Serializable object. We don't need that for MediaSourceHandle.

I do want to recommend against inventing a new model for object ownership. If you don't follow the JS-like path (cloneable objects that are GC'd), there are surprising roadblocks.

There is no new object ownership model proposed here.
MediaSourceHandle can be GC'ed without any need to be clonable/Serializable.

While merely transferable and not serializable, MediaSourceHandle cannot be transferred through BroadcastChannel, which is consistent with transfer of MessagePort.

I don't think this is an option. Transferable isn't its own concept (or even an IDL attribute any more), it's a detail of the structured clone algorithm. If you can't serialize it, you can't transfer it either.

Transferable objects already exist without any need to be Serializable: MessagePort, ReadableStream, WritableStream, and TransformStream are all examples of objects that are Transferable, but not Serializable. If browsers can implement these objects, then I don't see any reason why a Transferable and not Serializable MediaSourceHandle would be a problem.

All these objects serve a similar purpose to MediaSourceHandle in that they provide potentially cross-realm communication with at most one associated other object. (tee() is an explicit extension of this involving additional objects.)

VideoFrame is very different. VideoFrames are data, not communication portals (end-points).

A sensible way to implement and even spec MediaSourceHandle would be that it hold a MessagePort created when MediaSource.getHandle() is called, to be used as [[port to worker]] on HTMLMediaElement.

If there is a way to accomplish this combination, note that it would also prevent passing these handles through a TransferableStream.

What do you mean by TransferableStream? If you can edit and link to a spec, that might be helpful, please?

We don't have any need to pass MediaSourceHandles through ReadableStream, etc.
MediaSourceHandles are not "created, processed, and consumed in an incremental fashion", they are not transferred in large numbers, and they do not need backpressure.

@wolenetz wolenetz merged commit 099830e into w3c:main Jul 26, 2022
github-actions bot added a commit that referenced this pull request Jul 26, 2022
SHA: 099830e
Reason: push, by @wolenetz

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@wolenetz wolenetz deleted the refine-srcobject-worker-semantics branch July 26, 2022 23:18
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Jul 27, 2022
…mpler [SameObject] handle attr, a=testonly

Automatic update from web-platform-tests
MSE-in-Workers: Switch getHandle() to simpler [SameObject] handle attr

Following discussion in the spec PR #306 [1], this change updates the
way to obtain a MediaSourceHandle to be via a "handle" attribute on the
MediaSource instance that is both readonly and always returns the same
object (or throws exception, if for instance, it is attempted to be read
from a main-thread-owned MediaSource instance instead of a dedicated-
worker-owned MediaSource instance).

Also included is the removal of the readyState check when attempting to
obtain this handle (since it is now never expected to be changeable; no
sequence of distinct handles is ever expected to be obtainable from a
worker MediaSource). Also removed is the prevention of retrieving such a
handle from an instance more than once.

Multiple tests are added or updated to ensure correct behavior.

[1] w3c/media-source#306

BUG=878133

Change-Id: Ic07095d6d1dc95b8e6be818027984600aa7ab334
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3750140
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1024034}

--

wpt-commits: 5d309d6f31a279218ff15302e8cfa22c95028267
wpt-pr: 34827
wolenetz added a commit to wolenetz/mse-in-workers-demo that referenced this pull request Jul 27, 2022
With [spec PR #306](w3c/media-source#306) merged
and with implementation landed corresponding to that spec already landed
in Chromium as of 105.0.5180, MSE-in-Workers requires a
MediaSourceHandle transferred from a dedicated worker to attach a worker
MediaSource to a media element. This change updates the demo to check
for the necessary support and, use handle and srcObject for worker
mediasource attachment (still leaving legacy MediaSource object URL for
main thread mediasource attachments), and updates various instructions
and READMEs accordingly.
blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this pull request Aug 31, 2022
Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PR with handle usage refinements:
  w3c/media-source#306

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

(Initial CL landed in trunk. Expectation is to land this cherry pick
merge in M105 branch upon approval of merge following bake in Canary,
to meet the intent of shipping in M105.)

BUG=878133

(cherry picked from commit d32d977)

Change-Id: If8c429b3615a6539699c4fb0e744e9f848ab1226
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3781750
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Commit-Queue: Mike Taylor <miketaylr@chromium.org>
Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1030243}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3795560
Cr-Commit-Position: refs/branch-heads/5195@{#170}
Cr-Branched-From: 7aa3f07-refs/heads/main@{#1027018}
Kokobe pushed a commit to neevaco/chromium that referenced this pull request Sep 15, 2022
…y switching features to stable"

This reverts commit aa0e398.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=1358542

Original change's description:
> [To M105] MSE-in-Workers: Launch by switching features to stable
>
> Switches the two RuntimeEnabled features that enable MSE-in-Workers
> from experimental to stable status:
>   MediaSourceInWorkers: Basic support, still using legacy object
>     URLs for attachment
>   MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.
>
> Updates the stable webexposed expectations for both the Main/Window
> context and the DedicatedWorker context.
>
> MSE spec PR with handle usage refinements:
>   w3c/media-source#306
>
> Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two
>
> (Initial CL landed in trunk. Expectation is to land this cherry pick
> merge in M105 branch upon approval of merge following bake in Canary,
> to meet the intent of shipping in M105.)
>
> BUG=878133
>
> (cherry picked from commit d32d977)
>
> Change-Id: If8c429b3615a6539699c4fb0e744e9f848ab1226
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3781750
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Commit-Queue: Mike Taylor <miketaylr@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Mike Taylor <miketaylr@chromium.org>
> Cr-Original-Commit-Position: refs/heads/main@{#1030243}
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3795560
> Cr-Commit-Position: refs/branch-heads/5195@{chromium#170}
> Cr-Branched-From: 7aa3f07-refs/heads/main@{#1027018}

(cherry picked from commit d5cef2e)

(cherry picked from commit 23866ed)

Bug: 878133
Change-Id: Ida6148ddd29efdd0fe1944cda2a8aee1e8675894
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3869184
Owners-Override: Prudhvikumar Bommana <pbommana@google.com>
Reviewed-by: Prudhvikumar Bommana <pbommana@google.com>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Original-Original-Commit-Position: refs/branch-heads/5195@{#1039}
Cr-Original-Original-Branched-From: 7aa3f07-refs/heads/main@{#1027018}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3864081
Owners-Override: Srinivas Sista <srinivassista@chromium.org>
Reviewed-by: Srinivas Sista <srinivassista@chromium.org>
Commit-Queue: Srinivas Sista <srinivassista@chromium.org>
Cr-Original-Commit-Position: refs/branch-heads/5195_55@{#3}
Cr-Original-Branched-From: 14225de-refs/branch-heads/5195@{#856}
Cr-Original-Branched-From: 7aa3f07-refs/heads/main@{#1027018}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3871976
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Krishna Govind <govind@chromium.org>
Owners-Override: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/5195_68@{#8}
Cr-Branched-From: ad13e82-refs/branch-heads/5195@{#903}
Cr-Branched-From: 7aa3f07-refs/heads/main@{#1027018}
aarongable pushed a commit to chromium/chromium that referenced this pull request Sep 19, 2022
…stable"

This reverts commit d32d977.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=1358542

Original change's description:
> MSE-in-Workers: Launch by switching features to stable
>
> Switches the two RuntimeEnabled features that enable MSE-in-Workers
> from experimental to stable status:
>   MediaSourceInWorkers: Basic support, still using legacy object
>     URLs for attachment
>   MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.
>
> Updates the stable webexposed expectations for both the Main/Window
> context and the DedicatedWorker context.
>
> MSE spec PR with handle usage refinements:
>   w3c/media-source#306
>
> Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two
> Though this is landing in trunk, expectation is to request merge of
> this to M105 branch ASAP once landed and baked, to meet the intent of
> shipping in M105.
>
> BUG=878133
>
> Change-Id: If8c429b3615a6539699c4fb0e744e9f848ab1226
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3781750
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Commit-Queue: Mike Taylor <miketaylr@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Mike Taylor <miketaylr@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1030243}

Bug: 878133, 1358542
Change-Id: I5b15b0f244962c727099132a7d1e70d67e1d247e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3905489
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048799}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 27, 2022
…icted

This undoes the previous launch revert commit 887a8c4e3d5203b0528e7c911b24be3aa67d2b4e, and includes multiple fixes.

Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PRs with handle usage refinements:
  * w3c/media-source#306
  * this relaunch also includes implementation of spec fix from
    w3c/media-source#317

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

Versus the original launch, this relaunch:
* adds base::Feature (aka flag-guards) for each of the two
  RuntimeEnabledFeatures, above (with same feature name strings).
  This is to comply with mandatory flag-guarding PSA process update,
  and is meant to mitigate possible binary respins in the event this
  feature pair yet again needs to be disabled.
* updates the MediaSource.handle attribute getter to fix the
  regression responsible for the previous revert, complying with
  MSE spec that was fixed to prevent that regression (see PR #317
  linked above):
  * Removes NotSupportedError exception throwing logic from the
    handle attribute getter.
  * Restricts visibility of the handle attribute to only dedicated
    worker contexts (removes visibility of it from the main/Window
    context versus previous launch attempt), along with corresponding
    webexposed stable web_tests expectations matching this change.
  * Updates mediasource-worker-handle.html web_test to no longer
    expect NotSupportedError exception, nor even ability to access the
    handle attribute of a MediaSource object on the main/window
    context.

BUG=878133

Change-Id: Id34a07254b9b98e79c495429f8ed79555b0c4580
blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this pull request Sep 29, 2022
This reverts commit aa0e398.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=1358542

Original change's description:
> [To M105] MSE-in-Workers: Launch by switching features to stable
>
> Switches the two RuntimeEnabled features that enable MSE-in-Workers
> from experimental to stable status:
>   MediaSourceInWorkers: Basic support, still using legacy object
>     URLs for attachment
>   MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.
>
> Updates the stable webexposed expectations for both the Main/Window
> context and the DedicatedWorker context.
>
> MSE spec PR with handle usage refinements:
>   w3c/media-source#306
>
> Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two
>
> (Initial CL landed in trunk. Expectation is to land this cherry pick
> merge in M105 branch upon approval of merge following bake in Canary,
> to meet the intent of shipping in M105.)
>
> BUG=878133
>
> (cherry picked from commit d32d977)
>
> Change-Id: If8c429b3615a6539699c4fb0e744e9f848ab1226
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3781750
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Commit-Queue: Mike Taylor <miketaylr@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Mike Taylor <miketaylr@chromium.org>
> Cr-Original-Commit-Position: refs/heads/main@{#1030243}
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3795560
> Cr-Commit-Position: refs/branch-heads/5195@{#170}
> Cr-Branched-From: 7aa3f07-refs/heads/main@{#1027018}

(cherry picked from commit d5cef2e)

Bug: 878133
Change-Id: Ida6148ddd29efdd0fe1944cda2a8aee1e8675894
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3869184
Owners-Override: Prudhvikumar Bommana <pbommana@google.com>
Reviewed-by: Prudhvikumar Bommana <pbommana@google.com>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Original-Commit-Position: refs/branch-heads/5195@{#1039}
Cr-Original-Branched-From: 7aa3f07-refs/heads/main@{#1027018}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3868458
Reviewed-by: Thomas Guilbert <tguilbert@chromium.org>
Reviewed-by: Frank Liberato <liberato@chromium.org>
Commit-Queue: Frank Liberato <liberato@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/branch-heads/5249@{#310}
Cr-Branched-From: 4f7bea5-refs/heads/main@{#1036826}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 1, 2022
…icted

This undoes the previous launch revert commit 887a8c4e3d5203b0528e7c911b24be3aa67d2b4e, and includes multiple fixes.

Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PRs with handle usage refinements:
  * w3c/media-source#306
  * this relaunch also includes implementation of spec fix from
    w3c/media-source#317

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

Versus the original launch, this relaunch:
* adds base::Feature (aka flag-guards) for each of the two
  RuntimeEnabledFeatures, above (with same feature name strings).
  This is to comply with mandatory flag-guarding PSA process update,
  and is meant to mitigate possible binary respins in the event this
  feature pair yet again needs to be disabled.
* updates the MediaSource.handle attribute getter to fix the
  regression responsible for the previous revert, complying with
  MSE spec that was fixed to prevent that regression (see PR #317
  linked above):
  * Removes NotSupportedError exception throwing logic from the
    handle attribute getter.
  * Restricts visibility of the handle attribute to only dedicated
    worker contexts (removes visibility of it from the main/Window
    context versus previous launch attempt), along with corresponding
    webexposed stable web_tests expectations matching this change.
  * Updates mediasource-worker-handle.html web_test to no longer
    expect NotSupportedError exception, nor even ability to access the
    handle attribute of a MediaSource object on the main/window
    context.

BUG=878133

Change-Id: Id34a07254b9b98e79c495429f8ed79555b0c4580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910706
Commit-Queue: Will Cassella <cassew@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053854}
aarongable pushed a commit to chromium/chromium that referenced this pull request Oct 1, 2022
…icted

This undoes the previous launch revert commit 887a8c4, and includes multiple fixes.

Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PRs with handle usage refinements:
  * w3c/media-source#306
  * this relaunch also includes implementation of spec fix from
    w3c/media-source#317

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

Versus the original launch, this relaunch:
* adds base::Feature (aka flag-guards) for each of the two
  RuntimeEnabledFeatures, above (with same feature name strings).
  This is to comply with mandatory flag-guarding PSA process update,
  and is meant to mitigate possible binary respins in the event this
  feature pair yet again needs to be disabled.
* updates the MediaSource.handle attribute getter to fix the
  regression responsible for the previous revert, complying with
  MSE spec that was fixed to prevent that regression (see PR #317
  linked above):
  * Removes NotSupportedError exception throwing logic from the
    handle attribute getter.
  * Restricts visibility of the handle attribute to only dedicated
    worker contexts (removes visibility of it from the main/Window
    context versus previous launch attempt), along with corresponding
    webexposed stable web_tests expectations matching this change.
  * Updates mediasource-worker-handle.html web_test to no longer
    expect NotSupportedError exception, nor even ability to access the
    handle attribute of a MediaSource object on the main/window
    context.

BUG=878133

Change-Id: Id34a07254b9b98e79c495429f8ed79555b0c4580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910706
Commit-Queue: Will Cassella <cassew@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053854}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 1, 2022
…icted

This undoes the previous launch revert commit 887a8c4e3d5203b0528e7c911b24be3aa67d2b4e, and includes multiple fixes.

Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PRs with handle usage refinements:
  * w3c/media-source#306
  * this relaunch also includes implementation of spec fix from
    w3c/media-source#317

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

Versus the original launch, this relaunch:
* adds base::Feature (aka flag-guards) for each of the two
  RuntimeEnabledFeatures, above (with same feature name strings).
  This is to comply with mandatory flag-guarding PSA process update,
  and is meant to mitigate possible binary respins in the event this
  feature pair yet again needs to be disabled.
* updates the MediaSource.handle attribute getter to fix the
  regression responsible for the previous revert, complying with
  MSE spec that was fixed to prevent that regression (see PR #317
  linked above):
  * Removes NotSupportedError exception throwing logic from the
    handle attribute getter.
  * Restricts visibility of the handle attribute to only dedicated
    worker contexts (removes visibility of it from the main/Window
    context versus previous launch attempt), along with corresponding
    webexposed stable web_tests expectations matching this change.
  * Updates mediasource-worker-handle.html web_test to no longer
    expect NotSupportedError exception, nor even ability to access the
    handle attribute of a MediaSource object on the main/window
    context.

BUG=878133

Change-Id: Id34a07254b9b98e79c495429f8ed79555b0c4580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910706
Commit-Queue: Will Cassella <cassew@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053854}
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Adds core MediaSourceHandle interface and modules implementation.
Later changes will enable apps to get a handle from a dedicated worker
MediaSource, post it to the main thread and attach it to an
HTMLMediaElement via the srcObject attribute; they will also include
test updates.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I9a3b47ea02d2755a9860999e245eafc26f864977
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3687146
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012115}
NOKEYCHECK=True
GitOrigin-RevId: 2813392442e5ff5cc8702a743bdd52a1bab82be4
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Adds ability for apps to get a MediaSourceHandle from a dedicated worker
MediaSource instance, gated by RuntimeEnabledFeature
"MediaSourceInWorkersUsingHandle". Updates the PassKey required for
creation of a concrete MediaSourceAttachmentSupplement to allow that
only from either URLMediaSource::createObjectURL or the new
MediaSource::getHandle method. This specificity is enabled by a new
AttachmentCreationPassKeyProvider type.
Later changes will enable apps to post the handle to the main thread and
attach it to an HTMLMediaElement via the srcObject attribute; they will
also include test updates.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

crbug.com/506273 is somewhat related, but not fixed by this change (it
refers to directly setting MediaSource on Window context to the media
element's srcObject attribute.) This change sequence is specific to
enabling MSE-in-Worker attachment via srcObject using a handle object.

BUG=878133,506273

Change-Id: Ic61f4cc4193080bdbc39234b98897d9a789778d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688613
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012129}
NOKEYCHECK=True
GitOrigin-RevId: 09e5fb1a68416f65ef2255c846b81a46f6aa8e52
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Adds ability to serialize a MediaSourceHandleImpl, conditionally failing
with DataCloneError if the handle is_serialized() already or if the
handle is_used() (both of those are initialized to be false
in the new instance created during deserialization.)
Later changes will enable apps to attach the handle to a main thread
HTMLMediaElement via the srcObject attribute; they will also include
test updates.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I19cc8a450423964aef78e8e468776e8cd912503a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688599
Reviewed-by: Will Cassella <cassew@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012132}
NOKEYCHECK=True
GitOrigin-RevId: d5d391975da969d6242e5785c68609d6cd15fda3
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Adds ability to attach a dedicated-worker-owned MediaSource to an
HTMLMediaElement using a MediaSourceHandle for that MediaSource instance
that the app has posted over to the main thread and assigned to the
srcObject attribute on the media element. Previously, only a MediaStream
could be set as a srcObject in Chrome. This change adds the relevant
MediaProvider IDL union type and makes it the type of that srcObject
attribute. For historical reasons, the srcObject attribute of an
HTMLMediaElement is implemented in modules as a partial interface; this
change updates that partial interface as well as the media element
implementation to enable the scenario without regressing existing
ability to use MediaStream as media element's srcObject.

The attachment of the worker MediaSource using the handle does not
involve lookup into a URL registry; rather, an internal blob URL is
built into the handle when it was retrieved from the MediaSource and
that URL is used to satisfy existing media element load safety checks as
well as provide the underlying WebMediaPlayer a URL that it can use when
logging to devtools.

Later changes will add further test updates and remove the previous
ability to attach a worker MediaSource using a registered object URL.

References:
Full prototype CL:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

crbug.com/506273 is somewhat related, but not fixed by this change (it
refers to directly setting MediaSource on Window context to the media
element's srcObject attribute.) This change sequence is specific to
enabling MSE-in-Worker attachment via srcObject using a handle object.

BUG=878133,506273

Change-Id: I86cddd87bafae1c7cbae9e94ea4614418067012f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688740
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Elad Alon <eladalon@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012202}
NOKEYCHECK=True
GitOrigin-RevId: 756af69b67c9e40e0a0c92cb6c0a911c96ea6835
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
If the MediaSourceInWorkersUsingHandle feature is enabled, this change
prevents successful ability of obtaining an objectURL that would succeed
in loading a worker-owned MediaSource.

It changes the wpt tests to use handle for attachment and verifies
expected new behavior of getHandle and that worker objectURL attachment
fails (these tests run on experimental builds of Chromium with
currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
just like the currently-experimental MediaSourceInWorkers feature.)

References:
Full prototype CL for the parts 1-4 that have already landed:
    https://chromium-review.googlesource.com/c/chromium/src/+/3515334
MSE spec issue:
    w3c/media-source#175
MSE spec feature updates switching from worker MSE attachment via
  object URL to attachment via srcObject MediaSourceHandle:
  * w3c/media-source#305
  * further clarifications in discussion at
    w3c/media-source#306 (comment)

BUG=878133

Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012712}
NOKEYCHECK=True
GitOrigin-RevId: 6315549b8c2ece3dbbf3062c1a87347589a5e115
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
…bjectURL"

This reverts commit 6315549b8c2ece3dbbf3062c1a87347589a5e115.

Reason for revert: This is causing failures on the WebKit Linux Leak builder
i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/WebKit%20Linux%20Leak/39394/overview

Original change's description:
> MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL
>
> If the MediaSourceInWorkersUsingHandle feature is enabled, this change
> prevents successful ability of obtaining an objectURL that would succeed
> in loading a worker-owned MediaSource.
>
> It changes the wpt tests to use handle for attachment and verifies
> expected new behavior of getHandle and that worker objectURL attachment
> fails (these tests run on experimental builds of Chromium with
> currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
> just like the currently-experimental MediaSourceInWorkers feature.)
>
> References:
> Full prototype CL for the parts 1-4 that have already landed:
>     https://chromium-review.googlesource.com/c/chromium/src/+/3515334
> MSE spec issue:
>     w3c/media-source#175
> MSE spec feature updates switching from worker MSE attachment via
>   object URL to attachment via srcObject MediaSourceHandle:
>   * w3c/media-source#305
>   * further clarifications in discussion at
>     w3c/media-source#306 (comment)
>
> BUG=878133
>
> Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Will Cassella <cassew@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1012712}

Bug: 878133
Change-Id: I1e405ae1de146d1f3183592b00a43bd3c38d849d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3695890
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012823}
NOKEYCHECK=True
GitOrigin-RevId: f438823c5527e6499b8dedb4eef7bb8ed43f4371
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
…bjectURL

With the underlying leak fixed by
https://chromium-review.googlesource.com/c/chromium/src/+/3704191, this
change can be relanded now.

Previous revert:
> Revert "MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL"
>
> This reverts commit 6315549b8c2ece3dbbf3062c1a87347589a5e115.
>
> Reason for revert: This is causing failures on the WebKit Linux Leak builder
> i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/WebKit%20Linux%20Leak/39394/overview
>
> Original change's description:
> > MSE-in-Workers: srcObject part 5: Conditionally fail worker objectURL
> >
> > If the MediaSourceInWorkersUsingHandle feature is enabled, this change
> > prevents successful ability of obtaining an objectURL that would succeed
> > in loading a worker-owned MediaSource.
> >
> > It changes the wpt tests to use handle for attachment and verifies
> > expected new behavior of getHandle and that worker objectURL attachment
> > fails (these tests run on experimental builds of Chromium with
> > currently-experimental MediaSourceInWorkersUsingHandle feature enabled,
> > just like the currently-experimental MediaSourceInWorkers feature.)
> >
> > References:
> > Full prototype CL for the parts 1-4 that have already landed:
> >     https://chromium-review.googlesource.com/c/chromium/src/+/3515334
> > MSE spec issue:
> >     w3c/media-source#175
> > MSE spec feature updates switching from worker MSE attachment via
> >   object URL to attachment via srcObject MediaSourceHandle:
> >   * w3c/media-source#305
> >   * further clarifications in discussion at
> >     w3c/media-source#306 (comment)
> >
> > BUG=878133
> >
> > Change-Id: I60ddca79ee0f95c87b6d84e4f44ad9c283f359a3
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698231
> > Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> > Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> > Reviewed-by: Will Cassella <cassew@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1012712}
>
> Bug: 878133
> Change-Id: I1e405ae1de146d1f3183592b00a43bd3c38d849d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3695890
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
> Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1012823}

Bug: 878133
Change-Id: I56e4ecd4d8b58d9d58ed3c575b0fb52f596b6fae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3708465
Reviewed-by: Will Cassella <cassew@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1014755}
NOKEYCHECK=True
GitOrigin-RevId: 39878163d3ff90baabd342ad784671a4b54262ed
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Updates serialization logic to reflect current state of discussion of
MediaSourceHandle refinement in spec [1]:
* MediaSourceHandle was previously Serializable-only. With this change,
  it is now Transferable-only. Data clone exception will occur if it is
  attempted to be serialized without transfer. Data clone exception
  will also occur if it is transferred more than once in same
  postMessage, or if it has already been transferred.

* Updates MediaSourceHandleImpl to use "[[Detached]]" internal slot
  semantic to know when a handle instance has already been transferred.
  This is necessary, beyond just knowing if it has been serialized,
  because otherwise the following scenario could not be enforced:
     postMessage(null, [handle]); // Should succeed and detach handle.
     // Then, this should fail because handle is already detached:
     postMessage(handle, [handle]);

* Manual tests verified the scenario for the following matches similar
  existing behavior for MessagePort transfer:
     postMessage( {x: handle, y: handle}, [handle]); // should succeed
     // on receipt: e.data.x === e.data.y should be true.

Existing handle-based MSE-in-Worker web-platform-tests are updated to
use transfer instead of just serialization to communicate the handles.
Later changes may add greater coverage, similar to coverage developed
locally while vetting this scenario and precedents like MessagePort
transfer.

Later change(s) may update the IDL and getHandle() implementation
according to similar spec discussion that has requested consideration
of using: [SameObject] handle() instead of current at-most-once
getHandle() success.

No change is made to the [[has_ever_been_used_as_srcObject]] logic: it
is still necessary to prevent transferring-away of a handle instance
once it has been assigned to the srcObject attribute of a media element.

[1] w3c/media-source#306 (comment)

BUG=878133,1338956

Change-Id: Icb64aa712a0ce310984ca5fa0e9e02bd9ac428b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3733664
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1019793}
NOKEYCHECK=True
GitOrigin-RevId: 905719605fcf5dbb76a80db2dac60d3528139a05
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Following discussion in the spec PR #306 [1], this change updates the
way to obtain a MediaSourceHandle to be via a "handle" attribute on the
MediaSource instance that is both readonly and always returns the same
object (or throws exception, if for instance, it is attempted to be read
from a main-thread-owned MediaSource instance instead of a dedicated-
worker-owned MediaSource instance).

Also included is the removal of the readyState check when attempting to
obtain this handle (since it is now never expected to be changeable; no
sequence of distinct handles is ever expected to be obtainable from a
worker MediaSource). Also removed is the prevention of retrieving such a
handle from an instance more than once.

Multiple tests are added or updated to ensure correct behavior.

[1] w3c/media-source#306

BUG=878133

Change-Id: Ic07095d6d1dc95b8e6be818027984600aa7ab334
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3750140
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1024034}
NOKEYCHECK=True
GitOrigin-RevId: dcf5b5d0185160a4f93c4882801becf2397ab890
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PR with handle usage refinements:
  w3c/media-source#306

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two
Though this is landing in trunk, expectation is to request merge of
this to M105 branch ASAP once landed and baked, to meet the intent of
shipping in M105.

BUG=878133

Change-Id: If8c429b3615a6539699c4fb0e744e9f848ab1226
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3781750
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Commit-Queue: Mike Taylor <miketaylr@chromium.org>
Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1030243}
NOKEYCHECK=True
GitOrigin-RevId: d32d977b567e153ae9a41379ab87000c51e60568
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
…stable"

This reverts commit d32d977b567e153ae9a41379ab87000c51e60568.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=1358542

Original change's description:
> MSE-in-Workers: Launch by switching features to stable
>
> Switches the two RuntimeEnabled features that enable MSE-in-Workers
> from experimental to stable status:
>   MediaSourceInWorkers: Basic support, still using legacy object
>     URLs for attachment
>   MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.
>
> Updates the stable webexposed expectations for both the Main/Window
> context and the DedicatedWorker context.
>
> MSE spec PR with handle usage refinements:
>   w3c/media-source#306
>
> Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two
> Though this is landing in trunk, expectation is to request merge of
> this to M105 branch ASAP once landed and baked, to meet the intent of
> shipping in M105.
>
> BUG=878133
>
> Change-Id: If8c429b3615a6539699c4fb0e744e9f848ab1226
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3781750
> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
> Commit-Queue: Mike Taylor <miketaylr@chromium.org>
> Auto-Submit: Matthew Wolenetz <wolenetz@chromium.org>
> Reviewed-by: Mike Taylor <miketaylr@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1030243}

Bug: 878133, 1358542
Change-Id: I5b15b0f244962c727099132a7d1e70d67e1d247e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3905489
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048799}
NOKEYCHECK=True
GitOrigin-RevId: 887a8c4e3d5203b0528e7c911b24be3aa67d2b4e
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
…icted

This undoes the previous launch revert commit 887a8c4e3d5203b0528e7c911b24be3aa67d2b4e, and includes multiple fixes.

Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PRs with handle usage refinements:
  * w3c/media-source#306
  * this relaunch also includes implementation of spec fix from
    w3c/media-source#317

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

Versus the original launch, this relaunch:
* adds base::Feature (aka flag-guards) for each of the two
  RuntimeEnabledFeatures, above (with same feature name strings).
  This is to comply with mandatory flag-guarding PSA process update,
  and is meant to mitigate possible binary respins in the event this
  feature pair yet again needs to be disabled.
* updates the MediaSource.handle attribute getter to fix the
  regression responsible for the previous revert, complying with
  MSE spec that was fixed to prevent that regression (see PR #317
  linked above):
  * Removes NotSupportedError exception throwing logic from the
    handle attribute getter.
  * Restricts visibility of the handle attribute to only dedicated
    worker contexts (removes visibility of it from the main/Window
    context versus previous launch attempt), along with corresponding
    webexposed stable web_tests expectations matching this change.
  * Updates mediasource-worker-handle.html web_test to no longer
    expect NotSupportedError exception, nor even ability to access the
    handle attribute of a MediaSource object on the main/window
    context.

BUG=878133

Change-Id: Id34a07254b9b98e79c495429f8ed79555b0c4580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910706
Commit-Queue: Will Cassella <cassew@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053854}
NOKEYCHECK=True
GitOrigin-RevId: f0a6df51caab2aec1ad24e6e638e84d922a60550
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Oct 21, 2022
…s and handle visibility restricted, a=testonly

Automatic update from web-platform-tests
MSE-in-Workers: Relaunch with flag guards and handle visibility restricted

This undoes the previous launch revert commit 887a8c4e3d5203b0528e7c911b24be3aa67d2b4e, and includes multiple fixes.

Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PRs with handle usage refinements:
  * w3c/media-source#306
  * this relaunch also includes implementation of spec fix from
    w3c/media-source#317

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

Versus the original launch, this relaunch:
* adds base::Feature (aka flag-guards) for each of the two
  RuntimeEnabledFeatures, above (with same feature name strings).
  This is to comply with mandatory flag-guarding PSA process update,
  and is meant to mitigate possible binary respins in the event this
  feature pair yet again needs to be disabled.
* updates the MediaSource.handle attribute getter to fix the
  regression responsible for the previous revert, complying with
  MSE spec that was fixed to prevent that regression (see PR #317
  linked above):
  * Removes NotSupportedError exception throwing logic from the
    handle attribute getter.
  * Restricts visibility of the handle attribute to only dedicated
    worker contexts (removes visibility of it from the main/Window
    context versus previous launch attempt), along with corresponding
    webexposed stable web_tests expectations matching this change.
  * Updates mediasource-worker-handle.html web_test to no longer
    expect NotSupportedError exception, nor even ability to access the
    handle attribute of a MediaSource object on the main/window
    context.

BUG=878133

Change-Id: Id34a07254b9b98e79c495429f8ed79555b0c4580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910706
Commit-Queue: Will Cassella <cassew@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053854}

--

wpt-commits: 2108f20a92a4073b8a16d00899e976ac3dc48673
wpt-pr: 36117
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Oct 26, 2022
…s and handle visibility restricted, a=testonly

Automatic update from web-platform-tests
MSE-in-Workers: Relaunch with flag guards and handle visibility restricted

This undoes the previous launch revert commit 887a8c4e3d5203b0528e7c911b24be3aa67d2b4e, and includes multiple fixes.

Switches the two RuntimeEnabled features that enable MSE-in-Workers
from experimental to stable status:
  MediaSourceInWorkers: Basic support, still using legacy object
    URLs for attachment
  MediaSourceInWorkersUsingHandle: Upgraded to match updated MSE spec, final PR linked below.

Updates the stable webexposed expectations for both the Main/Window
context and the DedicatedWorker context.

MSE spec PRs with handle usage refinements:
  * w3c/media-source#306
  * this relaunch also includes implementation of spec fix from
    w3c/media-source#317

Intent-to-ship=https://groups.google.com/a/chromium.org/g/blink-dev/c/FRY3F1v6Two

Versus the original launch, this relaunch:
* adds base::Feature (aka flag-guards) for each of the two
  RuntimeEnabledFeatures, above (with same feature name strings).
  This is to comply with mandatory flag-guarding PSA process update,
  and is meant to mitigate possible binary respins in the event this
  feature pair yet again needs to be disabled.
* updates the MediaSource.handle attribute getter to fix the
  regression responsible for the previous revert, complying with
  MSE spec that was fixed to prevent that regression (see PR #317
  linked above):
  * Removes NotSupportedError exception throwing logic from the
    handle attribute getter.
  * Restricts visibility of the handle attribute to only dedicated
    worker contexts (removes visibility of it from the main/Window
    context versus previous launch attempt), along with corresponding
    webexposed stable web_tests expectations matching this change.
  * Updates mediasource-worker-handle.html web_test to no longer
    expect NotSupportedError exception, nor even ability to access the
    handle attribute of a MediaSource object on the main/window
    context.

BUG=878133

Change-Id: Id34a07254b9b98e79c495429f8ed79555b0c4580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910706
Commit-Queue: Will Cassella <cassew@chromium.org>
Reviewed-by: Mike Taylor <miketaylr@chromium.org>
Reviewed-by: Will Cassella <cassew@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053854}

--

wpt-commits: 2108f20a92a4073b8a16d00899e976ac3dc48673
wpt-pr: 36117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants