<?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>221622</bug_id>
          
          <creation_ts>2021-02-09 11:59:24 -0800</creation_ts>
          <short_desc>[GStreamer] Cannot play most videos: Received unexpected 200 HTTP status code for range request</short_desc>
          <delta_ts>2024-04-30 09:19:28 -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>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>REOPENED</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=183259</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Philippe Normand">philn</assigned_to>
          <cc>aboya</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cadubentzen</cc>
    
    <cc>calvaris</cc>
    
    <cc>fjimenez</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>noam</cc>
    
    <cc>philn</cc>
    
    <cc>pnormand</cc>
    
    <cc>svillar</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1727163</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2021-02-09 11:59:24 -0800</bug_when>
    <thetext>Splitting this out of bug #183259. I am unable to play this video in Element:

https://gnome.modular.im/_matrix/media/r0/download/gnome.org/62a43e4dd1f71c657be994f79a4a203db9c9e708/video_514ec09.mp4

Phil says the problem is:

ERROR      webkitmediaplayer MediaPlayerPrivateGStreamer.cpp:1806:handleMessage: Error 9: R3: Received unexpected 200 HTTP status code for range request (url=https://gnome.modular.im/_matrix/media/r0/download/gnome.org/62a43e4dd1f71c657be994f79a4a203db9c9e708/video_514ec09.mp4)

Calvaris says:

&gt; AFAIK a working range request should answer 206, not 200.
&gt;
&gt; If we should accept 200 as a valid answer and be prepared to handle the whole download is a different issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1727235</commentid>
    <comment_count>1</comment_count>
    <who name="Alicia Boya García">aboya</who>
    <bug_when>2021-02-09 14:02:50 -0800</bug_when>
    <thetext>Note:

* An HTTP server serving media files should support range requests and Content-Length. Otherwise data seeks are impossible, which media players and browsers (not only WebKit) expect to be able to do.
* Safari will outright mark these videos as broken for this reason.

Implications of supporting broken servers that lack range requests:

* The only way to support this is by downloading the entire file from byte zero, either to memory or to disk.
* This adds extra complexity to WebKitWebSrc.
* Because of the layout of very common media files (e.g. non-fragmented MP4 files with a trailing moov, the most common kind of MP4 files) many files won&apos;t be able to play until the entire file has been downloaded.
* Users will assume this is a correct configuration seeing how small videos work, but later complain that playback or seeks are very slow, or about strange disk/memory usage.

Therefore, please note that the real problem here is in the server-side. This is at its core not a WebKit bug, but a server bug.

A workaround in WebKit to accomodate broken servers is technically possible, with all these caveats and some open questions, such as what to do if the video is &quot;too big&quot; (which in the case of a missing Content-Length it may not even be known in advance). Personally I wouldn&apos;t give it a high priority unless there were important websites with broken configurations like this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1727295</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2021-02-09 15:07:34 -0800</bug_when>
    <thetext>I&apos;ll trust you experts to decide what to do! Suffice to say this video works perfectly in Firefox.

It would be good to report a bug to Element if we decide not to change WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1727482</commentid>
    <comment_count>3</comment_count>
    <who name="Alicia Boya García">aboya</who>
    <bug_when>2021-02-10 02:19:55 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #2)
&gt; I&apos;ll trust you experts to decide what to do! Suffice to say this video works
&gt; perfectly in Firefox.
&gt; 
&gt; It would be good to report a bug to Element if we decide not to change
&gt; WebKit.

It would be good to report to Element regardless, since browser support would only be possible with a workaround (as explained).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1792441</commentid>
    <comment_count>4</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2021-09-10 10:45:12 -0700</bug_when>
    <thetext>Reading this: https://tools.ietf.org/id/draft-ietf-httpbis-p5-range-09.html#header.content-range

If the server ignores a byte-range-spec because it is syntactically invalid, the server SHOULD treat the request as if the invalid Range header field did not exist. (Normally, this means return a 200 response containing the full entity).

If the server receives a request (other than one including an If-Range request-header field) with an unsatisfiable Range request-header field (that is, all of whose byte-range-spec values have a first-byte-pos value greater than the current length of the selected resource), it SHOULD return a response code of 416 (Requested range not satisfiable) (Section 3.2).

Note: Clients cannot depend on servers to send a 416 (Requested range not satisfiable) response instead of a 200 (OK) response for an unsatisfiable Range request-header, since not all servers implement this request-header.

... So, do I understand correctly that we should expect 200 (OK) when the server wasn&apos;t able to fullfil the range request?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1792665</commentid>
    <comment_count>5</comment_count>
    <who name="Alicia Boya García">aboya</who>
    <bug_when>2021-09-11 01:29:14 -0700</bug_when>
    <thetext>(In reply to Philippe Normand from comment #4)
&gt; ... So, do I understand correctly that we should expect 200 (OK) when the
&gt; server wasn&apos;t able to fullfil the range request?

Yes. Which makes sense because that&apos;s what a naive server that doesn&apos;t check for the Range header will do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1857823</commentid>
    <comment_count>6</comment_count>
    <who name="Noam Rosenthal">noam</who>
    <bug_when>2022-04-04 05:41:24 -0700</bug_when>
    <thetext>See HTML PR: https://github.com/whatwg/html/pull/7782
and WPT: https://github.com/web-platform-tests/wpt/pull/33491</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958862</commentid>
    <comment_count>7</comment_count>
    <who name="Philippe Normand">philn</who>
    <bug_when>2023-05-30 13:18:29 -0700</bug_when>
    <thetext>(In reply to Noam Rosenthal from comment #6)
&gt; See HTML PR: https://github.com/whatwg/html/pull/7782
&gt; and WPT: https://github.com/web-platform-tests/wpt/pull/33491

Sadly this test doesn&apos;t seem to cover the issue at hand.
After adding the missing asset (https://github.com/WebKit/WebKit/pull/14504) the test is passing here in GTK, without patching our httpsrc element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964047</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-06-28 09:28:43 -0700</bug_when>
    <thetext>More videos that I believe are broken due to this bug (from bug #183259):

https://teams.pages.gitlab.gnome.org/Design/web-experiments/static/tiling/
https://bugs.webkit.org/attachment.cgi?id=451573</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964048</commentid>
    <comment_count>9</comment_count>
    <who name="Philippe Normand">philn</who>
    <bug_when>2023-06-28 09:32:22 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #8)
&gt; More videos that I believe are broken due to this bug (from bug #183259):
&gt; 
&gt; https://teams.pages.gitlab.gnome.org/Design/web-experiments/static/tiling/

As mentioned in the other bug, that one plays here now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964049</commentid>
    <comment_count>10</comment_count>
    <who name="Philippe Normand">philn</who>
    <bug_when>2023-06-28 09:36:46 -0700</bug_when>
    <thetext>Ah, sorry, somehow I had it in cache...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1987731</commentid>
    <comment_count>11</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-10-26 08:17:43 -0700</bug_when>
    <thetext>*** Bug 263718 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1988303</commentid>
    <comment_count>12</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2023-10-29 03:02:14 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/19687</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2015434</commentid>
    <comment_count>13</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2024-02-20 01:06:24 -0800</bug_when>
    <thetext>Another example is the video in https://release.gnome.org/45 which URL is https://release.gnome.org/45/loupe.webm</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2024187</commentid>
    <comment_count>14</comment_count>
    <who name="Carlos Bentzen">cadubentzen</who>
    <bug_when>2024-03-27 08:34:11 -0700</bug_when>
    <thetext>Commenting here just for completeness in case someone looks at this in the future.

(In reply to Michael Catanzaro from comment #0)
&gt; https://gnome.modular.im/_matrix/media/r0/download/gnome.org/
&gt; 62a43e4dd1f71c657be994f79a4a203db9c9e708/video_514ec09.mp4

This server does respond with 206 to range requests now, so they might have fixed it. (Was a bug filed?)

```
$ curl -v https://gnome.modular.im/_matrix/media/r0/download/gnome.org/62a43e4dd1f71c657be994f79a4a203db9c9e708/video_514ec09.mp4 -H &apos;Range: bytes=0-&apos; -O

...
&gt; GET /_matrix/media/r0/download/gnome.org/62a43e4dd1f71c657be994f79a4a203db9c9e708/video_514ec09.mp4 HTTP/2
&gt; Host: gnome.modular.im
&gt; User-Agent: curl/8.2.1
&gt; Accept: */*
&gt; Range: bytes=0-

&lt; HTTP/2 206 
&lt; date: Wed, 27 Mar 2024 15:06:11 GMT
&lt; content-type: video/mp4
&lt; content-length: 2404245
&lt; accept-ranges: bytes
&lt; access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
&lt; access-control-allow-origin: *
&lt; cache-control: private, max-age=259200
&lt; content-disposition: inline; filename=video_514ec09.mp4
&lt; content-range: bytes 0-2404244/2404245
&lt; content-security-policy: sandbox; default-src &apos;none&apos;; script-src &apos;none&apos;; plugin-types application/pdf; style-src &apos;unsafe-inline&apos;; media-src &apos;self&apos;; object-src &apos;self&apos;;
&lt; cross-origin-resource-policy: cross-origin
&lt; x-content-security-policy: sandbox;
&lt; x-rate-limit-duration: 1
&lt; x-rate-limit-limit: 10.00
&lt; x-rate-limit-request-forwarded-for: 84.157.74.81
&lt; x-rate-limit-request-remote-addr: 172.17.0.144:33106
&lt; x-robots-tag: noindex, nofollow, noarchive, noimageindex
&lt; strict-transport-security: max-age=15724800; includeSubDomains
```

The reason it doesn&apos;t play now is also in the HTTP response and shows in the inspector console:
```
CONSOLE SECURITY ERROR Blocked script execution in &apos;https://gnome.modular.im/_matrix/media/r0/download/gnome.org/62a43e4dd1f71c657be994f79a4a203db9c9e708/video_514ec09.mp4&apos; because the document&apos;s frame is sandboxed and the &apos;allow-scripts&apos; permission is not set.
```

It played for me after patching ScriptController::canExecuteScripts(). No idea whether this is a bug or WebKit is actually more correct here.

(In reply to Michael Catanzaro from comment #0) 
&gt; Phil says the problem is:
&gt; 
&gt; ERROR      webkitmediaplayer
&gt; MediaPlayerPrivateGStreamer.cpp:1806:handleMessage: Error 9: R3: Received
&gt; unexpected 200 HTTP status code for range request
&gt; (url=https://gnome.modular.im/_matrix/media/r0/download/gnome.org/
&gt; 62a43e4dd1f71c657be994f79a4a203db9c9e708/video_514ec09.mp4)
&gt; 

Can still reproduce this in today&apos;s trunk with:
- https://release.gnome.org/45/loupe.webm
- https://bugs.webkit.org/attachment.cgi?id=451573

With https://teams.pages.gitlab.gnome.org/Design/web-experiments/static/tiling/ the video does play, but stalls at ~7s.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2032231</commentid>
    <comment_count>15</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-04-30 09:19:28 -0700</bug_when>
    <thetext>Just a note, from https://www.rfc-editor.org/rfc/rfc9110.html#name-range-requests

&quot;&quot;&quot;
Range requests are an OPTIONAL feature of HTTP, designed so that recipients not implementing this feature (or not supporting it for the target resource) can respond as if it is a normal GET request without impacting interoperability.
&quot;&quot;&quot;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>