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: requestSingleInstanceLock API sometimes hangs #33777

Merged
merged 1 commit into from May 4, 2022

Conversation

rzhao271
Copy link
Contributor

Description of Change

Fixes #33736

CC @nornagon @deepak1556

Checklist

Release Notes

Notes: Fixed an issue with the app.requestSingleInstanceLock() API where it would sometimes hang.

@rzhao271 rzhao271 requested review from a team as code owners April 13, 2022 23:16
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Apr 13, 2022
@nornagon nornagon added target/18-x-y semver/patch backwards-compatible bug fixes labels Apr 13, 2022
@trop
Copy link
Contributor

trop bot commented Apr 13, 2022

@rzhao271 has manually backported this PR to "18-x-y", please check out #33778

+ // the acknowledgement. Therefore, only send back
+ // the acknowledgement if *result is TRUE,
+ // otherwise the program hangs during the ConnectNamedPipe call.
+ g_ack_timer.Start(FROM_HERE, base::Seconds(0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not convinced for the purpose of the timer here, consider the following sequence,

  • ProcessLaunchNotification gets called as soon as the second instance calls chrome::AttemptToNotifyRunningChrome
  • chrome::AttemptToNotifyRunningChrome triggers ReadAck as soon as the notification to the message window is successful
  • On the first instance side, notification_callback.Run represents NotificationCallbackWrapper which returns false only when the first instance is shutting down.

Problem:

  1. StoreAck corresponds to ack_callback which may get called by user once preventDefault action is executed if not we call it with nullptr for backwards compatibility. In the case, were user executes the StoreAck how does SendBackAck ensure the user input is obtained before piping data to the second instance. The timer fires as soon as notification_callback.Run is executed which does not correspond to user executing StoreAck.

  2. ReadAck is called eagerly for all success scenarios irrespective of whether the first instance has data to send or not.

Solutions:

For supporting the cases of sending data from first instance to second instance, we should have a message window on the second instance as well and the first instance should notify this message window to prepare for reading data back once the first instance knows for sure there is data to send. This would eliminate the timer used here and also ensure SendBackAck is responsible for controlling the ack pipe creation.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Apr 14, 2022
Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepak1556
Copy link
Member

Can you rebase against latest main to address the CI failures, thanks!

@rzhao271 rzhao271 force-pushed the rzhao271/connect-patch-fix-main branch from d4fd45b to 016cca5 Compare April 19, 2022 16:55
@Yakinopat
Copy link

Yakinopat commented Apr 23, 2022 via email

@deepak1556
Copy link
Member

deepak1556 commented Apr 30, 2022

Failing test is unrelated and a known flake on main.

/cc @jkleinsc

@deepak1556
Copy link
Member

@rzhao271 can you rebase on latest main to address the flaky test failure, Refs #34020

@jkleinsc
Copy link
Contributor

jkleinsc commented May 4, 2022

Merging as CI failure unrelated to PR change.

@jkleinsc jkleinsc merged commit 5b64885 into electron:main May 4, 2022
@release-clerk
Copy link

release-clerk bot commented May 4, 2022

Release Notes Persisted

Fixed an issue with the app.requestSingleInstanceLock() API where it would sometimes hang.

@trop
Copy link
Contributor

trop bot commented May 4, 2022

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

VerteDinde added a commit that referenced this pull request May 7, 2022
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
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.

Hang in ConnectNamedPipe when using requestSingleInstanceLock
5 participants