mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: capturePage not resolving with hidden windows (#28075)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -2810,6 +2810,18 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
|
||||
return handle;
|
||||
}
|
||||
|
||||
#if !defined(OS_MAC)
|
||||
// If the view's renderer is suspended this may fail on Windows/Linux -
|
||||
// bail if so. See CopyFromSurface in
|
||||
// content/public/browser/render_widget_host_view.h.
|
||||
auto* rfh = web_contents()->GetMainFrame();
|
||||
if (rfh &&
|
||||
rfh->GetVisibilityState() == blink::mojom::PageVisibilityState::kHidden) {
|
||||
promise.Resolve(gfx::Image());
|
||||
return handle;
|
||||
}
|
||||
#endif // defined(OS_MAC)
|
||||
|
||||
// Capture full page if user doesn't specify a |rect|.
|
||||
const gfx::Size view_size =
|
||||
rect.IsEmpty() ? view->GetViewBounds().size() : rect.size();
|
||||
|
||||
Reference in New Issue
Block a user