Does this happen to anyone else? App crashes when pressing home button before first scene loads.

I’m not sure if this issue has always been present in my app. But I noticed that if I launch my game, then suspend it somehow while Default.png is still showing (by either pressing home, switching to another app, or turning off the screen) the background music will eventually start to play even though the app is not in the foreground. If I go back to the app, it’s still stuck on the Default.png image and will not go to the first scene. Eventually the OS kills it for being unresponsive.

I’m using the latest public build 2014.2511 on Android.

I tried looking in logcat for any errors but this was the only relevant thing I could find:

W ActivityManager: Activity stop timeout for ActivityRecord{21049b18 com.test.game/com.ansca.corona.CoronaActivity} I ActivityManager: Activity reported stop, but no longer stopping: ActivityRecord{21049b18 com.test.game/com.ansca.corona.CoronaActivity} W ActivityManager: Activity idle timeout for ActivityRecord{21049b18 com.test.game/com.ansca.corona.CoronaActivity}

Bumping this

Never seen this.  Are you loading a lot of resources or building a complex scene in the beginning?  

If so, you may want to use a co-routine based, resource-loading loop to let the app tick, else iOS may kill it.  (home press or no home press).

Well, I do all the initilization stuff in my main.lua for things like ad plugins, music, loading and verifying game data stored on the device, initialitizing the store for in app purchases, etc. I’d say it takes about 2-3 seconds before my main menu scene gets displayed. It takes even longer on the first install of the app.

Do you have links to any tutorials?

I wonder if maybe my main.lua should do nothing except immediately point to a scene specifically made for the initial loading stuff.

UPDATE: Moving all the initial loading into a separate scene did nothing to help. In fact, even though my main.lua is pretty sparse now (just setting a couple global variables) it still takes about second until the new loading scene is displayed. And if I press the home key during that 1 second I still get the crash.

Also, once it goes to the loading scene, there’s this awkward period where the music starts playing before the background image is displayed, even though the background is called in scene:create() and the music doesn’t get called until the “did” phase of scene:show().

I wonder if it has to do with all the plugins for the different ad networks, google in app billing, facebook, openSSL, etc.

I was able to narrow it down. Specifically, it is store.init which is causing a crash if you suspend the app right when it is called. I made a small sample app to showcase the issue if anybody is interested.

@RoamingGamer,

thanks for the suggestion about coroutines. I tried to implement one to load my resources but unfortunately it failed miserably. I was getting all sorts of errors, and for some reason, when a song that got loaded using the coroutine would loop, the app would crash saying that I couldn’t resume a dead coroutine (even though I made no more references to it??)…strange.

So instead, I made a stateful timer function that essentially acts as a coroutine. I’m actually kind of happy with how it turned out. Doing it this way even let me implement a progress bar that will update between loading of resources.

However! This does not fix the issue with the crashing. Using the progress bar, I can see when store.init is called because it hangs for a little there, and if I press the home button at that moment it will still crash.

Bumping this

Never seen this.  Are you loading a lot of resources or building a complex scene in the beginning?  

If so, you may want to use a co-routine based, resource-loading loop to let the app tick, else iOS may kill it.  (home press or no home press).

Well, I do all the initilization stuff in my main.lua for things like ad plugins, music, loading and verifying game data stored on the device, initialitizing the store for in app purchases, etc. I’d say it takes about 2-3 seconds before my main menu scene gets displayed. It takes even longer on the first install of the app.

Do you have links to any tutorials?

I wonder if maybe my main.lua should do nothing except immediately point to a scene specifically made for the initial loading stuff.

UPDATE: Moving all the initial loading into a separate scene did nothing to help. In fact, even though my main.lua is pretty sparse now (just setting a couple global variables) it still takes about second until the new loading scene is displayed. And if I press the home key during that 1 second I still get the crash.

Also, once it goes to the loading scene, there’s this awkward period where the music starts playing before the background image is displayed, even though the background is called in scene:create() and the music doesn’t get called until the “did” phase of scene:show().

I wonder if it has to do with all the plugins for the different ad networks, google in app billing, facebook, openSSL, etc.

I was able to narrow it down. Specifically, it is store.init which is causing a crash if you suspend the app right when it is called. I made a small sample app to showcase the issue if anybody is interested.

@RoamingGamer,

thanks for the suggestion about coroutines. I tried to implement one to load my resources but unfortunately it failed miserably. I was getting all sorts of errors, and for some reason, when a song that got loaded using the coroutine would loop, the app would crash saying that I couldn’t resume a dead coroutine (even though I made no more references to it??)…strange.

So instead, I made a stateful timer function that essentially acts as a coroutine. I’m actually kind of happy with how it turned out. Doing it this way even let me implement a progress bar that will update between loading of resources.

However! This does not fix the issue with the crashing. Using the progress bar, I can see when store.init is called because it hangs for a little there, and if I press the home button at that moment it will still crash.