<?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>270050</bug_id>
          
          <creation_ts>2024-02-25 07:54:05 -0800</creation_ts>
          <short_desc>MSE player will have readyState oscillate between readyState = HAVE_CURRENT_DATA and HAVE_ENOUGH_DATA</short_desc>
          <delta_ts>2024-02-26 14:26:25 -0800</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=265023</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>2016698</commentid>
    <comment_count>0</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2024-02-25 07:54:05 -0800</bug_when>
    <thetext>This is a regression due to bug 265023 and change in 272762@main

The change made it assume that if we have 3s of data buffered, then we can switch to readyState = HAVE_ENOUGH_DATA

The change was incorrect in multiple ways:
1- In only checks that we have buffered data past currentTime + 3s [1]
2- it doesn&apos;t check that we have 3s ahead but just 2, as it always removes 1s to the time ahead [2]
3- the MockMediaSourcePlayer doesn&apos;t play the data as such, it simply skips to the end of the next buffered range gap. And so will quickly go from readyState HAVE_ENOUGH_DATA to
HAVE_CURRENT_DATA and so change made to check the readyState in media-source-monitor-playing-event.html makes it racy [3] 
This is making media/media-source/media-source-monitor-playing-event.html 

[1] https://searchfox.org/wubkat/rev/d102bc345038f90db9ed1f3d16c42f4843f33f7c/Source/WebCore/Modules/mediasource/SourceBuffer.cpp#1304
[2] https://searchfox.org/wubkat/rev/d102bc345038f90db9ed1f3d16c42f4843f33f7c/Source/WebCore/Modules/mediasource/SourceBuffer.cpp#1302
[3] https://searchfox.org/wubkat/rev/d102bc345038f90db9ed1f3d16c42f4843f33f7c/LayoutTests/media/media-source/media-source-monitor-playing-event.html#88</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016699</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-02-25 07:54:12 -0800</bug_when>
    <thetext>&lt;rdar://problem/123597692&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016700</commentid>
    <comment_count>2</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2024-02-25 07:56:49 -0800</bug_when>
    <thetext>Addition to point 1: the test doesn&apos;t check that we have *continuous* data, just that we have buffered data in the future.

so if currentTime = 10 and we have a buffered range of:
[0, 10] [20, 30]

readyState will be HAVE_ENOUGH_DATA, when playback would have stalled.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016706</commentid>
    <comment_count>3</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2024-02-25 08:39:56 -0800</bug_when>
    <thetext>I see which code was copied from Firefox and where the error comes from:

https://searchfox.org/mozilla-central/source/dom/media/mediasource/MediaSourceDecoder.cpp#322

The logic in Firefox is broken too since https://searchfox.org/mozilla-central/diff/0412867c82b28b519898f8819a2ffe1614fa8ed0/dom/media/mediasource/MediaSourceDecoder.cpp#307

The original Firefox logic properly ensured that we had 3s of contiguous data allows only gaps of 250ms
https://searchfox.org/mozilla-central/rev/66362e5e967addc30c932be903fc75b6f6f75968/dom/media/mediasource/MediaSourceDecoder.cpp#296

(incidentally I was the author of that earlier version)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016764</commentid>
    <comment_count>4</comment_count>
    <who name="Jean-Yves Avenard [:jya]">jean-yves.avenard</who>
    <bug_when>2024-02-25 20:25:30 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/25083</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2016992</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-26 14:26:24 -0800</bug_when>
    <thetext>Committed 275348@main (747f80b0591c): &lt;https://commits.webkit.org/275348@main&gt;

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

    </bug>

</bugzilla>