Since a few months the Android Build of my game occasionally freezes.
I’m looking for ideas what might be the cause and help to investigate it further.
I’m considering submitting a bug report, but feel like I first need to make it better reproducible.
How it looks like:
Sounds keep playing, but everything else no longer updates i.e. the last frame stays and inputs are ignored.
I once had the DisplayStats open (the Unity Overlay that opens when you double tap with three fingers) and even those were frozen and unresponsive.
What triggers it:
This never happened in the years before, but now it randomly happens after some time of playing, widely distributed between 1 and 30 Minutes. So far I could not see any connection to anything that happens in the game. The freeze occurred when not doing anything, when playing constantly, when in the menu, when in the start screen, … and nothing specific was happening when it froze.
Investigation Results:
- Android Logcat still works and logs a
MotionEvent
every time I touch the screen, so something is still running. No errors or warnings show up (except those that seem to be normal during startup). - The app does not crash and I can still connect it to Logcat and even attach a debugger.
- When I have a debugger attached (since before or after the freeze) and press the Pause button, it so far always stopped at the same point within the URP ShadowUtils script. Usually this button pauses at some more or less random point wherever the update loop just happens to be. Pressing Continue and Pause again stays at that line. Pressing Step Into or Step Over crashes the app. So I guess the game is stuck there when the freeze occurs.
- The exact location is
com.unity.render-pipelines.universal(v17.0.3)/Runtime/ShadowUtils.cs
L. 135. In theExtractDirectionalLightMatrix
method, callingcullResults.ComputeDirectionalShadowMatricesAndCullingPrimitives
. Here is the Call Stack at that freeze location:
System Info:
OnePlus 10Pro, running Android 14
Unity 6000.0.7
My theory:
The execution is stuck in some kind of infinite loop within the ComputeDirectionalShadowMatricesAndCullingPrimitives
call (I cannot look inside that because its Unity internal injected code). This blocks the entire Main thread and everything that runs on it is “paused”. Other threads are not affected, which is why sounds and logcat are still working.
But I have absolutely no idea what could cause the call to run infinitely.