Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation is paused if source is not visible anywhere #307

Open
CyBeRoni opened this issue Jul 26, 2021 · 6 comments
Open

Animation is paused if source is not visible anywhere #307

CyBeRoni opened this issue Jul 26, 2021 · 6 comments

Comments

@CyBeRoni
Copy link

CyBeRoni commented Jul 26, 2021

Operating System Info

Windows 10

Other OS

No response

OBS Studio Version

27.0.1

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/gORv5KITsQ0cWIfn

OBS Studio Crash Log URL

No response

Expected Behavior

The OBS Browser source should always continue to run animations (and js code) even when it is not actually visible anywhere. For example an animation triggered by the scene being switched away from the browser source should continue in the background so that when the source becomes visible again, it is (presumably) finished.

Current Behavior

When not using studio mode, a multiview window or a projector, processing is paused when the browser source becomes invisible. Using studio mode or having a multi-view or a projector containing the source open prevents the behaviour and has animations complete as expected.

A quick google led me to the "--disable-background-timer-throttling" flag to prevent this but that does not work in the current version of OBS at the time of writing.

Steps to Reproduce

  1. Create an HTML file with the following content:
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.7.1/gsap.min.js"></script>
<div style="background: red; font-size: 24pt" id="move">THIS SHOULD MOVE DOWN ONLY</div>
<script type="application/javascript">

function moveDown(){
        gsap.to("#move", {y: 200, duration: 1});
}

function moveUp(){
        gsap.to("#move", {y: 0, duration: 1});
}


window.addEventListener('obsSceneChanged', function(event) {
        console.log(event);
        if (event.detail.name == "Scene"){
                moveDown();
        } else {
                moveUp();
        }
});
</script>
</body>

The page contains a red bar with text that moves up or down. Only the downward motion should be visible to Program.

  1. Create a scene called "Scene", with a browser source in it with the above file and the rest default
  2. Create a second scene with no contents
  3. Switch between the two scenes. Upon switching to "Scene" the red bar should move down. Upon switching to any other scene, it should (in the background) move up.
  4. Observe that with no projector, multi-view and without studio mode, switching back to Scene has the upward animation running as you switch to it, even if you waited for longer than 1 second (the animation duration). The animation is then interrupted by the downward animation triggered by the switch to Scene.
  5. Enable Studio Mode and switch again. Observe that when Scene is in the Preview pane, the red bar moves up as expected, and then down again when you switch to it. (If you switch faster than one second, the animation is still interrupted but this is to be expected.)

Anything else we should know?

It seems that the obsSourceVisibleChanged event also does not fire when using studio mode/etc which I believe is not how people are intending that to be used. I have not verified this however.

@WizardCM
Copy link
Member

This sounds like intended behaviour from the Page Visibility API.

@CyBeRoni
Copy link
Author

I would agree that this behaviour is intended in an actual browser (laptop battery life and all that) but not in a broadcast setting.

@WizardCM
Copy link
Member

The main reason we respect the Page Visibility API is because it's standardised behaviour, which in my opinion also makes sense in a broadcast setting. Keep in mind a large chunk of our users stream video games while using OBS, and wouldn't want sources using resources unnecessarily when they're not visible.

@CyBeRoni
Copy link
Author

I'm aware of that, and in fact I see the same issue happening often with video game streamers who have an intermission scene with their chat rendered on it: the chat doesn't update when the scene isn't visible and only restarts when they switch to that scene. Most game streamers don't use studio mode so I'm going to guess this is the same behaviour.

Another problem with this is that it causes the behaviour of the browser source in OBS to be different depending on whether or not you're using studio mode, a multi-view window or a source/scene projector that happens to have the relevant browser source in it.

It is my opinion that while this behaviour might be ok to have enabled by default for the reason you state, it should be able to be opted out of without workarounds.

@WizardCM
Copy link
Member

I wouldn't be against a toggle in the browser source Properties that allows the user to disable the Page Visibility API, it'd just have to be worded very specifically.

@mahurdx
Copy link

mahurdx commented Jan 19, 2023

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 screen space 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.
image_2023-01-19_061013085

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants