[Webkit-unassigned] [Bug 205599] New: Closing an AudioContext kills native audio played using an AVAudioPlayer

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Dec 26 14:48:05 PST 2019


https://bugs.webkit.org/show_bug.cgi?id=205599

            Bug ID: 205599
           Summary: Closing an AudioContext kills native audio played
                    using an AVAudioPlayer
           Product: WebKit
           Version: Safari 13
          Hardware: iPhone / iPad
                OS: iOS 13
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Audio
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: distinctdan at gmail.com

My hybrid app uses html5 webaudio for sound effects, as well as native audio for background music. I'm closing an AudioContext as part of a hack to get iOS 12 to play audio at the correct sample rate (related to https://stackoverflow.com/a/37057640/2095953). However, when I close the context, it kills any native audio that is already playing using AVAudioPlayer. It's not a hard stop, it's a quick fadeout just like if you press the home button. This is unexpected because I wouldn't expect a webview to be able to affect native audio at all. My current workaround is delaying my native audio from starting until after I've done the context close + a short timeout.

Here's some simplified sample code to show the flow:

// Objective C - runs first
player = [[AVAudioPlayer alloc] initWithContentsOfURL:pathURL error:&err];
[player play];

// JS - play a short sound that's at 48khz, then recreate context to get iOS 12 to play audio at the correct sample rate instead of 44.1khz.
htmlAudioEl.play().then(() => {
    htmlAudioEl.pause();
    this.ctx.close();
    this.ctx = new AudioContext({sampleRate: 48000});
});

// All audio then fades out and never plays again.

Info
----------
Using WkWebView for the webview
Replicated on:
- iPod Touch 6th gen running iOS 12.4.3
- iPad Pro 11inch running iOS 13.2.3

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20191226/3bda1f5a/attachment.htm>


More information about the webkit-unassigned mailing list