IOS13-WkWebView: 在后台时音频停止

我有一个应用程序,它使用 WkWebView播放来自 Soundcloud 的音频,在 ios13beta6上,当应用程序不在前台时,音频就会停止, 甚至当 音频背景模式中打开时。

当开始播放时,这个断言被抛出:

Error acquiring assertion: <NSError: 0x282cf67c0; domain: RBSAssertionErrorDomain; code: 2; reason: "Required client entitlement is missing"> {
userInfo = {
RBSAssertionAttribute = <RBSLegacyAttribute: 0x1592432e0; requestedReason: MediaPlayback; reason: MediaPlayback; flags: PreventTaskSuspend | PreventTaskThrottleDown | WantsForegroundResourcePriority>;
}

进入后台状态后,抛出以下断言并挂起音频:

Can't end BackgroundTask: no background task exists with identifier 13 (0xd), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
[ProcessSuspension] Background task expired while holding WebKit ProcessAssertion (isMainThread? 1).

在 iOS12系统中,音频在背景中正常播放,但这种情况并没有发生。

6576 次浏览

我猜你用的是电容器。

I'm running into the same issue as you and it looks like the last error about 'no background task exists' has something to do with Capacitor's BackgroundTask Plugin, wether you're using it or not (BackgroundTask.swift)

It's clear something changed between iOS 12 and iOS 13, but so far haven't figured out how to define the required entitlements for background audio.

EDIT: It only happens when using HTML5 Audio.