Skip to content

fix: capturePage not resolving with hidden windows - #27883

Merged
codebytere merged 1 commit into
masterfrom
occluded-win-linux-no-capture
Mar 9, 2021
Merged

codebytere merged 1 commit into
masterfrom
occluded-win-linux-no-capture

Conversation

@codebytere

@codebytere codebytere commented Feb 23, 2021 •

Copy link
Copy Markdown
Member

Description of Change

Closes #6015.
Closes #27891.

If the renderer is suspended or otherwise occluded, there's no guarantee that view->CopyFromSurface will ever be called and thus the promise ever resolved (see here). Handle this by checking for the current page visibility and returning an empty image if this is the case.

cc @ckerr @zcbenz @MarshallOfSound @deepak1556

Checklist

Release Notes

Notes: Fixed an issue where win.capturePage() never called back after calling hide() for a hidden window on some platforms.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/10-x-y labels Feb 23, 2021
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Feb 23, 2021
@codebytere
codebytere force-pushed the occluded-win-linux-no-capture branch from f79326b to 38cfd22 Compare February 23, 2021 22:47
@codebytere
codebytere force-pushed the occluded-win-linux-no-capture branch from 38cfd22 to 814abb4 Compare February 24, 2021 15:26
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Feb 24, 2021
@deepak1556

Copy link
Copy Markdown
Member

@codebytere #27892 looks like a better solution to this issue as well, it has also narrowed down the root issue.

@codebytere codebytere closed this Feb 25, 2021
@CezaryKulakowski

Copy link
Copy Markdown
Contributor

@deepak1556 @codebytere I've made some testing and my fix (#27892) doesn't cover all cases: it may happen that callback isn't called at all. It can be reproduced by test added to this pr. I've checked that this fix covers both cases: with it both tests (mine and the one added by this pr) pass. I'd say: let's close my pr and merge this one.

@deepak1556

Copy link
Copy Markdown
Member

I am good with adding this fix back, but in your PR it is indicated that the responses sometime come back on a different thread is that only the case for hidden pages ?

@CezaryKulakowski

Copy link
Copy Markdown
Contributor

Yes, I've checked that this fix also covers my test case. It seems that without any fix callback is called on bad thread or it's not called at all for hidden pages so this fix should cover both cases.

@deepak1556

Copy link
Copy Markdown
Member

Thanks for clarifying, @codebytere wanna revive this PR ?

@zcbenz

zcbenz commented Mar 9, 2021

Copy link
Copy Markdown
Contributor

It seems that we all agree to merge this fix instead of #27892.

@codebytere
codebytere merged commit d9997c3 into master Mar 9, 2021
@release-clerk

release-clerk Bot commented Mar 9, 2021

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue where win.capturePage() never called back after calling hide() for a hidden window on some platforms.

@trop

trop Bot commented Mar 9, 2021

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "11-x-y", please check out #28074

@trop

trop Bot commented Mar 9, 2021

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "12-x-y", please check out #28075

@trop

trop Bot commented Mar 9, 2021

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "13-x-y", please check out #28076

@ztob

ztob commented Dec 17, 2021 •

Copy link
Copy Markdown

hi guys,

this issue still occurs.
we run electron app with 30-50 concurrent BrowserWindow with hidden state and at some point on some (random) pages the capture method will hang forever in the promise.
I did implemented Page.captureScreenshot through devtools protocol but the same thing.

electron v16.0.4
linux server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebContents.capturePage can freeze browser process win.capturePage never calls back after calling hide() for a hidden window

5 participants