<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>254321</bug_id>
          
          <creation_ts>2023-03-23 02:10:03 -0700</creation_ts>
          <short_desc>remotemediaplayermanager::supportsTypeAndCodecs will always return false for mediaSource in &lt;source&gt; child</short_desc>
          <delta_ts>2023-03-23 05:02:54 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=146752</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jean-Yves Avenard [:jya]">jean-yves.avenard</reporter>
          <assigned_to name="Jean-Yves Avenard [:jya]">jean-yves.avenard</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1943321</commentid>
    <comment_count>0</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2023-03-23 02:10:03 -0700</bug_when>
    <thetext>Consider the following code:

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

    var ms = new MediaSource();
    const videoSource = document.createElement(&apos;source&apos;);
    videoSource.type = &apos;video/mp4&apos;;
    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 &quot;blob&quot; 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 &amp;&amp; !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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1943322</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-03-23 02:10:28 -0700</bug_when>
    <thetext>&lt;rdar://problem/107125077&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1943324</commentid>
    <comment_count>2</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2023-03-23 02:37:54 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/11856</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1943339</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-03-23 05:02:52 -0700</bug_when>
    <thetext>Committed 262013@main (932adf06b671): &lt;https://commits.webkit.org/262013@main&gt;

Reviewed commits have been landed. Closing PR #11856 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>