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
fix: requestSingleInstanceLock API sometimes hangs #33777
Conversation
+ // 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), |
There was a problem hiding this comment.
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 callschrome::AttemptToNotifyRunningChrome
chrome::AttemptToNotifyRunningChrome
triggersReadAck
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:
-
StoreAck
corresponds to ack_callback which may get called by user oncepreventDefault
action is executed if not we call it withnullptr
for backwards compatibility. In the case, were user executes theStoreAck
how doesSendBackAck
ensure the user input is obtained before piping data to the second instance. The timer fires as soon asnotification_callback.Run
is executed which does not correspond to user executingStoreAck
. -
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refs #33778 (comment)
Can you rebase against latest |
d4fd45b
to
016cca5
Compare
this is what also me I was asking that question please help me. whith
ensues
…On Thu, 14 Apr 2022, 07:01 Robo, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
patches/chromium/feat_add_data_transfer_to_requestsingleinstancelock.patch
<#33777 (comment)>:
> + g_write_ack_callback_called = false;
+ *result = notification_callback.Run(parsed_command_line, current_directory,
+ std::move(additional_data),
+ base::BindRepeating(&StoreAck))
+ ? TRUE
+ : FALSE;
-+ g_ack_timer.Start(FROM_HERE, base::Seconds(0),
-+ base::BindOnce(&SendBackAck));
++ if (*result) {
++ // If *result is TRUE, we return NOTIFY_SUCCESS.
++ // Only for that case does the second process read
++ // 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),
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
<https://github.com/electron/electron/blob/3d4d39d67b072a7c355dada2881cb6791e9e9f53/shell/browser/api/electron_api_app.cc#L518>
which returns false only when the first instance is shutting down.
Problem:
1.
StoreAck corresponds to ack_callback
<https://github.com/electron/electron/blob/3d4d39d67b072a7c355dada2881cb6791e9e9f53/shell/browser/api/electron_api_app.cc#L1121>
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.
—
Reply to this email directly, view it on GitHub
<#33777 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHU32BJLTV435EJCXFR7ALDVE6KDFANCNFSM5TMDY2LA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Failing test is unrelated and a known flake on /cc @jkleinsc |
Merging as CI failure unrelated to PR change. |
Release Notes Persisted
|
I have automatically backported this PR to "19-x-y", please check out #34071 |
This reverts commit 5b64885.
Description of Change
Fixes #33736
CC @nornagon @deepak1556
Checklist
npm test
passesRelease Notes
Notes: Fixed an issue with the
app.requestSingleInstanceLock()
API where it would sometimes hang.