<?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>302391</bug_id>
          
          <creation_ts>2025-11-12 03:38:02 -0800</creation_ts>
          <short_desc>REGRESSION(299424@main): [GStreamer][WPE] WebAudio doesn&apos;t resume after window.alert()</short_desc>
          <delta_ts>2026-02-09 04:10:13 -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>
          
          
          <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="Pawel Lampe">plampe</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>llepage</cc>
    
    <cc>philn</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2158201</commentid>
    <comment_count>0</comment_count>
    <who name="Pawel Lampe">plampe</who>
    <bug_when>2025-11-12 03:38:02 -0800</bug_when>
    <thetext>This is a regression after https://commits.webkit.org/299424@main

When window.alert() is used on WPE port along with existing WebAudio pipline, the &quot;resume&quot; step that is executed after actual handling of .alert() (not implemented on WPE) freezes as WebAudio pipeline cannot finish the state transition from READY to PLAYING.

The demo that reproduces problem: https://scony.github.io/web-examples/javascript/alert.html?ac=1
- expected: the counters count without any interruption.
- actual: the counters freeze after ~5s (when window.alert() is called)

I tried locally a partial reverts of https://commits.webkit.org/299424@main:
- just removing clocksync helps
- just adding queue back does not help</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2177917</commentid>
    <comment_count>1</comment_count>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 05:10:49 -0800</bug_when>
    <thetext>*** Bug 306950 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2177918</commentid>
    <comment_count>2</comment_count>
      <attachid>478249</attachid>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 05:12:13 -0800</bug_when>
    <thetext>Created attachment 478249
Reproduces the bug systematically</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2177919</commentid>
    <comment_count>3</comment_count>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 05:13:31 -0800</bug_when>
    <thetext>When calling `window.alert()` with the WPE flavor of WebKit it is just stopping the `AudioContext` and then restarting it. So, the expected result would be to have the different counters (frames and time in seconds) keeping on running. But what we obtain is that the counters are frozen (because the UI thread is frozen) during the time spent in the web page.

If you click on &quot;Trigger Alert&quot; at time=3 seconds, it will be frozen during 3 seconds.
If you click on &quot;Trigger Alert&quot; at time=20 seconds, it will be frozen during 20 seconds.

The issue comes from the fact that when the UI thread is restarting the `AudioContext`, it is waiting synchronously for the underlying GStreamer pipeline to switch to the `Playing` state but this is not happening immediately.
The audio buffers managed by the `AudioContext` are timestamped monotonically by a dedicated thread before being pushed to the rendering pipeline. This timestamping is not reset to zero after restarting the pipeline whereas the running time of this pipeline is effectively reset to zero when passing by the `Ready` state. So, when restarting the pipeline the timestamp of the next pushed buffer is the running time of the web page (like 3 seconds or 20 seconds in the former examples), whereas the pipeline is restarting at zero and then the `clocksync` in the pipeline is waiting during all this time preventing the pipeline to pre-roll and change state.

The solution is quite easy, we just need to reset the timestamp when restarting the pipeline. It can be done using 2 different approaches:
- letting the pipeline do the timestamping itself (by enabling &quot;do-timestamp&quot; in the `appsrc` and setting the pushed buffers PTS to 0)
- manually reset the actual timestamping when the `AudioContext` is restarted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2177926</commentid>
    <comment_count>4</comment_count>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 05:56:10 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/57861</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2179402</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-02-09 04:09:17 -0800</bug_when>
    <thetext>Committed 307066@main (13cab9300fd6): &lt;https://commits.webkit.org/307066@main&gt;

Reviewed commits have been landed. Closing PR #57861 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2179403</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-02-09 04:10:13 -0800</bug_when>
    <thetext>&lt;rdar://problem/169958734&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>478249</attachid>
            <date>2026-02-04 05:12:13 -0800</date>
            <delta_ts>2026-02-04 05:12:13 -0800</delta_ts>
            <desc>Reproduces the bug systematically</desc>
            <filename>audiocontext-alert.html</filename>
            <type>text/html</type>
            <size>838</size>
            <attacher name="Loïc Le Page">llepage</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPgogIDxzdHlsZT4KICAgICogewogICAgICBmb250LXNpemU6IDI0cHg7CiAg
ICB9CiAgPC9zdHlsZT4KPC9oZWFkPgo8Ym9keT4KICA8cD48c3BhbiBpZD0iZnJhbWVzIj4wPC9z
cGFuPiBmcmFtZXM8L3A+CiAgPHA+PHNwYW4gaWQ9InRpbWUiPjA8L3NwYW4+IHNlY29uZHM8L3A+
CiAgPGRpdj48YnV0dG9uIGlkPSJ0cmlnZ2VyIj5UcmlnZ2VyIEFsZXJ0PC9idX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