Everyday Unity – Telegram
Everyday Unity
1.11K subscribers
157 photos
59 videos
42 files
2.36K links
A game developer and tech lead in a top grossing company posting Unity, programming, and gamedev related stuff that I find interesting
Website: https://gamedev.center

Most used tags are:
#performance
#shader
#interview

Author: @alexmtr
Download Telegram
🔥4
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
🔥10👍3
🔥14👍1
The final talk of the conference, and the one I was most excited about: "Performance Tips & Tricks from a Unity Consultant."

I wanted to attend this session because one of my favorite talks ever at Unite was on the same topic by Ian Dundore. I learned a lot from it. I even wrote a post about all the tips from that session, which has helped me many times: https://news.1rj.ru/str/everydayUnity/1623

While I didn't learn a lot of new things this time, the talk was still very good overall.

Highlights:
- Use native profilers such as SuperLuminal. The Unity profiler shows a very limited call stack, and in deep profile mode, too much performance is consumed by capturing the call stack. Results become increasingly skewed the deeper the stack is.
- Prewarm your shaders and use shader variant collections (SVC). However, SVC is not supported by all graphics APIs.
- More improvements for graphics and shaders are coming in Unity 6, so they encourage updating.
- Use the SRP batcher and ensure your shaders are SRP batcher-compatible.
- Use instancing for more than 100 identical meshes. This is interesting because a few years ago it was suggested that instancing should be used from 1024 meshes. I suppose this should be tested in Unity 6 with specific use cases to confirm.
- I also asked during the Q&A which low-level API he recommends, and he suggested using BRG (I have written a blog post about this as well a long time ago when BRG was just released https://news.1rj.ru/str/everydayUnity/1716).
- Avoid quad overdraw. I shared a great post about this some time ago: https://news.1rj.ru/str/everydayUnity/1634.
- Basic shader advice: use half/int16 where possible, reduce the number of variables, and minimize texture samples.
- One particularly interesting point was about memory allocations: Boehm allocates memory in 4KB blocks, and a block isn't freed until all buckets within it are free. Because of this, you should allocate long-term memory together so it’s placed in the same block.
- Avoid multiple cameras, as each adds significant overhead. Use render features instead when possible.
- Mix UI and 3D with camera space UI.
- Use the resident drawer in Unity 6 for repeating meshes where draw calls are a bottleneck.
- Avoid duplicates in Addressables. Use the Addressables Analyzer, Build Reporter, and Memory Profiler's potential duplicates tool to find duplicated assets.
- Untracked memory in the Memory Profiler might not be an issue; native profilers can help determine that.
👍5🔥3
Controlling Unity's Rendering Order - Why and How

A detailed post packed with references to other posts, documentation, and even source code. Digging into source code is a crucial skill for software engineers.

I especially love the conclusion—something I’ve discussed extensively in my posts from Unite:
In closing, I’ll repeat that if your interest in this topic is to improve performance, make sure to profile before you decide that changing the rendering order is the right optimization to implement!
https://medium.com/toca-boca-tech-blog/controlling-unitys-rendering-order-why-and-how-3c2bb1da8e78

#rendering #sorting
🔥6👍2
Optimizing Texture Memory (VRAM) & Size

TL;DR
MEASURE TEXTURE VRAM USAGE AND DOWNLOAD SIZE using lox9973's Assetbundle Stat tool and Thry's VRAM estimator.
Reduce Resolution in the texture import settings! Not every texture needs to be 2k or 4k.
Don't disable mipmaps - Your materials will look and run better with them on!
Crunch doesn't change VRAM usage but can reduce download size. Not a magic bullet!
For Normal Maps, Use RG Compressed BC5 (From Platform overrides menu1). Normal Quality (DXT5nm) and High Quality (BC7) use the same VRAM but look worse.
For textures with Alpha, Use High Quality (BC7). Normal Quality (DXT5) uses the same VRAM but looks worse.
Don't use JPG (or other lossy formats) to store your source textures! Lower quality, with no benefit to VRAM/Download Size


https://www.poiyomi.com/blog/2022-10-17-texture-optimization

#optimization #vram
🔥7👍2
Connecting the DOTS: Let’s make a game with Entities | Unite 2024

If you still haven't tried Entities, this talk gives you a good overview of what it is, how to work with it, and what drawbacks it has.

https://www.youtube.com/watch?v=gqJlQJn0N2g

Repo: https://github.com/Unity-Technologies/Unite24ConnectingTheDOTS

The speaker, Daniel, is also a regular guest on the Hot Path Show, which I recommend watching if you already have any experience with Entities and would like to dive into the details.

#dots #entities
👍8🔥3