Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: webContents.capturePage() for hidden windows on Windows/Linux #39730

Merged
merged 1 commit into from Oct 12, 2023

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Sep 4, 2023

Description of Change

Closes #31992.

Refactors a previous choice made to return an empty image for occluded windows when using webContents.capturePage on Windows and Linux. This was done to address an issue where GetRenderWidgetHostView::CopyFromSurface didn't call its callback in some occlusion cases. The original issue occurred because when a given page is hidden, the compositor called the provided callback immediately without posting it to the main thread - the worker thread then deadlocked as it tried to acquire the lock guarding the Promise returned by webContents.capturePage held by the main thread. This second approach instead creates a OnceCallback that will run OnCapturePageDone via the UIThreadTaskRunner.

This is done in several upstream callsites.

Checklist

Release Notes

Notes: Fixed an issue where fully occluded windows would return an empty image from webContents.capturePage() on Windows and Linux.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/25-x-y PR should also be added to the "25-x-y" branch. target/26-x-y PR should also be added to the "26-x-y" branch. target/27-x-y PR should also be added to the "27-x-y" branch. labels Sep 4, 2023
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Sep 4, 2023
@codebytere codebytere changed the title fix: webContents.capturePage for hidden windows on Windows/Linux fix: webContents.capturePage() for hidden windows on Windows/Linux Sep 4, 2023
@deepak1556
Copy link
Member

Needs a rebase to address build failures.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 5, 2023
@codebytere codebytere force-pushed the fix-capture-page-hidden branch 2 times, most recently from 5de00cc to 44010fc Compare September 6, 2023 12:24
@codebytere codebytere marked this pull request as draft September 6, 2023 13:51
@codebytere codebytere force-pushed the fix-capture-page-hidden branch 2 times, most recently from 47397ad to f08bebf Compare September 7, 2023 09:58
@codebytere codebytere marked this pull request as ready for review October 10, 2023 09:08
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Oct 10, 2023
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Oct 11, 2023
@github-actions github-actions bot added the target/28-x-y PR should also be added to the "28-x-y" branch. label Oct 11, 2023
@codebytere codebytere merged commit 5c821d3 into main Oct 12, 2023
18 checks passed
@codebytere codebytere deleted the fix-capture-page-hidden branch October 12, 2023 07:35
@release-clerk
Copy link

release-clerk bot commented Oct 12, 2023

Release Notes Persisted

Fixed an issue where fully occluded windows would return an empty image from webContents.capturePage() on Windows and Linux.

@trop
Copy link
Contributor

trop bot commented Oct 12, 2023

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

@trop trop bot added in-flight/28-x-y and removed target/28-x-y PR should also be added to the "28-x-y" branch. labels Oct 12, 2023
@trop
Copy link
Contributor

trop bot commented Oct 12, 2023

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

@trop
Copy link
Contributor

trop bot commented Oct 12, 2023

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

@trop
Copy link
Contributor

trop bot commented Oct 12, 2023

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

@trop trop bot added in-flight/26-x-y in-flight/27-x-y merged/28-x-y PR was merged to the "28-x-y" branch. merged/26-x-y PR was merged to the "26-x-y" branch. merged/27-x-y PR was merged to the "27-x-y" branch. merged/25-x-y PR was merged to the "25-x-y" branch. and removed target/25-x-y PR should also be added to the "25-x-y" branch. target/26-x-y PR should also be added to the "26-x-y" branch. target/27-x-y PR should also be added to the "27-x-y" branch. in-flight/28-x-y in-flight/26-x-y in-flight/27-x-y in-flight/25-x-y labels Oct 12, 2023
MrHuangJser pushed a commit to MrHuangJser/electron that referenced this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/25-x-y PR was merged to the "25-x-y" branch. merged/26-x-y PR was merged to the "26-x-y" branch. merged/27-x-y PR was merged to the "27-x-y" branch. merged/28-x-y PR was merged to the "28-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: webContents.capturePage() returns empty image for fully occluded BrowserWindow on Windows
3 participants