1

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,426
  • 6
  • 24
  • 34
  • Can you capture a session in VLC? https://confluence.bethel.edu/display/ITSKB/Recording+a+Network+Stream+with+VLC+Player – DrMoishe Pippik Jun 06 '23 at 18:02
  • @DrMoishePippik That doesn't help because our classes are held in Big Blue Button which is an interactive platform which has a board, can play videos, show presentations etc. so it's not a video where I can capture with VLC. – Shayan Jun 06 '23 at 18:41
  • Have you tried creating another desktop and recording your software there? – Kalamalka Kid Jul 30 '23 at 04:37
  • @KalamalkaKid Same issue! The browser or the OS freezes the video, the audio can be heard, but the video is actually frozen to save resources. The only thing that works is to have a second monitor and to put the browser on the second monitor and no other window should completely cover the browser window, otherwise the video will get frozen again. I don't have a second monitor, I'm on a laptop and usually mobile. Recording online sessions without worries is very important to me. Over the years every single browser has gradually adopted this behavior to freeze the video when not visible. – Shayan Jul 30 '23 at 04:58
  • Can you use a virtual machine ? – harrymc Jul 30 '23 at 10:42
  • Firefox: try [this addon](https://addons.mozilla.org/en-US/firefox/addon/always-visible/). And also see [this thread](https://superuser.com/a/661013/714576) – 1NN Jul 30 '23 at 13:50
  • @1NN Doesn't work, I've already tried that extension and others, it does what I've described in item 2 on my question. Saw both links. What the browser is doing is beyond the scope of a page's Javascript. – Shayan Jul 30 '23 at 18:41
  • @harrymc I've had issues with virtual machines, the audio becomes broken after some time. Sluggish performance. Will have issues copy/pasting from and to the virtual machine, it will not always work and becomes broken after some time. If I'm asked to share my screen, I won't be able to share the host's screen which runs all my programs such as PySpark, VS Code etc. – Shayan Jul 30 '23 at 18:59
  • I'm only suggesting to use a VM for recording the browser, since it avoids the problems you mentioned. – harrymc Jul 31 '23 at 12:32
  • Have you tried disabling memory saver in chrome? [See here, point 1](https://www.windowsdigitals.com/how-to-keep-a-tab-active-in-chrome/) – 1NN Jul 31 '23 at 21:13
  • @1NN Yes it's already disabled. I've even listed some websites in the whitelist for extra measure, tried the "The Great Suspender" extension too. I'm an extension developer myself, what these features and what @Intruder has described in their answer, are related to unloading the tab completely from memory or as Chrome calls it, "discarding" the tab from memory: `chrome.tabs.discard()`. This is not related to the original issue I've described on my question here. And BTW, regardless of you disabling the memory saver or not, when you run out of memory, your tabs WILL be discarded by Chrome. – Shayan Aug 01 '23 at 07:28

3 Answers3

1

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

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/trasnparent mode. There's an issue talking about workaround for tricking browsers, but not sure how well it works and with which browsers.

Destroy666
  • 5,299
  • 7
  • 16
  • 35
  • 1
    I've been struggling with this issue for 2 years and now you solved it! Thanks a lot. If you happen to find the equivalent option in Firefox sometime, please do let me know. – Shayan Aug 01 '23 at 09:22
  • 2
    I think I found it, it's `widget.windows.window_occlusion_tracking.enabled` for Firefox! – Shayan Aug 01 '23 at 09:25
  • 1
    No idea about FF, but I also added an app that could potentially solve it for any browser/window, which came out as a result when searching for the flag in Google. – Destroy666 Aug 01 '23 at 09:36
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.)

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • Toggled the said setting to false and restarted the browser but the browser screen still freezes after around 10 seconds. I tried this method in conjunction with having the always visible extension enabled. – Shayan Aug 01 '23 at 08:14
  • I see some `compositor` options which could be related such as `gfx.vsync.compositor.unobserve-count`, tried upping the value of this one from 10 to 100 and restarted the browser, but the video still freezes after 10 seconds. – Shayan Aug 01 '23 at 08:19