- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I upgraded from XDK 2893 to 3240, now IOS 8 Phaser games will crash, or reload the splash screen when opening the app more than once. This did not happen with IOS 7, or IOS 8 ipa generated from XDK 2893. I can't find other XDK versions to test. This is also repro using the App Preview.
Repro:Create a basic Phaser game using the XDK template, or have something super simple - you only need the canvas (see below)
1 for App Preview: Fetch Wifi Project > choose your project. Once loaded, click on the home button to exit the app. Double tap on an empty space, then click on the App Preview. Result = It will be back at the Fetch Wifi Project menu. If you don't double tap and re-launch App Preview you will return to your game.
More severe when using an installed app.
2. To repro using an ipa: You can use CLI 5.1.1 or 5.4.1 - with IOS Target Version 8.0
Build, download and install the .ipa, then launch the app. Hit the home button to exit the app. Double-click on an empty space, then relaunch the app (or just relaunch the app). The splash screen will start again, or the app will crash. Repeat as necessary. It should simply return to the game, as it used to.
This is repro on IOS 8 and IOS 9 devices
Simple html below
<!DOCTYPE html>
<html>
<head>
<title>Game</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">
<style>
body {
padding: 0;
margin: 0;
overflow: hidden;
}
</style>
</script>
<script src="phaser.min.js"></script>
<script type="text/javascript">
var game = new Phaser.Game(320, 480, Phaser.AUTO, '', { preload: preload, create: create});
function preload() {
}
function create() {
};
</script>
</head>
<body>
</body>
</html>
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Jason B. I was able to build the Phaser template with XDK 3240, cli 5.4.1 and ran on ioS9.3/iphone6, I see no crash. send me the project zip as a private message, I can try that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rakshith Krishnappa (Intel) wrote:
@Jason B. I was able to build the Phaser template with XDK 3240, cli 5.4.1 and ran on ioS9.3/iphone6, I see no crash. send me the project zip as a private message, I can try that.
Hi Rakshith, thanks for your reply. Using IOS 8 pretty much on any device, re-entering the app will restart the splash screen, instead of returning to the game. Including on App Preview, where it returns to the wifi menu instead. Did you manage to test on a device running IOS 8, as that crashes for me. Or test using App Preview - on any IOS? As I would suspect that the same error is causes the splash screen restart, and that the crash is just a more severe example of the same issue.
I will prepare a zip anyway, but I expect that only on IOS 8 will the crash be more frequent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One of our engineer debugged the issue, the issue seem to be in the phaser code:
In the Phaser template, Add this workaround in app.js, and app.js must be included after cordova.js:
//--BEGIN-- WORKAROUND function onPause() { if(!game.paused) { game.gamePaused(); } } function onResume() { setTimeout(function() { if(game.paused) { game.gameResumed(); } }, 0); } document.addEventListener('pause', onPause, false); document.addEventListener('resume', onResume, false); //--END--
So the full app.js for the xdk phaser template will look like this:
(function () { /* globals Phaser:false, BasicGame: false */ // Create your Phaser game and inject it into the game div. // We did it in a window.onload event, but you can do it anywhere (requireJS load, anonymous function, jQuery dom ready, - whatever floats your boat) // We're using a game size of 480 x 640 here, but you can use whatever you feel makes sense for your game of course. var game = new Phaser.Game(480, 640, Phaser.AUTO, 'game'); // Add the States your game has. // You don't have to do this in the html, it could be done in your Game state too, but for simplicity I'll keep it here. game.state.add('Game', BasicGame.Game); // Now start the Game state. game.state.start('Game'); //--BEGIN-- WORKAROUND function onPause() { if(!game.paused) { game.gamePaused(); } } function onResume() { setTimeout(function() { if(game.paused) { game.gameResumed(); } }, 0); } document.addEventListener('pause', onPause, false); document.addEventListener('resume', onResume, false); //--END-- })();
This workaround will fix the crash when phaser game enters foreground.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very much for getting to the bottom of this, and for your workaround.
I have just tested it, and so far so good! :-)
Thanks again, it is very much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I thought to test without the workaround as well, and oddly now it does not crash, nor does it restart the splash screen.
I wonder if all of this might have been related to https://software.intel.com/en-us/forums/intel-xdk/topic/629281
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah ha - just to let you know. If I don't have the workaround, the app can crash after locking and unlocking the device.
Good to know about the workaround ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually I was wrong, the workaround still crashes hard on IOS 8 devices. IOS 7 no problems, IOS 9, crash is more rare. Changing Phaser versions does not help, however changing the game type to CANVAS var game = new Phaser.Game(480, 640, Phaser.CANVAS, 'game'); it does not crash. Sadly though CANVAS is not always the preferred option for all games.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My last post was user error.
I had forgotten to ensure to put <script src="cordova.js"></script> before the workaround.
Sorry for the noise
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page