How do I profile my game?
I've noticed when I have a lot of players in my lobby and they all start spawning normcore-synced items my frame rate drops abysmally, and if it stays too long like that the lobby crashes and they get sent to a new one. It doesn't seem to be an issue of too many triangles in the scene, I'm getting this even with 50k tris in view.
5 Replies
Hi @Alix Ollivier. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To profile your game and diagnose issues like frame drops and crashes when many Normcore-synced items are spawned, you should use Normcore's network profiler in combination with Unity's built-in Profiler. Here’s how you can approach this:
1. Use the Normcore Network Profiler
Normcore provides a network profiler module that integrates with Unity’s Profiler window. This tool allows you to analyze bandwidth usage in real-time, which is crucial when many synced objects are being instantiated and updated.
How to set it up:
- Open Unity’s Profiler window (
Profile your game using Unity’s Profiler with the Normcore module to monitor bandwidth and network activity. Use prefab pooling to reduce instantiation overhead, and ensure your room server is sized appropriately for your player and object count. These steps will help you pinpoint and resolve the cause of frame drops and crashes in your multiplayer lobby. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Window > Analysis > Profiler).
- In the Profiler window, click the "Profiler Modules" dropdown.
- Select "Normcore" to see total bandwidth use, or modules like "Normcore Audio" for voice chat bandwidth.
- Run your game and observe the "Sent" and "Received" metrics per frame.
Tips:
- Increase the number of stored frames in the Profiler (e.g., to 1000+) for better analysis.
- Disable vsync in the editor to avoid framerate spikes that can skew profiler data.
- Run multiple instances of your app to profile receive bandwidth, as the server only sends data if there are multiple clients connected.
What to look for:
- Spikes in data sent/received when spawning objects.
- Sustained high bandwidth usage as more objects are synced.
- Correlation between network activity and frame rate drops.
See the full guide here
2. Optimize Prefab Instantiation
Frequent instantiation and destruction of Normcore-synced prefabs can cause performance issues, especially with many players. Instead, use prefab pooling to reuse objects and avoid costly instantiation/garbage collection cycles.
- Add a RealtimePool component to your Realtime instance.
- Preload prefabs to avoid runtime hitches.
- Use pooling callbacks (IRealtimePoolCallbacks) for custom logic when objects are reused or returned to the pool.
Learn more about prefab pooling
3. Analyze Bandwidth and Object Count
The number of networked objects and the frequency of their updates can dramatically increase bandwidth and CPU usage, especially in VR. Normcore’s network profiler can help you identify if too many objects are being synced too frequently.
- Consider reusing objects (e.g., with a pool of 50 basketballs, reuse the oldest instead of instantiating new ones).
- Focus on optimizing data sent over long periods, not just spikes during instantiation.
See code examples and optimization tips
4. Room Server Capacity
If your lobby crashes or disconnects users, you may be hitting the limits of your room server configuration. VR titles, in particular, use much more bandwidth per player. Consider increasing your room server size using the Room Server Options API, or splitting large lobbies into multiple rooms.
Room server configuration details
---
Summary:Profile your game using Unity’s Profiler with the Normcore module to monitor bandwidth and network activity. Use prefab pooling to reduce instantiation overhead, and ensure your room server is sized appropriately for your player and object count. These steps will help you pinpoint and resolve the cause of frame drops and crashes in your multiplayer lobby. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@185325614775926784> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
if your local framerate is dropping, I don't expect this is a server CPU limit fwiw
the bottleneck sounds like the device. I would expect this to be a bottleneck with prefab instantiation as that's generally pretty expensive. Use the Unity profiler to measure CPU use and if it turns out to be prefab instantiation, check out the RealtimePool class. You can use that to pool instantiation of prefabs to pay that cost ahead of time.
oh yeah, I missed the frame rate drop, a cpu profiler will show where all the load is from. The meta quest developer hub has a performance analyzer https://developers.meta.com/horizon/documentation/unity/os-cpu-gpu-levels/
in the editor you can use the profiler to show areas you can optimise https://docs.unity3d.com/Manual/profiler-cpu-introduction.html
it's probably the physics if these are all rigidbodies. You can swap to using primitives instead of mesh colliders which helps a lot
CPU and GPU levels
Describes the CPU and GPU level system on Quest devices.
They are all rigidbodies with meshes, I'll check this out tomorrow thanks!