<?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>306950</bug_id>
          
          <creation_ts>2026-02-04 04:03:25 -0800</creation_ts>
          <short_desc>[WPE][WebAudio] UI thread freezes when calling `window.alert()` with an instance of `AudioContext`</short_desc>
          <delta_ts>2026-02-04 05:10:49 -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>WPE WebKit</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>302391</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Loïc Le Page">llepage</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2177905</commentid>
    <comment_count>0</comment_count>
      <attachid>478248</attachid>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 04:03:25 -0800</bug_when>
    <thetext>Created attachment 478248
Web page reproducing the issue

The issue is systematic and can be reproduced easily with this page:</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2177910</commentid>
    <comment_count>1</comment_count>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 04:17:26 -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>2177911</commentid>
    <comment_count>2</comment_count>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 04:17:57 -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>2177916</commentid>
    <comment_count>3</comment_count>
    <who name="Loïc Le Page">llepage</who>
    <bug_when>2026-02-04 05:10:49 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 302391 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>478248</attachid>
            <date>2026-02-04 04:03:25 -0800</date>
            <delta_ts>2026-02-04 04:03:25 -0800</delta_ts>
            <desc>Web page reproducing the issue</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+
CiAgPGRpdj48YnV0dG9uIGlkPSJ0cmlnZ2VyIj5UcmlnZ2VyIEFsZXJ0PC9idXR0b24+PC9kaXY+
CiAgPHNjcmlwdD4KICAgIGNvbnNvbGUubG9nKCJDcmVhdGluZyBBdWRpb0NvbnRleHQuLi4iKTsK
ICAgIG5ldyBB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