<?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>254198</bug_id>
          
          <creation_ts>2023-03-20 22:39:03 -0700</creation_ts>
          <short_desc>[MSE] readyState should change back to HAVE_METADATA when removing sample at current playtime</short_desc>
          <delta_ts>2023-03-22 03:31:09 -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=254136</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=254207</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>1942765</commentid>
    <comment_count>0</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2023-03-20 22:39:03 -0700</bug_when>
    <thetext>This is similar to the side fix made in https://bugs.webkit.org/show_bug.cgi?id=254136
where we ensured that the readyState was updated before we fired `updateend`.

Per spec in the coded frame removal [1]
step5:
```
If this object is in activeSourceBuffers, the current playback position is greater than or equal to start and less than the remove end timestamp, and HTMLMediaElement.readyState is greater than HAVE_METADATA, then set the HTMLMediaElement.readyState attribute to HAVE_METADATA and stall playback.
```

This occurs before we return from the coded frame remove algorithm, so readyState should change before we fire the `updateend` event.

Note that there&apos;s a similar code flow for when evicting data. However due to how the MediaPlayer works in the GPU process this isn&apos;t currently achievable as the readyState change require a back and forth from CP to GPU Process, incompatible with the synchronous nature of the prepare append algorithm [2].

However, in practice it doesn&apos;t matter, as the eviction algorithm is designed in such a way that it will never evict data at the current time, and as such, the readyState can never move back to HAVE_METADATA

[1] https://w3c.github.io/media-source/#sourcebuffer-coded-frame-removal
[2] https://w3c.github.io/media-source/#sourcebuffer-prepare-append</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1942768</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-03-20 22:45:36 -0700</bug_when>
    <thetext>&lt;rdar://problem/106979551&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1942792</commentid>
    <comment_count>2</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2023-03-21 01:41:38 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/11751</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1943057</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-03-22 03:31:07 -0700</bug_when>
    <thetext>Committed 261955@main (20053bdeedfd): &lt;https://commits.webkit.org/261955@main&gt;

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

    </bug>

</bugzilla>