Bug 254321 - remotemediaplayermanager::supportsTypeAndCodecs will always return false for mediaSource in <source> child
Summary: remotemediaplayermanager::supportsTypeAndCodecs will always return false for ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jean-Yves Avenard [:jya]
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-03-23 02:10 PDT by Jean-Yves Avenard [:jya]
Modified: 2023-03-23 05:02 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Yves Avenard [:jya] 2023-03-23 02:10:03 PDT
Consider the following code:

```
    var el = document.createElement("video");
    document.body.appendChild(el);

    var ms = new MediaSource();
    const videoSource = document.createElement('source');
    videoSource.type = 'video/mp4';
    videoSource.src = URL.createObjectURL(ms);
    el.appendChild(videoSource);
```

when we attempt to find select the new available source, we get to :
`HTMLMediaElement::selectNextSourceChild(ContentType` [1]

where we have:
```#if ENABLE(MEDIA_SOURCE)
            parameters.isMediaSource = mediaURL.protocolIs(mediaSourceBlobProtocol);
#endif
#if ENABLE(MEDIA_STREAM)
            parameters.isMediaStream = mediaURL.protocolIs(mediaStreamBlobProtocol);
#endif
```
both mediaSourceBlobProtocol and mediaStreamBlobProtocol have the same value "blob" and in the JS above would be true.

When we go through the MediaPlayerFactory to find the best suitable MediaPlayerPrivate 
The first one is the RemoteMediaPlayerManager [2] which immediately check if the object is a MediaStream.
```
    if (parameters.isMediaStream)
        return MediaPlayer::SupportsType::IsNotSupported;
```
and as such. RemoteMediaPlayerManager::supportsTypeAndCodecs always return NotSupported ; the next MediaPlayer is in `MediaPlayerPrivateMediaStreamAVFObjC` [3]
which test:
```
    return (parameters.isMediaStream && !parameters.requiresRemotePlayback) ? MediaPlayer::SupportsType::IsSupported : MediaPlayer::SupportsType::IsNotSupported;
```

and so return true.

As such we will not attempt to use the remote decoder and support is incorrectly reported.

Considering that `URL.createObjectURL(new MediaStream())` will always return false; (DOMURL only supports Blob and MediaSource objects). Assuming that we could have a blob URL constructed from a MediaStream element and make decision accordingly is nonsensical.

This bug was introduced in bug 146752.


[1] https://searchfox.org/wubkat/rev/4433b2e3d9c8bf7c4707b1afa1c8bd3a2d13f94d/Source/WebCore/html/HTMLMediaElement.cpp#5155
[2] https://searchfox.org/wubkat/rev/4433b2e3d9c8bf7c4707b1afa1c8bd3a2d13f94d/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp#220-221
[3] https://searchfox.org/wubkat/rev/4433b2e3d9c8bf7c4707b1afa1c8bd3a2d13f94d/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm#233
Comment 1 Radar WebKit Bug Importer 2023-03-23 02:10:28 PDT
<rdar://problem/107125077>
Comment 2 Jean-Yves Avenard [:jya] 2023-03-23 02:37:54 PDT
Pull request: https://github.com/WebKit/WebKit/pull/11856
Comment 3 EWS 2023-03-23 05:02:52 PDT
Committed 262013@main (932adf06b671): <https://commits.webkit.org/262013@main>

Reviewed commits have been landed. Closing PR #11856 and removing active labels.