Skip to content

Unity crashing on Android and freezing on iOS on second mount #191

Description

@adeiji

Description:

When mounting Unity for the first time, everything works as expected. However, on the second mount, on Android, the app crashes, and on iOS, Unity freezes. It shows the initial loading screen, but stays there without the loading bar moving.

This was not an issue until upgrading RN from 0.79 to 0.85.3 due to the new Fabric architecture change in 0.82. We have already updated to react-native-unity 1.1.1, which addresses the Fabric architecture changes; however, we are now seeing the issue mentioned above.

Repro Steps:

  • Mount Unity
  • Unmount Unity
  • Mount Unity again in the same session

What we've tried:

  • Remove unloadUnity from componentWillUnmount. Don't shut down the Unity engine when UnityView unmounts and reattach on next mount
  • Android addUnityViewToGroup: defer resume() via group.post(...) so it runs after attach
  • Android: after parking the frame off-screen, call windowFocusChanged(true) + resume() to keep the engine's main loop running while hidden. Otherwise, it auto-pauses on focus loss and stops processing messages sent to it on the next mount.

Additional Information:
The Android crash occurs with the stock library. With the workarounds above applied, the crash is gone, but the second mount just shows a white screen (Android) / frozen loading (iOS), and there is nothing in the logs indicating a failure.

The fix from #180 did not work for us.

Environment:

  • @azesmway/react-native-unity 1.1.1
  • React Native 0.85.3
  • Unity 6 (6000.3.13f1)
  • Android Emulator (Pixel 9a - Android 16.0)
  • iOS - Actual device iPhone 14 Pro Max (iOS Version 26.5.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions