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
[Bug]: capturePage doesn't work for a hidden browser view since version 13.0.0-beta.21 #30666
createBrowserView3 works fine with electron 12.x.y on Mac OS X.
createBrowserView2 doesn't work with electron 12.0.0-beta.21 and newer
createBrowserView3 doesn't work with electron 13.0.0-beta.21 and newer
The only difference between createBrowserView2 and createBrowserView3 is the createBrowserView3 loads about:blank before loading the target page.
Periodically reloading the page and capturing the page will break page loading completely, further loading requests will never be finished, and setting app.allowRendererProcessReuse to false doesn't help.
changed the title [-][Bug]: capturePage doesn't work for a hidden browser view since version 12.x[/-][+][Bug]: capturePage doesn't work for a hidden browser view since version 13.0.0-beta.21[/+]on Aug 24, 2021
I have updated the gist again to add another test createBrowserView4 to reproduce another issue we're facing, that is, periodic reloading the page and capturing the page will break page loading completely.
v12 - browserView.webContents.incrementCapturerCount() before capturing the page, browserView.webContents.decrementCapturerCount() after it(this is optional)
v13+ - browserView.webContents.incrementCapturerCount() before capturing the page, browserView.webContents.decrementCapturerCount() must be removed.
Same here. The workaround above doesn't work for my project. I am using electron/remote. remote.getCurrentWebContents().capturePage().then(r=>console.log(r))
The above promise will just hang forever without being solved.
However if I call webView.capturePage().then(r=>console.log(r))
this works fine when the webview is visible. Empty image is returned if the app is minimized / even covered by other app.
At least the promise returns something.
v12 - browserView.webContents.incrementCapturerCount() before capturing the page, browserView.webContents.decrementCapturerCount() after it(this is optional)
v13+ - browserView.webContents.incrementCapturerCount() before capturing the page, browserView.webContents.decrementCapturerCount() must be removed.
Can you test, that incrementCapturerCount() really increments visible_capturer_count_? isBeingCaptured() always returns false for hidden windows in 14.2.6
v12 - browserView.webContents.incrementCapturerCount() before capturing the page, browserView.webContents.decrementCapturerCount() after it(this is optional)
v13+ - browserView.webContents.incrementCapturerCount() before capturing the page, browserView.webContents.decrementCapturerCount() must be removed.
Can you test, that incrementCapturerCount() really increments visible_capturer_count_? isBeingCaptured() always returns false for hidden windows in 14.2.6
The incrementCapturerCount() is no longer working due to upstream changes and needs some changes to make it work again. The visible capturer count is reverted to the previous value just before returning to the javascript world, so the isBeingCaptured() always returns false.
With the following changes, the incrementCapturerCount() works as intended and the isBeingCaptured() return true now. But I'm not sure whether this is the correct fix, need some help from the dev team.
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index c1d28e24c2..ed5e744623 100644
--- a/shell/browser/api/electron_api_web_contents.cc+++ b/shell/browser/api/electron_api_web_contents.cc@@ -3006,8 +3006,9 @@ void WebContents::IncrementCapturerCount(gin::Arguments* args) {
// get stayAwake arguments if they exist
args->GetNext(&stay_awake);
- ignore_result(- web_contents()->IncrementCapturerCount(size, stay_hidden, stay_awake));+ auto handler =+ web_contents()->IncrementCapturerCount(size, stay_hidden, stay_awake);+ ignore_result(handler.Release());
}
Activity
[-][Bug]: capturePage doesn't work for a hidden browser view since version 12.x[/-][+][Bug]: capturePage doesn't work for a hidden browser view since version 13.0.0-beta.21[/+]zeeker999 commentedon Aug 26, 2021
The gist is updated with a new one that could reproduce this issue with electron 12.
zeeker999 commentedon Aug 26, 2021
it seems setting app.allowRendererProcessReuse to false fixes the issue for electron 12, but it doesn't fix it for electron 13.
zeeker999 commentedon Aug 26, 2021
I have updated the gist again to add another test
createBrowserView4to reproduce another issue we're facing, that is, periodic reloading the page and capturing the page will break page loading completely.codebytere commentedon Aug 26, 2021
@LuoJinghua are you sure it works on macOS? i'm seeing an empty image on macOS too, starting with
13.0.0-beta.21zeeker999 commentedon Aug 26, 2021
No. My memory is bad. It doesn't work on macOS starting with 13.0.0-beta.21, but it does work with 12.0.0-beta.21.
zeeker999 commentedon Oct 3, 2021
find a workaround for this issue:
@codebytere
h5nc commentedon Oct 19, 2021
Same here. The workaround above doesn't work for my project. I am using electron/remote.
remote.getCurrentWebContents().capturePage().then(r=>console.log(r))The above promise will just hang forever without being solved.
However if I call
webView.capturePage().then(r=>console.log(r))this works fine when the webview is visible. Empty image is returned if the app is minimized / even covered by other app.
At least the promise returns something.
miniak commentedon Nov 25, 2021
Could it be caused by #27883?
zeeker999 commentedon Jan 18, 2022
I don't think so. I did attach to the process and manually step into the method, the visibility state is correct.
sanperrier commentedon Feb 17, 2022
I think related to this bug in chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=999305&q=incrementCapturerCount&can=2
Current workaround we are using in our project (painful and hacky):
Windows:backgroundThrottling: falseincrementCapturerCount()just onceMacOS:backgroundThrottling: falseincrementCapturerCount()just onceOut testing shows that with that workaround:
requestAnimationFrame()works just fineCSS animations and transitionsworkIntersectionObserverworksdocument.visibilityStatestaysvisible(but onMacOSit switchesvisible -> hidden -> visibleif window becomes occluded)sanperrier commentedon Feb 17, 2022
Can you test, that
incrementCapturerCount()really incrementsvisible_capturer_count_?isBeingCaptured()always returnsfalsefor hidden windows in14.2.6@zeeker999
zeeker999 commentedon Feb 17, 2022
The incrementCapturerCount() is no longer working due to upstream changes and needs some changes to make it work again. The visible capturer count is reverted to the previous value just before returning to the javascript world, so the isBeingCaptured() always returns false.
zeeker999 commentedon Feb 17, 2022
With the following changes, the incrementCapturerCount() works as intended and the isBeingCaptured() return true now. But I'm not sure whether this is the correct fix, need some help from the dev team.
zeeker999 commentedon Feb 17, 2022
The change was introduced by commit 22a70eb.