Hello, I’ve been developing my game for around 8 months, I don’t ever recall having this problem for the first 6 months of development, actually I’ve never experienced this issue once in the past 5 years of using Unity. But now all of a sudden I’m getting huge frame drops, I’ve profiled this issue and all I’m seeing is Semaphore.WaitForSignal taking 22ms. This only seems to happen in the Built Standalone version!
I’ve spent 3 days now optimizing things and have seen slight improvements, yet the problem still remains there.
Everythings going great for around 2-5 minutes then the game has frame issues every 10 seconds or something then goes back to normal frames, then does it again?
Not much has changed on screen through this last 2 months apart from a few little things, mainly code changes which isn’t the issue whatsoever, the ‘renderer’ in the profiler spikes way above anything else and I can’t figure out why, its literally game breaking and not a pleasant experience to play the game.
I’m like 99% sure I haven’t changed any of my shaders since the start of time of development as well, they was the bedrock to my level design, my vert count is like: 5k, the tris count is like: 2k. There is only about 200 max game objects in scene at one time (Not on camera all at once either)
Vsync seems to stabalize the issue a little and has reduced the 22ms timer to around 14ms.
I’ve attached the profiler to my standalone build so I can profile during gameplay
The issue is likely your GPU frametimes are slightly too long to actually finish rendering at the intended framerate. As for why it’s happening only after 2-5 minutes, your GPU might be thermal throttling.
Try enabling GPU profiling in the Profiler. “Rendering” is not the GPU, that’s the CPU side render thread that issues commands to the GPU via the current graphics API.
The reason for the 2-5 minute timer does make sense actually, the fans start going nuts on my laptop after that time.
I had “Graphic Jobs” enabled and wasn’t able to profile the GPU at the time but I’ve disabled it now to run the checks. Could you possibly shed some light on this subject from this screenshot?
Seems like its coming from “Render Camera / Render Opaques / RenderLoop.ScheduleDraw” Mostly Render Camera at 13.5ms, the rest is small amounts like post processing etc which I’ve disabled way before this post too check if that was the issue, it isn’t
I mean that’s just the top level group, not the thing that’s taking a long time. You’d need to scroll through the children of each to find that. But if the fast frame and slow frames are both showing 69 total draw calls at the top of the hierarchy, then there’s nothing really more for you to see here. Next step is to download a GPU monitoring tool like GPU-Z, and watch the GPU Clock and temp graphs to see if your GPU is reaching it’s max temp and then dropping the clock rate a bunch. There’s not much Unity can do about that happening. But enabling Vsync should help in that it won’t be trying to do 400 fps until it overheats.
You might also want to check to make sure your GPU fans are spinning, and your air intakes aren’t clogged with dust.
Its the top level thing yeah isn’t that the point? Otherwise whats the point in the profiler? At one point it takes like 2-3ms then takes like 12ms for ‘Rendering Camera’ I don’t think its anything to do with heating issues if Im completely honest I’m using a brand new laptop not even 6 months old Razer Blade 15 with an RTX 2070, even with vsync on its still visibly lagging at those times shown, even capped at 60fps. This doesn’t happen with any high end games I play either on the laptop, if that was the case it would be happening on all my games which it doesn’t, so honestly I’m thinking it’s Unity in general or a mistake I’ve made using Unity at some point which Im unaware of
Thanks for reaching out I’ll probably check the GPU Monitoring tools but I doubt it will come out with anything useful, the profiler needs to be more specific about whats causing the issues ‘Opaque textures’ doesn’t lead too anything other than every material I’ve got in the game, no object names, no shader names, no material names, nothing just that itsself which is pretty much impossible to debug
Appreciate the reply but I don’t think that’s a solution, cheers!
The top level is showing you the sum of all items below it. If you have 10 draws taking 100ms, that doesn’t tell you if they’re all taking around 10ms, or if one is taking 91ms and the rest 1ms. The hierarchy helps you track down where those slow things are, but unless you actually find “the slow thing” it’s not going to be that useful.
Oh, then it’s absolutely an overheating problem. Razer laptops are famously bad at cooling, and thermal throttle fast even when brand new.
That’s just kind of the nature of having a very thin laptop with very powerful components, and many other similarly “high end” gaming laptops suffer from the same problems.
Other games might not show the issue as obviously because they’re more likely CPU limited so the GPU isn’t getting to spin up to max, and the GPU on laptops tends to be a far more significant portion of the total heat output and can quickly overwhelm the cooling systems.
Run Affinity Designer in the background. There’s some kind of bug in Affinity Designer that causes it to always be using the GPU, even when it’s in the background.
This bug is sufficient to force MacOS to constantly check in on the GPU and seemingly prevent it getting stuck in loops or in some other way flush/clear it.
Unity seems to, in most versions of 2019,4, get stuck in loops on the GPU, of some sort, even when there’s nothing going on.
By doing this dirty trick with Affinity Designer spoofing MacOS forcing it to do something to calm the card, my machine stays cool and I can continue to work and stay sane, and everything on the GPU happens much faster.
I found this by mistake. I’m not sure how you’re going to find a Windows app that does something similar to the GPU… if that’s the problem.
To know for sure, see if you get the same kind of heat and fan action in a nearly blank new scene in your project using the same rendering settings etc.
More the direction I’m thinking, probably Unity itself bugging out or hanging or no reason or a reason I’ve got no clue about, I’ve heard people have the same issue in empty scenes as well. I’m not sure how I can sort this though because I can’t expect people who play the game to have background apps open such as that, I mean its nice to know its cool when In development but you know what I mean?
I’m just going to ignore it for now and probably fix it later on, spending too much time working on something that has no debug is quite the task! Even when switching stuff out its still awful, I did though improve those wait times from 25ms to 14ms, so maybe I can do it again in the future too almost nothing cause that’s almost a 50% perfomance increase on those wait times I’ve already achieved
I know it doesn’t have this problem in builds (on a Mac, might not be same on PC).
These issues of flogging come and go with the little updates. You’ve hit on the right policy, don’t try to fix it until you’re done. Otherwise you’ll always be chasing out Unity bugs, presuming they’re your issues.
I’ve probably lost at least 6 months doing that, as I was new to C# and Unity, and presumed it was always me making things go haywire. It turns out it’s almost never me.
It used to be every second or third little minor point update was a goodie, and the other two or so would stutter and run slower and cook the fans etc. But I haven’t found one since 2019.4.16f that’s good like that. Which is a bit of a worry.
At some point I have to move to 2020.LTS, and everytime I try to do that… things are way worse in terms of overall performance. I hope they can sort that out, otherwise I’m going to have to wind back some graphics details and particle counts and do other optimisations that are time consuming.