Apple don't allow background app execute commands on graphics
If I build with cordova, run on iPhone5S(8.1.2), then press HOME. App will crash with error .
libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient:
0x18f952180 <+0>: orr x8, xzr, #0x1
0x18f952184 <+4>: movz w9, #0xdead, lsl #16
0x18f952188 <+8>: movk w9, #0xbeef
-> 0x18f95218c <+12>: str w9, [x8]
0x18f952190 <+16>: ret
This issue is only appear on iOS with WebGL. Canvas work fine.
For now, I resolve this issue by set game.lockRender = true in cordova pause event.
I think we should prevent any render action in <internal> game.gamePaused(event)
Hmm this is a Cordova specific issue. I'm reluctant to add hacks into the core specific for this case. However it's well worth adding into the docs, so I'll do that now.
Actually what the heck, it's in there.
A note for others that might still be running into this crash with Cordova+Phaser...
The provided fix works, but is not automatically invoked when the app goes to the background.
The app developer needs to add an event listener that pauses the game when the app is sent to the background (and another to unpause it when it returns to the foreground) so that the fix will be invoked to prevent the crash.
Something like:
//pause the game when the app pauses
function onPause() {
if(!game.paused) {
game.gamePaused();
}
}
function onResume() {
//ios quirk: resume handler needs to be in setTimeout
setTimeout(function() {
if(game.paused) {
game.gameResumed();
}
}, 0);
}
document.addEventListener('pause', onPause, false);
document.addEventListener('resume', onResume, false);
Thank you @tony-- that solution worked for me!
Most helpful comment
A note for others that might still be running into this crash with Cordova+Phaser...
The provided fix works, but is not automatically invoked when the app goes to the background.
The app developer needs to add an event listener that pauses the game when the app is sent to the background (and another to unpause it when it returns to the foreground) so that the fix will be invoked to prevent the crash.
Something like: