I know that modern browsers are throttling background tabs and making setTimeout() or setInterval() call once per second, but is there any possibility to prevent it from doing so?
As a web developer you have practically zero control over what the Browser does or decides to do.
I mean I’ve tried to use things like HackTimer.js or worker-timers package, but I’m not sure if that works with WebGL. Anyway I thought there are some solutions for it aswell.
You can see by its repository it was last updated 7 years ago. That’s ages in tech time. You can assume it no longer functions since Browser developers learned of that “hack” and prevented it. This is what you can expect to happen with any such tool so it’s best not to rely on it.
Yeah but it can give you bad performance (you can change the 30 by any number you want) :
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 30;
I have already tried that, but it does not change anything.
What is your unity version? I remember that i have tested on unity 2022 few months ago and it was working but like i was not happy of the performance, i’m not sure that i have keep the project file. I’m gonna take a look but i can’t promise anything.
My unity version is 2023. Anyway can you check if it is working on your version?
No. Any workaround you could try might not work with any browser/hardware/OS combination and will behave random/incorrectly.
You’ll have to design your game around this limitation. It should be quite easy if done right from the beginning.