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
win.capturePage never calls back after calling hide() for a hidden window #6015
Okay was able to reproduce in a new example app. There are two things which cause this to happen.
The window must currently be hidden
You must call capturePage asynchronously
varapp=require('electron').app;varBrowserWindow=require('electron').BrowserWindow;varmainWindow=null;app.on('ready',function(){varopts={width: 1280,height: 720,show: false,frame: false,devTools: false}mainWindow=newBrowserWindow(opts);// hiding the window is key, if it is shown it will workmainWindow.hide()mainWindow.loadURL('file://'+__dirname+'/index.html');setTimeout(function(){mainWindow.capturePage(function(data){// this function is never calledconsole.log("captured data",data)})},1000)// calling this async is key. if you reduce the setTimeout value it will work});
changed the title [-]win.capturePage never calls back in linux when window is hidden[/-][+]win.capturePage never calls back after calling `hide()` for a hidden window[/+]on Jun 14, 2016
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a temporary error. The following address(es) deferred:
[email protected]
Domain joe-jackson.net has exceeded the max emails per hour (124/100 (124%)) allowed. Message will be reattempted later
------- This is a copy of the message, including all the headers. ------
Received: from github-smtp2-ext3.iad.github.net ([192.30.252.194]:45330 helo=github-smtp2b-ext-cp1-prd.iad.github.net)
by rs5.websitehostserver.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
(Exim 4.89)
(envelope-from <[email protected]>)
id 1dx1SQ-0018wQ-Np
for [email protected]; Tue, 26 Sep 2017 20:48:17 -0500
Date: Tue, 26 Sep 2017 18:47:27 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com;
s=pf2014; t=1506476847;
bh=tYmfE8mjrtaq97yIcI8laC7ZmLX8mmoAsnr3FRSy4cA=;
h=From:Reply-To:To:Cc:In-Reply-To:References:Subject:List-ID:
List-Archive:List-Post:List-Unsubscribe:From;
b=i1hXkgzkMop8DpXdkUddlBdLotPU6fSI8/jDA4zFqe2zK73L0BtSHkcINL6ZSIpMR
XK2eBR8mZnrOhbC7AjD7QNroZUjmGT2qfoAd1hwPEn7R75fxZE/3Vukz7cEP7RFfN2
oB5Rf6QquaqstHBQTdazMT3QsEFYNBzQeoeUyeCY=
From: Shelley Vohr <[email protected]>
Reply-To: electron/electron <[email protected]>
To: electron/electron <[email protected]>
Cc: Subscribed <[email protected]>
Message-ID: <electron/electron/issues/6015/[email protected]>
In-Reply-To: <electron/electron/issues/[email protected]>
References: <electron/electron/issues/[email protected]>
Subject: Re: [electron/electron] win.capturePage never calls back after
calling `hide()` for a hidden window (#6015)
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_59cb032fb0398_ddd13fc104b84f848589a";
charset=UTF-8
Content-Transfer-Encoding: 7bit
Precedence: list
X-GitHub-Sender: codebytere
X-GitHub-Recipient: jcj52436999
X-GitHub-Reason: subscribed
List-ID: electron/electron <electron.electron.github.com>
List-Archive: https://github.com/electron/electron
List-Post: <mailto:[email protected]>
List-Unsubscribe: <mailto:unsub+000f94f77f82de615a756ab58805b36c4bf06f12002f281792cf0000000115e2c52f92a169ce0987014a@reply.github.com>,
<https://github.com/notifications/unsubscribe/AA-U92XXrkmWkIM9mQBGVDE0muY0pVSCks5smakvgaJpZM4Iz3F1>
X-Auto-Response-Suppress: All
X-GitHub-Recipient-Address: [email protected]
X-Spam-Status: No, score=-7.8
X-Spam-Score: -77
X-Spam-Bar: -------
X-Ham-Report: Spam detection software, running on the system "rs5.websitehostserver.net",
has NOT identified this incoming email as spam. The original
message has been attached to this so you can view it or label
similar future email. If you have any questions, see
root\@localhost for details.
Content preview: closing due to abandonment. -- You are receiving this because
you are subscribed to this thread. Reply to this email directly or view it
on GitHub: #6015 (comment)
[...]
Content analysis details: (-7.8 points, 5.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked.
See
http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
for more information.
[URIs: github.com]
0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source
[192.30.252.194 listed in dnsbl.sorbs.net]
-5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high
trust
[192.30.252.194 listed in list.dnswl.org]
-2.8 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2)
[192.30.252.194 listed in wl.mailspike.net]
-0.0 SPF_PASS SPF: sender matches SPF record
1.5 HTML_IMAGE_ONLY_20 BODY: HTML: images with 1600-2000 bytes of words
0.0 HTML_MESSAGE BODY: HTML included in message
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's
domain
-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid
X-Spam-Flag: NO
----==_mimepart_59cb032fb0398_ddd13fc104b84f848589a
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
closing due to abandonment.
It was closed since there had been no action on it for over a year, and it is not on our team's immediate radar. Since we try to treat the issues tab as the team's backlog, we try to close issues as needed to bring the project closer to its reality and roadmapping.
However, this is an existent issue we are experiencing in our app. We have implemented great functionality for increasing the perception loading time of our app by calling capturePage() before quitting the app and then showing the generated image on startup. We are calling hide() before calling capturePage() so users don't notice a lag when closing the app. This approach doesn't work on Windows which is quite unfortunate.
If this issue is fixed I could write a cool article for how to optimize Electron apps which will increase Electron's authority.
It would be awesome to reopen the issue. Thanks for considering.
i can't promise anything but i'll try to take a look at this issue next week if i have time :) i'll re-open it in the meantime, and let you know if there's progress. Oftentimes closing issues can help us figure out what's actually still an issue too, since we'll get more traction by closing and seeing reactions than by just leaving it and remaining unsure if it's still a problem.
This is still an issue on Windows years later: captureWindow is never resolved after calling .hide() on a BrowserWindow.
Sample to reproduce
import{app,BrowserWindow}from"electron";app.on("ready",async()=>{constbrowserWindow=newBrowserWindow({width: 900,height: 600,show: true,webPreferences: {contextIsolation: false,},});awaitbrowserWindow.loadURL("https://youtube.com");// This call will resolve as expectedconstimage=awaitbrowserWindow.capturePage();console.log("Screenshot size:",image.getSize());browserWindow.hide();// This call does not resolveconstimage2=awaitbrowserWindow.capturePage();// This will never be logged as the previous capturePage never resolvesconsole.log("Screenshot size",image2.getSize());});
The second capturePage never resolves on Windows 10. If you initiate the BrowserWindow with show: false, capturePage does work. It is explicitly after calling hide. Likewise, if you call .show(), all the previously unresolved calls with resolve and the method will continue working as expected.
My app's use case requires taking screenshots of the window while it is hidden, and the window switching between shown and hidden.
Electron versions: 11.3 (latest), 12.0.0-beta.28, 9.4.3, 10.3.2.
OS: Windows 10 (It works on OSX. I have not tested Linux)
Activity
zcbenz commentedon Jun 13, 2016
I can't reproduce by simply capturing a page loaded from filesystem, can you provide a minimal app that can reproduce this problem?
brian-mann commentedon Jun 13, 2016
Okay was able to reproduce in a new example app. There are two things which cause this to happen.
capturePageasynchronouslyzcbenz commentedon Jun 14, 2016
I can reproduce with your example, calling
hide()for a hidden window seems to cause problems.[-]win.capturePage never calls back in linux when window is hidden[/-][+]win.capturePage never calls back after calling `hide()` for a hidden window[/+]codebytere commentedon Sep 27, 2017
closing due to abandonment.
jcj52436999 commentedon Sep 27, 2017
astoilkov commentedon Jan 11, 2018
Why was this issue closed? I am experiencing the same problem. Should I create a new issue describing the same problem?
codebytere commentedon Jan 12, 2018
It was closed since there had been no action on it for over a year, and it is not on our team's immediate radar. Since we try to treat the issues tab as the team's backlog, we try to close issues as needed to bring the project closer to its reality and roadmapping.
astoilkov commentedon Jan 12, 2018
Great to hear an explanation @codebytere. Thanks!
However, this is an existent issue we are experiencing in our app. We have implemented great functionality for increasing the perception loading time of our app by calling
capturePage()before quitting the app and then showing the generated image on startup. We are callinghide()before callingcapturePage()so users don't notice a lag when closing the app. This approach doesn't work on Windows which is quite unfortunate.If this issue is fixed I could write a cool article for how to optimize Electron apps which will increase Electron's authority.
It would be awesome to reopen the issue. Thanks for considering.
codebytere commentedon Jan 12, 2018
i can't promise anything but i'll try to take a look at this issue next week if i have time :) i'll re-open it in the meantime, and let you know if there's progress. Oftentimes closing issues can help us figure out what's actually still an issue too, since we'll get more traction by closing and seeing reactions than by just leaving it and remaining unsure if it's still a problem.
astoilkov commentedon Jan 12, 2018
Great. Thanks!
sns-sem commentedon Feb 23, 2021
This is still an issue on Windows years later:
captureWindowis never resolved after calling.hide()on aBrowserWindow.Sample to reproduce
The second
capturePagenever resolves on Windows 10. If you initiate the BrowserWindow withshow: false,capturePagedoes work. It is explicitly after calling hide. Likewise, if you call.show(), all the previously unresolved calls with resolve and the method will continue working as expected.My app's use case requires taking screenshots of the window while it is hidden, and the window switching between shown and hidden.
I hope this issue can get looked at.