4

I'm on Windows 10 and I use OBS to record the window of web browsers. I record online class sessions for later use, a lot of the times I have to switch windows or desktops, and when the web browser window is not in focus, after 10 seconds on Firefox, and immediately on Chromium based browsers, the web browser screen freezes (Firefox) or goes black blank (Chromium), so as to save resources rendering etc. I have tried a lot of things to stop this from happening:

  1. Changing Windows styles such as transparency and always on top. See: window styles and extended window styles
  2. Installing browser extension to change document objects like this: document.visibilityState = 'visible'; document.hidden = false to fool the tab into thinking it's still visible. See: always visible and always active window
  3. Try different recording programs.
  4. Try different major web browsers (Chrome, Firefox, Edge, Opera, Brave).
  5. Toggling Hardware Acceleration.
  6. Toggling memory saving options, in settings or in about:config or chrome:flags and related extensions. See: the great suspender

I think it was first Chrome that adopted this behavior so I stopped using it, and moved over to Firefox, then Firefox adopted this, and I moved to the Edge browser, but the new updated Edge browser (which is based on Chromium) is also doing this. I also tried Opera and Brave.

Another idea would be to record the class inside OBS (browser source feature), but on most online sessions, my presence is only limited to one tab/browser, so I can't open a browser tab with OBS's browser to record the session. I need to be active on a browser, respond to the class etc. And I want to be able to record it's screen and freely move between desktops and windows. So as you can see, I cannot record the browser inside a virtual machine as I might have to share my host's desktop to the class. Installing my programs such as VS Code etc. inside a virtual machine and syncing files between would be too much of a hassle.

Similar issue has been discussed here on the OBS forums: Problem with window capture when the window is not focused

Shayan
  • 1,893

4 Answers4

3

Update

As pointed out by @Shayan, recent Chromium versions hid this flag. And the default behavior is still that e.g. videos freeze if you switch tab focus.

To show the flag until they get of it completely, you can enable chrome://flags/#temporary-unexpire-flags-m130 flag. But as the name suggests, this is temporary and the flag is doomed, it might be removed permamently at any time, probably in 133 version if I understand their expiration policies correctly.


There's also this application that could work for other browsers or windows which don't have such feature/flag: WindowTop, which attempts to set window on top, including also in shrink/transparent mode. There's an issue talking about workaround for tricking browsers, but not sure how well it works and with which browsers.

No longer a reliable answer

In Chrome there's this flag: chrome://flags/#calculate-native-win-occlusion, which unloads the active tab if the window is not in foreground. You can try disabling it. Relaunch the browser afterwards, else it will not have effect.

I tested with latest Chrome as window capture in latest OBS and:

  • before disabling it, it froze webpages when minimized, e.g. playing videos on them, no black screen as you reported
  • after disabling it, it froze no longer
Destroy666
  • 12,350
1

The "calculate-native-win-occlusion" flag has been removed.

  1. The registry tweak still works for now (3rd option), but I experienced major issues loading sites like YouTube.

Option 3 This will require editing registry

Open Registry Editor

Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome

if there are keys (folders) missing, just create a new key

Under Chrome key add new DWORD with name NativeWindowOcclusionEnabled and value 0

Create a second one with name WindowOcclusionEnabled and value 0

Or copy the following into a new Notepad document, save with a .reg extension and run

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
"NativeWindowOcclusionEnabled"=dword:00000000
"WindowOcclusionEnabled"=dword:00000000
  1. You can also use third-party applications to keep a window always in focus. For example, the Crop And Lock utility from Microsoft PowerToys offers this via the Reparent function (default shortcut: ⊞ Win + Ctrl + Shift + R).

    (Turns out a similar solution was suggested in the very first reply on the OBS Project forum, but it used windowtop.info instead.)

There are probably better alternatives out there.

GtGt
  • 11
0

Firefox:

Navigate to about:config and search for browser.tabs.unloadOnLowMemory. Set it to false.

Chrome:

Open Settings and use search bar to look for "Memory Saver" (in some chrome clones it could be "Tab sleep", etc.). Turn that feature off.
As for Microsoft Edge, you should be looking for "Turn on efficiency mode" and "Save resources with sleeping tabs" (turn those off).

P.S.: Also make sure you don't have any third party extensions for unloading inactive tabs installed.

Intruder
  • 11
  • 3
0

For Firefox, I suspect that disabling the widget.pause-compositor-when-minimized setting might fix this. (It's not a "memory saver" thing but a "power saver" – it's fairly common for programs to stop rendering when the window is invisible, especially now that web browsers use GPU rendering like games do; and Firefox probably has no way of knowing that its window is being recorded.)

grawity
  • 501,077