<?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>240646</bug_id>
          
          <creation_ts>2022-05-19 07:10:48 -0700</creation_ts>
          <short_desc>AudioContext fails to resume in WKWebView</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>Safari 15</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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="Ashley Gullen">ashley</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>jer.noble</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1870358</commentid>
    <comment_count>0</comment_count>
    <who name="Ashley Gullen">ashley</who>
    <bug_when>2022-05-19 07:10:48 -0700</bug_when>
    <thetext>A user of our web-based game engine Construct (www.construct.net) discovered a strange issue with Web Audio in WKWebView. I believe it&apos;s a bug in iOS.

Sample Xcode project demonstrating the issue: https://www.dropbox.com/s/5gdoxb9nkcqe9pd/Audio%20test.ios.project.zip?dl=0

This project is built using Cordova and loads some web content in WKWebView. The WKWebView is configured to allow media playback without a user gesture via mediaTypesRequiringUserActionForPlayback, so audio playback immediately on startup is allowed. The web content creates an AudioContext on startup and immediately starts playing a music track.

Press the home button and wait 30 seconds. This fully suspends the app. Then open the app again. It resumes, but there is no audio playback.

I&apos;ve debugged this and checked:
- the audio context state does return to &quot;running&quot;
- our code correctly remembers where playback reached upon suspending, and re-starts playback upon resuming
- if we add a 5 second delay before starting playback, it works correctly
- if we start playback in a touch (matching the user gesture requirements in the Safari browser), it also works correctly

So it looks like there&apos;s a bug in WKWebView where if playback is started immediately, it is not able to continue playback after suspending and resuming.

Perhaps there is a race condition where something needs to happen shortly after audio context creation for suspending/resuming to work? Immediate audio playback is not normally possible in Safari due to the user gesture requirements, so perhaps this is an overlooked aspect of WKWebView.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1872004</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-05-26 07:11:13 -0700</bug_when>
    <thetext>&lt;rdar://problem/93967995&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>