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

refactor: rewire the desktop capturer API to remove race conditions #18042

Conversation

trop[bot]
Copy link
Contributor

@trop trop bot commented Apr 29, 2019

Backport of #18029

See that PR for details.

Notes: Fixed race condition in the desktopCapturer module where some requests for sources would never be resolved or unhandled exceptions would be thrown in the main process.

We now create a new instance of atom::api::DesktopCapturer for every
request instead of weirdly re-using the same instance and queuing
requests.  This means there is now a 1:1 relationship between request
and DesktopCapturer so there isn't a race condition between the observer
for one request calling back before the observer of another.  This is an
issue ever since the backing APIs moved to worker threads.

This also does a few things to ensure memory management
* Only ever listen to one event per-request, after that we wipe the emit
function to ignore all future events
* Ensures we clean up the window_capturer_, screen_capturer_ and
captured_sources_ in native land once the request is over.

This _in theory_ fixes a flake we've been seeing on CI where we try to
resolve the promise for a request that no longerr exists.
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Apr 29, 2019
@trop trop bot added 6-0-x backport This is a backport PR labels Apr 29, 2019
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Apr 29, 2019
@jkleinsc jkleinsc merged commit cd3539a into 6-0-x Apr 30, 2019
@release-clerk
Copy link

release-clerk bot commented Apr 30, 2019

Release Notes Persisted

Fixed race condition in the desktopCapturer module where some requests for sources would never be resolved or unhandled exceptions would be thrown in the main process.

@jkleinsc jkleinsc deleted the trop/6-0-x-bp-refactor-rewire-the-desktop-capturer-api-to-remove-race-conditions-1556569299539 branch April 30, 2019 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6-0-x backport This is a backport PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants