Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 13 webaudio is totally broken for html audio elements within a webview

I'm building a mobile game using cordova, using wkwebview, and I'm having a major issue with audio not working on iOS 13 (specifically iPadOS 13.2.2). I have several html audio elements connected to an AudioContext, and when I play one after the context has been resumed, there are no js errors and everything looks good from the js side. However, it doesn't play any sound, and on the native iOS side, it throws this error:

2019-11-15 18:27:09.610800-0500 MyApp[9045:99562] [assertion] Error acquiring assertion: <NSError: 0x2811ddfe0; domain: RBSAssertionErrorDomain; code: 2; reason: "Client is missing required entitlement"> {
    userInfo = {
        RBSAssertionAttribute = <RBSLegacyAttribute: 0x111048cf0; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>;
    }
}
2019-11-15 18:27:09.610840-0500 MyApp[9045:99562] [ProcessSuspension]  0x108ee7138 - ProcessAssertion() PID 9045 Unable to acquire assertion for process with PID 9045
2019-11-15 18:27:09.610894-0500 MyApp[9045:99269] [ProcessSuspension] 0x108ee7138 - ProcessAssertion::processAssertionWasInvalidated()

I've tried adding the "Audio, AirPlay, and Picture in Picture" and "Background processing" flags in the Background Modes tab of xcode, but they had no effect. Other things to note: it plays audio in the simulator even though it still throws the error, but fails to play on an actual device. Also, audio does play correctly using AudioBuffer's, it's just Audio elements that are affected. Unfortunately, I can't use AudioBuffers for my soundtrack because they're only designed for short sounds, and take way too long to load for full length songs.

I've filed this as a webkit bug: https://bugs.webkit.org/show_bug.cgi?id=204261

Has anyone been able to get html audio working on iOS 13, or know any workarounds?

like image 448
frodo2975 Avatar asked Nov 16 '19 03:11

frodo2975


1 Answers

Same problem, use WKWebView and audio in background stops after 30 seconds. Ticking "Audio, AirPlay, and Picture in Picture" and "Background processing" flags in the Background Modes tab of X-Code, had no effect. In iOS 12 everything worked correctly, I do not understand that is a problem of the new iOS 13 system or a new Apple company policy. Is nothing specified or changed in their documentation about IOS 13 and audio in background (https://developer.apple.com/documentation/avfoundation/media_assets_playback_and_editing/creating_a_basic_video_player_ios_and_tvos/enabling_background_audio). At my question via Apple Developer Support I still haven't answered. ...if anyone can answer us about this problem or help us. Thank you in advance.

like image 64
Vitalie Andries Avatar answered Oct 19 '22 18:10

Vitalie Andries