JS-throttling in background tabs; bug or feature?
flash last edited by
jacekn last edited by
Chromium-based browsers + Firefox (idk about other Gecko-based) do this since 2012. IIRC Internet Explorer does it too. Same for Edge.
You can disable it with command line option AFAIK, but you have to search for it. Also you may want to try some workarounds: https://blog.pivotal.io/labs/labs/chrome-and-firefox-throttle-settimeout-setinterval-in-inactive-tabs - I don't know if they'll work. You may try Web Workers too.
Personally I think it's a very good feature. There isn't much use cases when this is undesierd and can't be worked around.
flash last edited by
Hi jacekn and thanks for your reply.
I already mentioned in my previous post, that the old Vivaldi throttled JS in background tabs, just like most other browsers do by default. That's not the issue, because in Firefox and Opera I can disable this feature entirely and generally speaking, any other browser I know of, was able to circumvent this throttling with the use of WebWorkers as you rightly said.
I've been doing exactly that for a long time and so far it has worked fine in all previous versions of Vivaldi until snapshot 1.5.627.3 (it should be fine in 1.5.633.16 as well but I didn't use that version). Since the update past said snapshot however, any use of the previous circumvention code produces bad results. Take a look at the following:
If the page is in the foreground everything is fine and the console is quickly filled with almost identical "tick 100" entries, the odd "tick 99" and "tick 101" in between. However, as soon as I switch to another tab, the behavior becomes very strange. The new console output is "tick 999 tick 0 tick 0 tick 0 tick 0 tick 1 tick 0 tick 0 tick 0 tick 0" within one second. Normally, since this setInterval() is called from within a WebWorker, it should not be affected by throttling at all. That's how the whole thing worked for years!
While the code is still executed ten times per second, it's not possible any more to spread this execution out equally over time, instead all of the calls now run in a series without any break in between. This change out-right breaks some features I wrote userscripts for and I would assume a host of other websites' features too. One of those I wrote for myself is a fade-out fade-in for media playback, where I would adjust the volume every x milliseconds to achieve the desired effect.
In order to get around this issue, I tried using the "–disable-background-timer-throttling" flag. It is mentioned as being applied in the vivaldi://about page, but it has no effect on this issue.
I just tested the above code on a portable version of the Chromium 56 browser and it behaves the same way as the latest Vivaldi snapshot does, breaking my desired functionality. At least it's not a Vivaldi only issue, although by using the Blink engine, the Vivaldi devs do import both bugs and features into their Browser and this is one of them. I guess knowing the kind of developers of Chrome/Chromium, this is yet another "feature" we receive without an ability to disable. Well, I'm adding this to the long list of reasons why I do not use Chrome and hope the Vivaldi devs will pick up my feature request about an option to disable background throttling entirely.