The next talk at Unite 2024 worth mentioning was "Best Practices for Reducing ANRs on Android"
Highlights:
- The ANR timer may vary from vendor to vendor. The default is 5 seconds, while some Samsung devices have 10 seconds.
- ANR rate affects app discoverability.
- The main thread and Unity thread are two separate threads. Thread.Sleep() blocks the main thread, but not the Unity one, so animations can still run in the background.
- Unity published a test game to the store to track ANRs. An update to the 2021 version had the biggest impact, reducing the ANR rate from 3.5% to 0.4%. If you're still experiencing issues on older versions, consider updating. We saw a similar effect with a significant reduction after updating for our game, though our old rate wasn't that bad.
- They also broke down top ANRs. TL;DR:
- NativePollOnce: Can be ignored.
- PerformPause: Unity Android player syncs with the engine for more than 4 seconds.
- NativeUnitySendMessage: Too much workload on resume triggered from native callbacks.
- For debugging, use Android Strict Mode to identify performance issues and long I/O on the main thread.
- Check the ANR playbook on the Android Developers Portal.
- Update to Unity 6 or 2022.3.10 to reduce the ANR rate even further by 20-40%.
- Unity 6 can embed debug symbols into the app bundle to simplify the uploading process.
- Unity 6 has GameActivity, which supports better threading.
I am also adding a few slides from that talk that I find interesting and that speak for themselves
Post #2436
816
- 🔥 10
- 👍 3