<?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>202846</bug_id>
          
          <creation_ts>2019-10-11 03:48:51 -0700</creation_ts>
          <short_desc>AudioContext stops playing when suspended on visibilitychange</short_desc>
          <delta_ts>2024-11-11 23:43:15 -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>Web Audio</component>
          <version>Other</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 13</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=281566</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="Jesper van den Ende">jespertheend</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>jer.noble</cc>
    
    <cc>jespertheend</cc>
    
    <cc>johndoe437528</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1579059</commentid>
    <comment_count>0</comment_count>
      <attachid>380740</attachid>
    <who name="Jesper van den Ende">jespertheend</who>
    <bug_when>2019-10-11 03:48:51 -0700</bug_when>
    <thetext>Created attachment 380740
demonstration of the issue

When suspending an audio context in the visibilitychange event of a document, resuming the audio context does not start playing audio.
Check the attached file for a demonstration.

-open the file on safari on iOS 13.1.2
-tap the resume button
-close safari
-note how the audio stops playing
-open safari again
-note how the audio does not resume, the current time stays the same even though the state of the audio context is still &quot;running&quot;
-tapping the resume button doesn&apos;t do anything
-only after tapping the suspend button and then the resume button, the audio context starts playing
-when &apos;suspend on visibility change&apos; is unchecked, the problem does not occur.
-the problem also does not occur on iOS 12, though on iOS 12 the audio keeps on playing when the checkbox is not checked.

I wasn&apos;t able to reproduce this issue in the simulator on iOS 13.1, I was not able to download the iOS 13.1.2 simulator.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1579064</commentid>
    <comment_count>1</comment_count>
    <who name="Jesper van den Ende">jespertheend</who>
    <bug_when>2019-10-11 04:27:14 -0700</bug_when>
    <thetext>A temporary workaround for this issue is to put the ctx.resume() call of the visibilitychange event in a setTimeout with about 300ms.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1579133</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-10-11 09:59:39 -0700</bug_when>
    <thetext>&lt;rdar://problem/56194169&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1716568</commentid>
    <comment_count>3</comment_count>
    <who name="John Doe">johndoe437528</who>
    <bug_when>2020-12-24 04:47:21 -0800</bug_when>
    <thetext>The setTimeout of ≈ 300 is also required for resuming the audioContext on pageshow, as it seems.

Though I&apos;m not sure why I need to call resume on pageshow, shouldn&apos;t that be done automatic by the browser as it suspends the audioContext when leaving the page?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>380740</attachid>
            <date>2019-10-11 03:48:51 -0700</date>
            <delta_ts>2019-10-11 03:48:51 -0700</delta_ts>
            <desc>demonstration of the issue</desc>
            <filename>webkitaudiobug.html</filename>
            <type>text/html</type>
            <size>1138</size>
            <attacher name="Jesper van den Ende">jespertheend</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgoJPGhlYWQ+CgkJPHRpdGxlPldlY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