Cordova-plugin-ionic-webview: iOS 13 background audio not working

Created on 8 Oct 2019  路  22Comments  路  Source: ionic-team/cordova-plugin-ionic-webview

We have a radio app and after the update to iOS 13 the audio will only play for like a minute before stopping with this console message " [ProcessSuspension] Background task expired while holding WebKit ProcessAssertion (isMainThread? 1)." I have Background mode audio selected in xcode. It was working before iOS 13.

apple bug

Most helpful comment

@tkondej Thanks so much for sharing. You finally lead to the solution.
@DiegoZurita Thanks for your PR. It works and after several frustrating days my audio is running for a couple minutes now and I am very, very happy not to throw that f*ing iPhone against the wall.
You both made my day! Thanks!

All 22 comments

Same issue.
Did you resolve this problem?

Unfortunately no.

same

same

Any news about this issue?

I am having this issue as well! What plugin is everyone using for this? It was working with: nl.kingsquare.cordova.background-audio
Still broken when I switched to cordova-plugin-backgroundaudio
(using Phonegap Build)

In my opinion the problem comes from Apple.
I created a project with a component WKWebView, with just an audio tag, and when the project goes into background, after 20 seconds the sound is cut.
audio.swift.txt

In my opinion the problem comes from Apple.
I created a project with a component WKWebView, with just an audio tag, and when the project goes into background, after 20 seconds the sound is cut.
audio.swift.txt

I think it's a bug. I solve this problem with cordova-media-plugin and background-fetch.

I wrote code to run the background with swift, but wkwebview stops working in the background again

Can you give us more details on how you solved it? I'm stucked for several days now.

My solution was to use cordova-plugin-background-mode plugin, with backgroundMode enabled audio continues to work in background too.

Unfortunately not in my case. It stops the audio after a second. Are you using a forked version?

@wunschradio yes, cordova-plugin-background-mode-appstronauts

@tkondej Interesting, thank you for this solution... Although it worries me that that plugin forces background execution and disables iOS's ability to shut down an app...

Store Compliance
Infinite background tasks are not officially supported on most mobile operating systems and thus not compliant with public store vendors. Successful submission isn't guaranteed.

Use the plugin by your own risk!

@tkondej did you have any issues submitting your app to the App Store?

I just opened a PR in cordova-plugin-background-mode and solve my problem of not playing audio in background.

As mentioned in the PR's message, was heavily inspired in cordova-plugin-background-mode-appstronauts mentioned by @tkondej

@tkondej Thanks so much for sharing. You finally lead to the solution.
@DiegoZurita Thanks for your PR. It works and after several frustrating days my audio is running for a couple minutes now and I am very, very happy not to throw that f*ing iPhone against the wall.
You both made my day! Thanks!

@tkondej did you have any issues submitting your app to the App Store?

@benmcmaster No issues with submitting the app the store, but keep in mind te app uses audio features (it's basically radio based app), I'm not sure about background mode plugin App Store compliance with other apps. I'm glad it helped

I used the streaming media plugin to temporarily solve, by its native audio, IOS keeps playing ...

I will try this mentioned by @tkondej

I've reported it to Apple, you should do the same. This can't be fixed on the plugin.

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

Acabei de abrir um PR no modo cordova-plugin-background-mode e resolvo meu problema de n茫o reproduzir 谩udio em segundo plano.

Como mencionado na mensagem do PR, foi fortemente inspirado em cordova-plugin-background-mode-appstronauts mencionados por @tkondej

as you did? still unable to install cordova-plugin-background-mode-appstronauts, cordova-plugin-background-mode plugin called the audio but crashed

I see the bug report to Apple, but am still uncertain of the status of this issue. @tkondej, are you saying that you have a currently working solution that was approved by Apple for use in a radio-player app? Ie, is your solution currently working, while waiting for Apple to resolve the bug?

@benmcmaster nl.kingsquare.cordova.background-audio has been deprecated for a few years.. no longer maintained. Unfortunately the dev cash went elsewhere (better apps) a few years ago.

The root cause is that a third party can not support true background without partnering. The partnering/dev cost is above any feasible customer expectation.

@jcesarmobile the suggestion by @DiegoZurita has resolved the issue on iOS 13 for our app. Are you saying that the issue is still with a bug in webkit and this fix is more of a hack? Added line
[session setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:NULL];

Was this page helpful?
0 / 5 - 0 ratings