Repository navigation
fix: WebContents.capturePage can freeze browser process - #27892
Closed
CezaryKulakowski wants to merge 1 commit into
Closed
CezaryKulakowski wants to merge 1 commit into
CezaryKulakowski wants to merge 1 commit into
Conversation
When BrowserWindow.webContents.capturePage is called on hidden page we try to resolve its promise on the worker thread instead of the main thread of the browser process. It happens because when page is hidden compositor calls the callback OnCapturePageDone immediately without posting it to the main thread). When it happens worker thread dead locks as it tries to acquire lock kept by the main thread (the lock which guards the promise returned by capturePage). This change fixes the problem by assuring that promise is always resolved on the main thread of the browser process.
Contributor
Author
|
Fixes #27891. |
3 tasks done
5 tasks done
deepak1556
reviewed
Feb 25, 2021
deepak1556
left a comment
Member
There was a problem hiding this comment.
Nice find, LGTM
Failing tests on mac are related.
Contributor
Author
|
Test fails on mac as it looks like |
zcbenz
reviewed
Mar 8, 2021
| expect(imgBuffer[25]).to.equal(6); | ||
| }); | ||
|
|
||
| it('does not freeze browser process when called on hidden page', async() => { |
Contributor
There was a problem hiding this comment.
Can you also fix the lint error?
/home/builduser/project/src/electron/spec-main/api-browser-window-spec.ts
1357:75 error Missing space before function parentheses space-before-function-paren
1363:22 error There should be no space after this paren space-in-parens
Contributor
Author
Contributor
|
Closing in favor of #27883. |
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When BrowserWindow.webContents.capturePage is called on hidden
page we try to resolve its promise on the worker thread instead of
the main thread of the browser process. It happens because when page
is hidden compositor calls the callback OnCapturePageDone immediately
without posting it to the main thread). When it happens worker thread
dead locks as it tries to acquire lock kept by the main thread (the
lock which guards the promise returned by capturePage).
This change fixes the problem by assuring that promise is always
resolved on the main thread of the browser process.
Description of Change
Checklist
npm testpassesRelease Notes
Notes: Fixed possible dead lock on call to WebContents.capturePage