In my game I am using a particle system for a flamethrower. On the very first time the particle system is enabled, and only on the very first time it is enabled, the game stutters for a split second. Additionally, this only happens in the WebGL build, and does not happen when playing the game in the editor. Any ideas on why this happens and/or how to fix it? Thanks!
UPDATE - After some troubleshooting I determined that the issue is not with the particle system but rather is with some point lights that are enabled when the flamethrower is used. Any ideas on why this happens and/or how to fix it?
One clue might be that it doesn’t happen when you go back to the menu and then start a new game, or even when you refresh the page - which makes me suspect it’s loading something too big/complicated into memory (usually massive textures or sound).
I don’t have any experience with WebGL, but you can:
Check the audio import settings - usually turning on Load In Background really helps.
Check what your particle system is loading - is it using a billboard or a mesh? What textures is it using, and how big are they?
Deep Profile this in the Editor. you might not see the FPS drop, but you should still see something registering.
You can check the Memory Profiler if you want, and compare a before and after snapshots to see everything that’s being loaded.
Thank you @evyatron ! I did some troubleshooting and determined that the issue is with the point lights that are enabled with the flamethrower. I set it up so that some point lights are enabled when the flamethrower is used to provide the effect of the fire illuminating the scene. I did this because I thought enabling and disabling 3-5 point lights would be less resource intensive than using the light component on the particle system. Again, this only happens when the lights are first enabled. Any ideas on why this happens and/or how to fix it? Thanks!
When you first start up your game, run a one-time benchmark that enables/disables the problem lights, ideally behind a loading screen. This pre-warms your lights and prevents them from stuttering in-game.
My guess is that something in the render pipeline is having to be loaded or compiled the first time the lights are enabled.