Chez Hung Chez Hung - 1 month ago 43
iOS Question

YouTube embedded player crashed with gpus_ReturnNotPermittedKillClient on iOS 8

I made an iOS app with UIWebView which loads YouTube iFrame player.
Everything went well and it can even keep playing video on background with only one problem.

This problem only happens since this month, and it happens not only on the latest update (iOS 8.3) but also on iOS 8.1, so I figure that it has something to do with some recent modification on the YouTube iFrame API.

On iOS 8 (only iOS 8 on the device, not any iOS before 8, and not even on the emulator,) when I put the app to background (e.g. go to home screen, lock the device,) the video plays normally, but once the video is finished and the app tries to load the next video on the app's playlist, the app crashes (actually it seems like iOS forces terminating it.)

There is an EXC_BAD_ACCESS on the WebThread with

libGPUSupportMercury.dylib gpus_ReturnNotPermittedKillClient


and the relevent call stack in the crash log is as below:

Thread 6 name: WebThread
Thread 6 Crashed:
0 libGPUSupportMercury.dylib 0x000000018b829f90 gpus_ReturnNotPermittedKillClient + 12
1 libGPUSupportMercury.dylib 0x000000018b82af3c gpusSubmitDataBuffers + 168
2 WebCore 0x0000000191620820 WebCore::GraphicsContext3D::reshape(int, int) + 528
3 WebCore 0x0000000191e93ce0 WebCore::WebGLRenderingContext::initializeNewContext() + 1136
4 WebCore 0x0000000191e93594 WebCore::WebGLRenderingContext::WebGLRenderingContext(WebCore::HTMLCanvasElement*, WTF::PassRefPtr<WebCore::GraphicsContext3D>, WebCore::GraphicsContext3D::Attributes) + 600
5 WebCore 0x0000000191e92c54 WebCore::WebGLRenderingContext::create(WebCore::HTMLCanvasElement*, WebCore::WebGLContextAttributes*) + 1144
6 WebCore 0x000000019132f6ec WebCore::HTMLCanvasElement::getContext(WTF::String const&, WebCore::CanvasContextAttributes*) + 312


simply put, in my understanding, when I call YTPlayer.loadVideoById(...) YouTube API loads the video and tries to create a new WebGL rendering context, which iOS does not allow (GL rendering related instructions during background mode is not allowed,) so it terminates the app.

I've been googling and scratching my head for a whole week to deal with this but without any luck, does anyone has any idea how to deal with it?

Thank you so much for any suggestion and any help!!!

Answer

OK, I still don't have a working solution for this problem but I just figured out a work around.

It seems like YouTube iFrame player does not create WebGL rendering context as long as you don't call YTPlayer.loadVideoById (or cueVideoById, loadVideoByUrl, cueVideoByUrl, loadPlaylist, cuePlaylist.) So I just load all the video on my playlist with loadPlaylist whenever the playlist is changed.

With this work around, my app doesn't crash anymore. It's good but I still wonder if anyone has a real solution for this, please let me know and it's very much appreciated!!!

Comments