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
Copy link
Contributor

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.

refactor: rewire the desktop capturer API to remove race conditions
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 removed the new-pr 🌱 label Apr 29, 2019

@jkleinsc jkleinsc merged commit cd3539a into 6-0-x Apr 30, 2019

13 of 14 checks passed

appveyor: win-ia32-testing AppVeyor build failed
Details
Artifact Comparison No Changes
Details
Semantic Pull Request ready to be squashed
Details
Valid Backport Valid Backport
Details
WIP Ready for review
Details
appveyor: win-ia32-testing-pr AppVeyor build succeeded
Details
appveyor: win-x64-testing AppVeyor build succeeded
Details
appveyor: win-x64-testing-pr AppVeyor build succeeded
Details
build-linux Workflow: build-linux
Details
build-mac Workflow: build-mac
Details
electron-arm-testing Build #20190429.37 succeeded
Details
electron-arm64-testing Build #20190429.37 succeeded
Details
lint Workflow: lint
Details
release-notes Release notes found
@release-clerk

This comment has been minimized.

Copy link

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 Apr 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.