[Repo] Android IL2CPP crash when app is restored from background and a scene is loaded

Hey there

We are using IL2CPP for our Android game. We can trigger a crash on our Galaxy Edge if we navigate from the game menu to the game, put the application in to the background by pressing the home button, openning our application back up and attempting to navigate back to the game menu.

The backtrace is as follows:

12-16 17:08:20.981: I/DEBUG(2943): backtrace:
12-16 17:08:20.981: I/DEBUG(2943):     #00 pc 0185cbac  /data/app/com.our.app-2/lib/arm/libil2cpp.so (GC_mark_from+1952)
12-16 17:08:20.981: I/DEBUG(2943):     #01 pc 01854114  /data/app/com.our.app-2/lib/arm/libil2cpp.so (GC_mark_some+980)
12-16 17:08:20.981: I/DEBUG(2943):     #02 pc 01853100  /data/app/com.our.app-2/lib/arm/libil2cpp.so (GC_stopped_mark+284)
12-16 17:08:20.981: I/DEBUG(2943):     #03 pc 01852a5c  /data/app/com.our.app-2/lib/arm/libil2cpp.so (GC_try_to_collect_inner+408)
12-16 17:08:20.981: I/DEBUG(2943):     #04 pc 01855bc8  /data/app/com.our.app-2/lib/arm/libil2cpp.so (GC_try_to_collect_general+300)
12-16 17:08:20.981: I/DEBUG(2943):     #05 pc 01855cb4  /data/app/com.our.app-2/lib/arm/libil2cpp.so (GC_gcollect+12)
12-16 17:08:20.981: I/DEBUG(2943):     #06 pc 00389f70  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #07 pc 003da61c  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #08 pc 003da3fc  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #09 pc 003d7ffc  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #10 pc 003d856c  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #11 pc 00383284  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #12 pc 004c9914  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #13 pc 004ceb38  /data/app/com.our.app-2/lib/arm/libunity.so
12-16 17:08:20.981: I/DEBUG(2943):     #14 pc 002f2ebf  /data/dalvik-cache/arm/data@app@com.our.app-2@base.apk@classes.dex (int com.unity3d.player.UnityPlayer.nativeActivityIndicatorStyle()+82)

This crash happens almost 100% of the time on our Galaxy Edge. It happens fairly frequently on our HTX One M8, and infrequently on our Nexus 6P, where I have to repeat the process a couple of times to trigger the crash.

When it does happen, each and every device that crashes produces the same backtrace.

I have not been able to reproduce this issue in an empty project. I do not know what conditions lead to the crash. But it is reproducable easily the Galaxy Edge in our project and I would like to get our project into the hands of a Unity dev to look at. The project is rather large so I can share a build via GDrive or something.

I have been trying to put together a repo all week and this is as close as I’ve gotten to nailing down the source of the problem.

There are no clear errors, the backtraces do not hint at anything specfic. I can’t go any further with this. The backtrace suggests something went wrong when garbage collecting. I have no control over this at all.

Please help

Hi

Thank you for putting time into creating a repro. I believe we already have a bug report and a repro case for what you are describing. I will poke you once we have fix so you can test your project.

Thanks for responding Bitter! We are running Unity Pro at our company, so I am happy to jump on to the next beta or grab the latest patch as soon as it is out to see if it is fixed. This is holding off our entire Android release and the boss man is not happy :wink:

I was going to force the game to quit on OnApplicationPause so that the user gets a ‘fresh start’ every time they return to the app - annoying, but better than an ‘random’ crash when the game is loading. But it turned out that it wasn’t an option since our game ‘pauses’ when we trigger an IAP dialogue or trigger a full screen advertisement video. Obviously we can’t quit the app when the user triggers these dialogues but if we don’t quit the game the user will experience a crash at the next load screen.

Anyway, fingers crossed that this fix’ll do the trick! :slight_smile: