<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:jer.noble&#64;apple.com" title="Jer Noble &lt;jer.noble&#64;apple.com&gt;"> <span class="fn">Jer Noble</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - iOS 8 / OSX 10.10 WebGL - using a video from an other domain fails (CORS bug)"
   href="https://bugs.webkit.org/show_bug.cgi?id=135379">bug 135379</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #266976 Flags</td>
           <td>
               &nbsp;
           </td>
           <td>review-
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - iOS 8 / OSX 10.10 WebGL - using a video from an other domain fails (CORS bug)"
   href="https://bugs.webkit.org/show_bug.cgi?id=135379#c20">Comment # 20</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - iOS 8 / OSX 10.10 WebGL - using a video from an other domain fails (CORS bug)"
   href="https://bugs.webkit.org/show_bug.cgi?id=135379">bug 135379</a>
              from <span class="vcard"><a class="email" href="mailto:jer.noble&#64;apple.com" title="Jer Noble &lt;jer.noble&#64;apple.com&gt;"> <span class="fn">Jer Noble</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=266976&amp;action=diff" name="attach_266976" title="Proof of concept patch">attachment 266976</a> <a href="attachment.cgi?id=266976&amp;action=edit" title="Proof of concept patch">[details]</a></span>
Proof of concept patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=266976&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=266976&amp;action=review</a>

Thanks for the patch. We've previously looked into this mechanism for custom data loading of media resources, and our experiments revealed a number of problems with this approach.  Namely:

This will only work for initial requests.  Subsequent requests (for additional byte ranges, for sub-resources, or due to HTTP redirects) will not come through this path, and will thus we will not get a chance to do a CORS check on those requests.  We have to assume that these requests would not pass CORS, or we would risk opening up a hole in CORS support.  Additionally, this path is only triggered for the HLS manifest load, but requests for HLS media segments does not come through this API.

I am going to give this a r- due to the above, but only due to the shortcomings of the approach in the patch, not because of the patch itself. In addition, there are a few things in your patch I'd like to call out that would need to be fixed in the hypothetical case that the approach was valid.

<span class="quote">&gt; avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:412
&gt; +    int m_didPassCORSAccessCheck;</span >

This should be defined in terms of an enum, with defined states. Such as:

enum CORSAccessCheckResult {
    CORSAccessUnknown,
    CORSAccessDenied,
    CORSAccessAllowed,
};
CORSAccessCheckResult m_didPassCORSAccessCheck { CORSAccessUnknown };

<span class="quote">&gt; avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:514
&gt; +    , m_didPassCORSAccessCheck(0)</span >

With C++11, this style of initialization can be put in the header.

<span class="quote">&gt; avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:839
&gt; +    if (parsedURL.protocol().lower() == &quot;http&quot;) {
&gt; +        parsedURL.setProtocol(&quot;mock-http&quot;);
&gt; +    } else if (parsedURL.protocol().lower() == &quot;https&quot;) {
&gt; +        parsedURL.setProtocol(&quot;mock-https&quot;);
&gt; +    }</span >

WebKit coding style guidelines &lt;<a href="https://webkit.org/code-style-guidelines/">https://webkit.org/code-style-guidelines/</a>&gt; specify dropping braces on single-line control statements.

<span class="quote">&gt; avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:2222
&gt; +bool MediaPlayerPrivateAVFoundationObjC::didPassCORSAccessCheck() const
&gt; +{
&gt; +    //ASSERT(m_didPassCORSAccessCheck != 0);
&gt; +    return m_didPassCORSAccessCheck == 2;</span >

These should use the enum values i mentioned above.  So this would become:

return m_didPassCORSAccessCheck == CORSAccessAllowed;

<span class="quote">&gt; avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:2227
&gt; +void MediaPlayerPrivateAVFoundationObjC::didFinishCORSAccessCheck(bool passed) {
&gt; +    m_didPassCORSAccessCheck = passed ? 2 : 1;
&gt; +}</span >

And this would become:

m_didPassCORSAccessCheck = passed ? CORSAccessCheckAllowed : CORSAccessCheckDenied;

<span class="quote">&gt; avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:3445
&gt; +    URL url([m_avAsset resolvedURL]);
&gt; +    if (url.protocol() == &quot;mock-http&quot;) {
&gt; +        url.setProtocol(&quot;http&quot;);
&gt; +    } else if (url.protocol() == &quot;mock-https&quot;) {
&gt; +        url.setProtocol(&quot;https&quot;);
&gt; +    }
&gt; +    return url;</span >

Ditto about the WebKit coding style guidelines.

<span class="quote">&gt; avfoundation/objc/WebCoreAVFResourceLoader.mm:75
&gt; +    if (requestURL.protocol() == &quot;mock-http&quot;) {
&gt; +        requestURL.setProtocol(&quot;http&quot;);
&gt; +    } else if (requestURL.protocol() == &quot;mock-https&quot;) {
&gt; +        requestURL.setProtocol(&quot;https&quot;);
&gt; +    }</span >

Ditto.

<span class="quote">&gt; avfoundation/objc/WebCoreAVFResourceLoader.mm:83
&gt; +    m_origin = loader-&gt;document() ? loader-&gt;document()-&gt;securityOrigin() : nullptr;
&gt; +    ASSERT(m_origin.get());</span >

No need to add .get() to a RefPtr or RetainPtr when testing nullity.  Those classes provide a convenience bool operator.

<span class="quote">&gt; avfoundation/objc/WebCoreAVFResourceLoader.mm:117
&gt; +    bool didPassCORSAccessCheck = resource-&gt;passesAccessControlCheck(*m_origin.get());</span >

Also, they override operator*(), so no need to add a .get() before dereferencing.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>