You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
backgroundThrottling: false not obeyed in Electron 4+ #20974
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
Electron Version:
All versions starting from 4
Operating System:
Tested on Win 10, don't know if other platforms are affected.
Last Known Working Electron version:
3.1.13
Expected Behavior
When an electron window is opened with backgroundThrottling: false set in webPreferences it shouldn't throttle setTimeout while window is minimized, but it does throttle it.
Actual Behavior
Minimized window's setTimeout is throttled, despite disabling it.
#21037 says it's backported to 6.1.x, but I'm getting document.visibilityState === 'hidden' when my window is minimized or hidden on 6.1.7 - any thoughts?
Much more strangely, static content in my BrowserWindows disappears when I focus a separate window in my project and many other oddities, 3 shown below
Even more strangely, this worked properly for me exactly once when I tested it andd ensured I was getting the expected visibilityState, then I packaged the app to give it a shot, didn't work, plus the weird behaviors.
Came back to development, didn't work there either, but no weird behaviors. No changes to any files, dependencies or otherwise.
Edit: I've only seen these issues very sporadically now, but no amount of restarting fixed it the day I made this comment. Very strange. Will update if I encounter it again or discover more details.
Unfortunately I continue seeing this issue and the visibilityState continues to return unexpected results. You can see here the effects. The cursor updates in response to the underlying content, but that content is not visible (default, pointer, text). Note that when the cursor is missing in this video, it is a text selection cursor but the screen recorder doesn't capture that cursor.
The failure to render contents can occur at any time in any application window or multiple application windows. Any ideas about this? Is this not actually fixed in Electron 6.1.x?
The issue occurs with and without GPU rasterization available ('enabled' & unavailable_off), which surprises me. Sending a signal to update the contents of a window via ipc will briefly restore for a split second, and then they're empty windows again. The more windows backgroundThrottling is disabled for, seemingly the worse the issue gets. This possibly only affects windows with a preload script, though I don't have enough data to do anything but make a slightly educated guess there. I managed to run into this in development for the first time today.
Edit: Persists in Electron 7. The weird content disappearing bug seems to only occur in the following circumstances over 99% of the time:
At least 3 BrowserWindow
Developer tools is open for at least 1 BrowserWindow
document.visibilityState === "hidden" when the docs say this should not occur.
From the docs:
If backgroundThrottling is disabled, the visibility state will remain visible even if the window is minimized, occluded, or hidden.
This happens when I minimize or hide a window. I've tried the following, and the issue persists:
Creating the window with webPreferences.backgroundThrottling: false
win.setBackgroundThrottling(false)
win.webContents.setBackgroundThrottling(false)
Unfortunately there's no win.getBackgroundThrottling() for me to see what the renderer thinks its own state is supposed to be.
This is creating big issues for us with lag when users show the window for our app, because operations that are intended to happen when the window is hidden don't occur reliably, and instead they need to be done when the user shows the window.
Tested on Windows 7 with Electron 8.2.5.
Reacted by Justin Mayfield, hanshou101 and Jack Keating
It was still an issue the last time I tested in 18.3.x
@deepak1556@codebytere I don't think this should be closed because #21037 doesn't seem to resolve the issue - unless the documentation I'm relying on was incorrect.
Activity
codebytere commentedon Nov 6, 2019
@mbman i believe this was fixed in #20239, but was not backported. I'll see if I can get some backports up to address this in versions 7 and 6.
mbman commentedon Nov 7, 2019
@codebytere thanks for the info - does that PR also fixes
window.setBackgroundThrottling()not working?codebytere commentedon Nov 7, 2019
That'll be fixed by the PR i put up a little while ago: #21037
Nantris commentedon Jan 8, 2020
#21037 says it's backported to
6.1.x, but I'm gettingdocument.visibilityState === 'hidden'when my window isminimizedorhiddenon6.1.7- any thoughts?Much more strangely, static content in my
BrowserWindows disappears when I focus a separate window in my project and many other oddities, 3 shown belowEven more strangely, this worked properly for me exactly once when I tested it andd ensured I was getting the expected
visibilityState, then I packaged the app to give it a shot, didn't work, plus the weird behaviors.Came back to development, didn't work there either, but no weird behaviors. No changes to any files, dependencies or otherwise.
Edit: I've only seen these issues very sporadically now, but no amount of restarting fixed it the day I made this comment. Very strange. Will update if I encounter it again or discover more details.
Nantris commentedon Jan 10, 2020
Unfortunately I continue seeing this issue and the
visibilityStatecontinues to return unexpected results. You can see here the effects. The cursor updates in response to the underlying content, but that content is not visible (default,pointer,text). Note that when the cursor is missing in this video, it is atext selection cursorbut the screen recorder doesn't capture that cursor.The failure to render contents can occur at any time in any application window or multiple application windows. Any ideas about this? Is this not actually fixed in Electron 6.1.x?
The issue occurs with and without GPU rasterization available ('enabled' &
unavailable_off), which surprises me. Sending a signal to update the contents of a window viaipcwill briefly restore for a split second, and then they're empty windows again. The more windowsbackgroundThrottlingis disabled for, seemingly the worse the issue gets. This possibly only affects windows with a preload script, though I don't have enough data to do anything but make a slightly educated guess there. I managed to run into this in development for the first time today.Edit: Persists in Electron 7. The weird content disappearing bug seems to only occur in the following circumstances over 99% of the time:
Nantris commentedon Jul 7, 2020
@sofianguy @codebytere this persists in
Electron 8.2.5or the docs are wrong.document.visibilityState === "hidden"when the docs say this should not occur.From the docs:
This happens when I
minimizeorhidea window. I've tried the following, and the issue persists:webPreferences.backgroundThrottling: falsewin.setBackgroundThrottling(false)win.webContents.setBackgroundThrottling(false)Unfortunately there's no
win.getBackgroundThrottling()for me to see what the renderer thinks its own state is supposed to be.This is creating big issues for us with lag when users show the window for our app, because operations that are intended to happen when the window is hidden don't occur reliably, and instead they need to be done when the user shows the window.
Tested on Windows 7 with Electron 8.2.5.
crypto-dump commentedon Jan 31, 2023
@slapbox is this issue resolved? I also have same problem
Nantris commentedon Jan 31, 2023
It was still an issue the last time I tested in
18.3.x@deepak1556 @codebytere I don't think this should be closed because #21037 doesn't seem to resolve the issue - unless the documentation I'm relying on was incorrect.
hlevring commentedon Feb 21, 2024
I think this might have finally gotten resolved in V 28.0.0
https://www.electronjs.org/blog/electron-28-0#behavior-changed-webcontentsbackgroundthrottling-set-to-false-affects-all-webcontents-in-the-host-browserwindow
I just had a 10 sec look and could really find the related PR, but it's definitely described as something that should fix this issue I think