Skip to content

fix: DesktopCapturer gc'd prior to capture completion #28273

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

Merged

Conversation

samuelmaddock
Copy link
Member

@samuelmaddock samuelmaddock commented Mar 18, 2021

Description of Change

desktopCapturer.getSources() returns a promise which should resolve
when capturing finishes. Internally it creates an instance of
DesktopCapturer which is responsible for resolving or rejecting
the promise.

Between the time DesktopCapturer starts capturing frames and when
it finishes, it's possible for its handle to be GC'd leading to
it never resolving.

These changes pin the instance of DesktopCapturer until it either
finishes or errors.

fixes #25595


To verify the fix, I ran this Fiddle gist which normally fails after 10-30 seconds without the fix
https://gist.github.com/90f43a52e7c48a531a57bec77428e11a

cc @codebytere

Checklist

Release Notes

Notes: Fixed desktopCapturer.getSources() promise result sometimes never resolving.

desktopCapture.getSources() returns a promise which should resolve
when capturing finishes. Internally it creates an instance of
DesktopCapturer which is responsible for resolving or rejecting
the promise.

Between the time DesktopCapturer starts capturing frames and when
it finishes, it's possible for its handle to be GC'd leading to
it never resolving.

These changes pin the instance of DesktopCapturer until it either
finishes or errors.

fixes electron#25595
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 18, 2021
@samuelmaddock samuelmaddock added target/10-x-y semver/patch backwards-compatible bug fixes labels Mar 18, 2021
@MarshallOfSound MarshallOfSound merged commit 4057e6b into electron:master Mar 18, 2021
@release-clerk
Copy link

release-clerk bot commented Mar 18, 2021

Release Notes Persisted

Fixed desktopCapturer.getSources() promise result sometimes never resolving.

@MarshallOfSound MarshallOfSound deleted the fix/desktop-capturer-gc branch March 18, 2021 20:43
@trop
Copy link
Contributor

trop bot commented Mar 18, 2021

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

@trop
Copy link
Contributor

trop bot commented Mar 18, 2021

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

@trop
Copy link
Contributor

trop bot commented Mar 18, 2021

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

@trop
Copy link
Contributor

trop bot commented Mar 18, 2021

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

@alectrocute
Copy link

Thank you so much for this, @samuelmaddock!

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Mar 22, 2021
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.

Electron desktopCapturer.getSources().then is not resolved
5 participants