Repository navigation
fix: ensure document.visibilityState aligns with the visibility of the TopLevelWindow - #19988
Conversation
1bb2456 to
ce66fa9
Compare
zcbenz
left a comment
There was a problem hiding this comment.
Would this affect the behavior of setBackgroundThrottling API?
And should this be a feat as it adds a new option?
Initial tests showed it didn't change the behavior of that API, our patch short circuits this logic so even these extra calls don't affect it.
🤷♂ Technically yes, I added that new option to retain backwards compatibility. I'd like to find some form of this change that can land in |
zcbenz
left a comment
There was a problem hiding this comment.
Thanks for clarification, this looks good to me.
ce66fa9 to
89385d5
Compare
|
Release Notes Persisted
|
|
I have automatically backported this PR to "7-0-x", please check out #20134 |
In electron#20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also electron#19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
In electron#20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also electron#19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
In electron#20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also electron#19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
Backport of electron#21372. This also backports a tiny bit of electron#19988. Notes: Fix flicker when switching between BrowserViews after creating new BrowserView
In #20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also #19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
In #20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also #19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
In #20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also #19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
In #20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also #19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
In #20829, we fixed compositor recycling when switching between BrowserViews, but it turns out that there is one additional case that we need to handle. When we create a completely new BrowserView instance, it starts of as visible (even when it hasn't been added to the window), which means that it will need its own compositor instead of using the recycled compositor. To fix this, lets make BrowserViews hidden by default until they're added to the window. See also #19988. This is a potentially breaking change given that the initial value of `document.visibilityState` will now be `hidden`, but given the experimental status of BrowserViews, I think this is a fine change to make. The old behavior can be restored with `webPreferences: { show: true }`. Notes: Fix compositor recycling when creating new BrowserView
The best way to see what this changes is to review the bunch of new tests I added. Basically this fixes the following two things and a bunch of edge cases
show: falseresults indocument.visibilityState === 'visible'. This is fundamentally wrong so now it's hidden, but due to a technical constraint imposed by theready-to-showevent we only set it to hidden initially if folks use a newpaintWhenInitiallyHidden: falseoption when constructing their window.win.hide()andwin.show()did not modify visibilityState resulting in backgrounded windows not being throttled correctly and CPU usage being insane while backgrounded. This is fixed in this PR, no other changes for users needed.Long term we should make
paintWhenInitiallyHidden: falsethe default but for now let's keep this change non breaking. The reason we needpaintWhenInitiallyHiddenis because previouslyshow: falsedidn't set the renderer as hidden so it painted, that first paint is used to fire theready-to-showevent. If we don't paint that event never fires (and I've documented this in this PR).Notes: Fixed several cases where
document.visibilityStatewould be incorrect. Thewin.show()andwin.hide()methods now correctly update visibility state