Web Audio API with IOS and Phonegap causes crash on resume from background

吃可爱长大的小学妹 提交于 2020-01-05 07:33:11

问题


This might be a shot in the dark but here it goes:

I have an HTML5 game running great on iPhone using Phonegap.

I added audio using Web Audio API (which as of ios 6 is supported). This too works well, except when I exit the app then re-open the app (from being "Backgrounded").

Upon resuming, the app now pauses then crashes.

Some other info

  • I first noticed this after using the howler.js framework for audio. I removed this and tried the most basic barebones example of Web Audio API and the problem still persists.

  • I'm testing this with Phonegap 2.5.0 on iOS 6.1.2 and an iPhone5.

  • Can't debug through xcode as for some reason when connected to xcode, the app will still pause upon resume but will not crash. (so only crashes when run from the icon on the home screen)

  • I think I pinned it down to the ctx.createBufferSource() call.


If anyone else has experienced the same or even has a solution, I'd love to hear!

Thanks
j.


回答1:


Have you tried allowing your app to play audio in the background? It would be a nice experiment to determine whether the Audio API you are using is handling your app going to the background, and resuming from it. In the lower level Audio API's there is several things you need to do properly in order to avoid crashes.

Anyhow, back to the experiment. In order to allow your app to play audio in the background, modify your .plist file by adding "App plays audio" item to "Required background modes" dictionary. And then rebuild, and retest.

If that does not help you understand the issue better, then you will have to generate a crash backtrace with one of the popular methods.




回答2:


Updated to new version of xcode and the problem is gone.

I'm fairly confident this is not a phone gap issue but a bug in xcode/ios.



来源:https://stackoverflow.com/questions/15192468/web-audio-api-with-ios-and-phonegap-causes-crash-on-resume-from-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!