Bug Report Browser Source, 'Background Tabs,' and Javascript Timing

vencabot

Member
The recent Chromium update for the Browser sources has killed some of the apps that I use on the stream, and it's because non-visible Browser Sources are now treated as being 'in the background.

When using Javascript's setTimeout method to schedule execution, recent versions of Chrome enforce a minimum of 1 second between delays as a way of managing battery life when multiple tabs are open in the browser and they want to continuously run code. This move was very controversial and has broken tons of apps all over the internet, effectively stopping them from executing when they're in the background and forcing them to "catch up" once they come back to the foreground.

Basically, I have some web apps on the stream which animate continuously, but the BrowserSource isn't always visible. Since the recent OBS Studio update, when the Browser Source becomes visible, the animations are out of time and have to awkwardly catch up while onlookers recoil in disgust. Previously, the animations were always running, even when the source wasn't visible, so this wasn't an issue.

I think that Browser Source tabs should automatically be launched with Chromium's "--disable-background-timer-throttling" flag, or this option should be togglable on each source's Properties page. OBS already has tools for automatically reloading Browser Sources when they become visible and shutting them down when they become invisible, if CPU usage is a concern.

Here's some more information on the subject. https://developers.google.com/web/updates/2017/03/background_tabs In the meantime, I guess I'm going to try to re-write my apps so that I can reload them whenever they become visible without them looking so ugly while they reload. That way, at least the animations won't be all out-of-sync when the source becomes visible, again. v_v
 

WizardCM

Forum Moderator
Community Helper
Definitely not a bad suggestion. In the meantime, you can launch OBS with that flag (--disable-background-timer-throttling ) and it will automatically pass it on to all of your browser sources.
 

vencabot

Member
Definitely not a bad suggestion. In the meantime, you can launch OBS with that flag (--disable-background-timer-throttling ) and it will automatically pass it on to all of your browser sources.

Wow, thanks! That worked! Saves me the trouble of recoding stuff for the stream UI. Have a good one!
 

vencabot

Member
As of version 23.1.0, adding the --disable-background-timer-throttling option to OBS no longer fixes this problem. This is a pretty nasty bug, since it means that, when using a browser source with continuous, Javascript-based animations, one of two things need to be true for them to work right:

1.) They must be on a scene that is ALWAYS visible, or
2.) They need to have 'refresh browser when the scene becomes active' toggled, which can cause all kinds of other problems (resource pop-in as images, videos, etc., have to be loaded while the scene is active. Won't work for pages where some amount of set-up needs to be done, on the page, before the stream begins so that it'll look right on stream).

When actually using Chromium, it is still possible to avoid Javascript throttling by keeping each tab in its own, non-minimized (?) window, rather than relegating them to a background tab.

Without knowing how the Browser Source works, I can't recommend a particular fix, but it does seem odd to me that Browser Sources in non-visible scenes are treated as though they were in a background tab. Is that a feature that was intentionally coded into OBS (maybe to conserve resources?). If so, can we get a checkbox in the Properties window to disable this functionality? Is it a bug that the '--disable-background-timer-throttling' option stopped working, or is it just that this option is no longer supported by the version of Chromium that OBS is using?

Should I report this elsewhere than on this forum?


Thank you for your help. Sad that the animations on my browser sources is all glitchy, again, after being smooth for a year. v_v
 

mahurdx

New Member
I had something similar of an issue. My browser sources just keeps disappearing and they are only visible when I turn on studio mode but not everyone wants to waste their screenspace with studio mode. So basically the only alternative to a proper fix I found is by using a plugin called source dock which lets you dock any source or scene in ur obs as a dockable window. Using this, I stacked all the browser sources under one dock and now all the browser sources are visible all the time.
image_2023-01-19_055637173.png
 
Last edited:
Top