Android Oculus Quest IL2CPP build crashes, while editor and Mono works fine

Hello, we have run into an issue with PUN2. We have an application for Oculus Quest (2) implementing a multiplayer via PUN2. Unity applications at Oculus Store for Oculus Quest platform are required to use IL2CPP instead of Mono for reasons beyond this forum post.

The crash scenario is pretty simple and copies tutorials. We create a room, join it, start game and change scene via Photon. The Awake and Start methods of Monobehaviours in the scene get called, but before we can see a first frame in the new scene the app crashes. The app also crashes if I try to change to an empty scene however everything works just fine in editor or while using Mono backend.

I tried on both Quest (Android 7) and Quest 2 (Android 10) HMDs. I tried to upgrade Unity to latest 2020 LTS version (2020.3.20f1). I tried the latest PUN (2.38) and I also tried the fix for IL2CPP on UWP from PUN Known issues.

This is the crash backtrace from logcat, which I know looks like a Unity bug, but happens only when using PUN2 with IL2CPP. Any help would be much appreciated. Many thanks!

FATAL EXCEPTION: UnityMain
Process: com.sensearena.sensearena, PID: 4686
java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version '2020.3.20f1 (41c4e627c95f)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
Build fingerprint: 'oculus/hollywood/hollywood:10/QQ3A.200805.001/19130100199900000:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2021-10-14 13:21:54+0200
pid: 4686, tid: 4711, name: UnityMain  >>> com.sensearena.sensearena <<<
uid: 10097
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  0000007b3c7d09f8  x1  0000007b342866b8  x2  0000007b8e52b3a8  x3  0000000000000001
    x4  0000000000000000  x5  00000000ffffffff  x6  00000000ffffffff  x7  000000000043f99a
    x8  0000000000000000  x9  0000000000607978  x10 0000007b3085a000  x11 0000000000000000
    x12 0000000000000001  x13 000000008f7c7200  x14 0000000000008af2  x15 0000ad3672a98ee0
    x16 0000007b3c99c458  x17 0000007c27b4efec  x18 0000007b342622e0  x19 0000007b3c7d09f8
    x20 0000007a5b89e580  x21 0000007a5bb9caf8  x22 0000007b3ddfa9c0  x23 0000007b3ddfa000
    x24 0000007b3ddfa000  x25 0000007b3ddfa000  x26 00000000ba2e8ba3  x27 0000007a5cc4e240
    x28 0000007b34286ee0  x29 0000007b34286670
    sp  0000007b34286660  lr  0000007b3b18374c  pc  0000007b3b183824
    
backtrace:
libil2cpp.0x6ef7824(Native Method)
libil2cpp.0x6ef7748(Native Method)
libil2cpp.0x6ef7bd8(Native Method)
libunity.GarbageCollectSharedAssets(bool, bool)(GarbageCollectSharedAssets:680)
libunity.UnloadUnusedAssetsOperation::IntegrateMainThread()(IntegrateMainThread:16)
libunity.PreloadManager::UpdatePreloadingSingleStep(PreloadManager::UpdatePreloadingFlags, int)(UpdatePreloadingSingleStep:276)
libunity.PreloadManager::WaitForAllAsyncOperationsToComplete()(WaitForAllAsyncOperationsToComplete:144)
libunity.PreloadManager::UpdatePreloading()(UpdatePreloading:184)
libunity.InitPlayerLoopCallbacks()::EarlyUpdateUpdatePreloadingRegistrator::Forward()(InitPlayerLoopCallbacks:64)
libunity.ExecutePlayerLoop(NativePlayerLoopSystem*)(ExecutePlayerLoop:80)
libunity.ExecutePlayerLoop(NativePlayerLoopSystem*)(ExecutePlayerLoop:168)
libunity.PlayerLoop()(PlayerLoop:400)
libunity.UnityPlayerLoop()(UnityPlayerLoop:744)
libunity.nativeRender(_JNIEnv*, _jobject*)(nativeRender:72)
libart.art_quick_alloc_array_resolved_region_tlab(art_quick_alloc_array_resolved_region_tlab:112)

Answers

  • Tobias
    Tobias admin
    edited October 2021

    I'm sorry you are running into such an issue. There are currently no known issues that match this problem. In fact, we know that some games are successfully released on Quest 2.

    Overall, this is a Unity bug, as the "promise" is that IL2CPP and Mono deliver about the same results.

    So your client does connect and run. Only when you start the game in the room and load the next scene, things fail, right?

    Did you try to load a blank scene? If the Awake and Start methods of Monobehaviours in the scene get called, this could be part of the problem.

    Does the same crash happen in a standalone build with IL2CPP?

  • Hello Tobias and thank you for replying!

    Yes, that is right. Yes I have also tried to load only an empty scene with just a cube object and a light and the app crashes as well. I haven't tried a standalone build, but I will give it a go.

    I will also try to come up with a minimum crashing example to help to identify the issue.

  • I think it makes sense to submit this to Unity as a bug (and there the minimal project is also of help). It will be interesting to know what the standalone version does.

    It could actually also be an issue related to the Oculus integration (and in those, to a specific version) but I have no first hand experience, which versions are fine and which have issues.

    On the Unity side, 2020.3.20f1 should be fine but then again, even LTS versions get the occasional issue.

  • PatrikM_SenseArena
    edited October 2021

    EDIT: The problem still persist. The workaround works randomly, in other cases the app still crashes :/

    For anybody coming here to find a workaround... At the end of the day we have found a workaround for this issue, while we are still unsure what causes the problem. The crash as the log above suggests is caused by the Unity's garbage collector running after a new scene is loaded. It might relate to a multiscene setup. We use a two scene setup + DontDestroyOnLoad. One scene with the environment is always loaded while other scenes are changing.

    We have randomly worked around this issue by manually unloading the scene before loading the new one, while one scene with the environment remains loaded all the time.

    Much more digging would be needed to extract the exact problem and make a proper Unity bug report, but it looks like the issue is rather rare anyway.

  • Thanks for the update.

    I think you evaluated the case as far as one could expect. I would definitely report this as issue to Unity and let them know something is odd. It might be a repro they could use or add importance to other reports of similar issues.

  • @PatrikM_SenseArena hi,

    I am also having the same issue. It would be really appreciated, if you could tell me how did you fix that issue.

    I have been facing this for long time and did not get any working solution for this.

  • Hi @Ravitakhi ,

    the only thing that worked for us so far was to change a sceen like this

    1) Fade players view to black so he cannot see what mess is going on and optionally provide some loading stuff

    2) Load the new scene async

    3) Unload the old scene

    4) Fade players view back from black

    While this workaround works we have not invested our time into digging into what exactly causes the issue. Anyway if you found what the problem was I would be much interested :) Hope this helps.