<?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>222183</bug_id>
          
          <creation_ts>2021-02-19 10:48:15 -0800</creation_ts>
          <short_desc>[BigSur+ Wk2] imported/w3c/web-platform-tests/media-source/mediasource-seek-during-pending-seek.html is a flakey failure</short_desc>
          <delta_ts>2021-07-22 16:47:13 -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>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <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="Amir Mark Jr">amir_mark</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>jean-yves.avenard</cc>
    
    <cc>jenner</cc>
    
    <cc>tsavell</cc>
    
    <cc>webkit-bot-watchers-bugzilla</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1731425</commentid>
    <comment_count>0</comment_count>
    <who name="Amir Mark Jr">amir_mark</who>
    <bug_when>2021-02-19 10:48:15 -0800</bug_when>
    <thetext>imported/w3c/web-platform-tests/media-source/mediasource-seek-during-pending-seek.html

Is a flakey failure on BigSur Wk2

History:

https://results.webkit.org/?suite=layout-tests&amp;test=imported%2Fw3c%2Fweb-platform-tests%2Fmedia-source%2Fmediasource-seek-during-pending-seek.html

Text Diff:

--- /Volumes/Data/slave/bigsur-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/media-source/mediasource-seek-during-pending-seek-expected.txt
+++ /Volumes/Data/slave/bigsur-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/media-source/mediasource-seek-during-pending-seek-actual.txt
@@ -1,4 +1,6 @@
+
+Harness Error (TIMEOUT), message = null
 
 PASS Test seeking to a new location before transitioning beyond HAVE_METADATA.
-PASS Test seeking to a new location during a pending seek.
+TIMEOUT Test seeking to a new location during a pending seek. Test timed out</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1731426</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-02-19 10:48:45 -0800</bug_when>
    <thetext>&lt;rdar://problem/74528766&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1732681</commentid>
    <comment_count>2</comment_count>
      <attachid>421348</attachid>
    <who name="Amir Mark Jr">amir_mark</who>
    <bug_when>2021-02-23 13:54:21 -0800</bug_when>
    <thetext>Created attachment 421348
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1732692</commentid>
    <comment_count>3</comment_count>
      <attachid>421348</attachid>
    <who name="Truitt Savell">tsavell</who>
    <bug_when>2021-02-23 14:38:29 -0800</bug_when>
    <thetext>Comment on attachment 421348
Patch

Clearing flags on attachment: 421348

Committed r273335 (234487@main): &lt;https://commits.webkit.org/234487@main&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1759554</commentid>
    <comment_count>4</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2021-05-12 22:24:56 -0700</bug_when>
    <thetext>I haven&apos;t been able to reproduce the TIMEOUT error.

However, I can easily reproduce the error:
`
FAIL Test seeking to a new location before transitioning beyond HAVE_METADATA. assert_equals: Event types match. expected &quot;seeked&quot; but got &quot;playing&quot;
`

Upon review of the spec and how this test is written, the behaviour seen is correct. This test can intermittently fail and this is to be expected.

https://github.com/web-platform-tests/wpt/blob/89505713ad43568e8e9c985d489a59209aaebad6/media-source/mediasource-seek-during-pending-seek.html#L50

The test does the following.
mediaElement.play()
mediaElement.currentTime = non_buffered_area;
it will then append data at currenTime and make sure that the `seeked` event is fired before `playing`

The `playing` event is to be fired according to HTML5 spec when the internal play steps are running.
https://html.spec.whatwg.org/multipage/media.html#internal-play-steps

&gt; 3. If the media element&apos;s paused attribute is true, then:
&gt;     1. Change the value of paused to false.
&gt;     2. If the show poster flag is true, set the element&apos;s show poster flag to false and run the time marches on steps.
&gt;     3. Queue a media element task given the media element to fire an event named play at the element.
&gt;     4. If the media element&apos;s readyState attribute has the value HAVE_NOTHING, HAVE_METADATA, or HAVE_CURRENT_DATA, queue a media element task given the media element to fire an event named waiting at the element.
&gt;        Otherwise, the media element&apos;s readyState attribute has the value HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA: notify about playing for the element.
&gt; 

The other non-normative reference to when the `playing` event is to be fired is when:
https://html.spec.whatwg.org/multipage/media.html#event-media-playing

&gt; readyState is newly equal to or greater than HAVE_FUTURE_DATA and paused is false, or paused is newly false and readyState is equal to or greater than HAVE_FUTURE_DATA. Even if this event fires, the element might still not be potentially playing, e.g. if the element is paused for user interaction or paused for in-band content. 

mediaElement.play() was called early in the test, so mediaElement.paused attribute is false. So the next time the mediaElement should be firing the `playing` event is when readyState moves to a value equal or greater than HAVE_FUTURE_DATA.

Media Source Extension clarifies the following when it comes to seeking:
https://w3c.github.io/media-source/#mediasource-seeking

&gt; 1. If new playback position is not in any TimeRanges of HTMLMediaElement.buffered
&gt;         If the HTMLMediaElement.readyState attribute is greater than HAVE_METADATA, then set the HTMLMediaElement.readyState attribute to HAVE_METADATA.
&gt;         Note
&gt; 
&gt;         Per HTMLMediaElement ready states [HTML] logic, HTMLMediaElement.readyState changes may trigger events on the HTMLMediaElement.
&gt;         The media element waits until an appendBuffer() call causes the coded frame processing algorithm to set the HTMLMediaElement.readyState attribute to a value greater than HAVE_METADATA. 
&gt; 


So per spec, when seeking to a non-buffered area, readyState will be set to HAVE_METADATA (which the test properly checks)
This is done while 
https://html.spec.whatwg.org/multipage/media.html#seeking :
&gt; Wait until the user agent has established whether or not the media data for the new playback position is available, and, if it is, until it has decoded enough data to play back that position.

The HTML spec clearly specifies here that we are to wait for *decoded* data, not until data is available (e.g. buffered). 

Now the appendBuffer operation runs and the coded frame processing algorithm is run:
https://w3c.github.io/media-source/#dfn-coded-frame-processing

&gt; 2. If the HTMLMediaElement.readyState attribute is HAVE_METADATA and the new coded frames cause HTMLMediaElement.buffered to have a TimeRanges for the current playback position, then set the HTMLMediaElement.readyState attribute to HAVE_CURRENT_DATA.
&gt; Note
&gt; 
&gt; Per HTMLMediaElement ready states [HTML] logic, HTMLMediaElement.readyState changes may trigger events on the HTMLMediaElement.
&gt; 
&gt; 3. If the HTMLMediaElement.readyState attribute is HAVE_CURRENT_DATA and the new coded frames cause HTMLMediaElement.buffered to have a TimeRanges that includes the current playback position and some time beyond the current playback position, then set the HTMLMediaElement.readyState attribute to HAVE_FUTURE_DATA.
&gt; 

So readyState during the appendBuffer and before `updateend` is fired should transition mediaElement.currentState from HAVE_METADATA to HAVE_FUTURE_DATA and fire the `playing` event.

So the order of operation when seeking in this test becomes:
1- wait until we have buffered data
2a- modify readyState to HAVE_FUTURE_DATA
2b- wait until we have enough decoded data
3- complete seeking.

When we complete the seeking operation, the `seeked` event will be fired.
Step 2a and 2b can be done in parallel, it is possible that we have enough decoded data at the same time the readyState is being modified.

so we can&apos;t assert that the `seeked` event will be fired before the `playing` event. The opposite should be a more regular occurrence.


I have opened a WPT bug:
https://github.com/web-platform-tests/wpt/issues/28984</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1778897</commentid>
    <comment_count>5</comment_count>
    <who name="Robert Jenner">jenner</who>
    <bug_when>2021-07-22 16:47:13 -0700</bug_when>
    <thetext>Expanding expectations to included BigSur+:
https://trac.webkit.org/changeset/280208/webkit</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>421348</attachid>
            <date>2021-02-23 13:54:21 -0800</date>
            <delta_ts>2021-02-23 14:38:29 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-222183-20210223155420.patch</filename>
            <type>text/plain</type>
            <size>1567</size>
            <attacher name="Amir Mark Jr">amir_mark</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjczMzMxCmRpZmYgLS1naXQgYS9MYXlvdXRUZXN0cy9DaGFu
Z2VMb2cgYi9MYXlvdXRUZXN0cy9DaGFuZ2VMb2cKaW5kZXggNzgxM2E3MjY5NDAxZWRjNDNmNTZk
NGViYjFmZTAwMjA1OGNjMTljZi4uYzFjNWI3M2ZiNGRkZjk5ZDc0MDAyZTFjN2YyYmIwNWI3OWE4
MWY1MSAxMDA2NDQKLS0tIGEvTGF5b3V0VGVzdHMvQ2hhbmdlTG9nCisrKyBiL0xheW91dFRlc3Rz
L0NoYW5nZUxvZwpAQCAtMSwzICsxLDEyIEBACisyMDIxLTAyLTIzICBBbWlyIE1hcmsgSnIgIDxh
bWlyX21hcmtAYXBwbGUuY29tPgorCisgICAgICAgIFtCaWdTdXIgV2syXSBpbXBvcnRlZC93M2Mv
d2ViLXBsYXRmb3JtLXRlc3RzL21lZGlhLXNvdXJjZS9tZWRpYXNvdXJjZS1zZWVrLWR1cmluZy1w
ZW5kaW5nLXNlZWsuaHRtbCBpcyBhIGZsYWtleSBmYWlsdXJlLgorICAgICAgICBodHRwczovL2J1
Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MjIyMTgzCisKKyAgICAgICAgVW5yZXZpZXdl
ZCB0ZXN0IGdhcmRlbmluZy4KKworICAgICAgICAqIHBsYXRmb3JtL21hYy13azIvVGVzdEV4cGVj
dGF0aW9uczoKKwogMjAyMS0wMi0yMyAgRnJ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