Avoid BusyIndicator putting Display to sleep after being done#3181
Avoid BusyIndicator putting Display to sleep after being done#3181HeikoKlare merged 1 commit intoeclipse-platform:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a Linux-specific race condition in BusyIndicator.showWhile(Future<?>) where the display thread could get stuck in display.sleep() if a Display#wake() happens just before sleep() is entered. It replaces the completion wake-up mechanism for CompletionStage/CompletableFuture with a no-op asyncExec, ensuring an event is always queued and sleep() is reliably interrupted across platforms.
Changes:
- Replace
display.wake()with a no-opdisplay.asyncExec(...)in theCompletionStagecompletion handler to avoid lost wakeups. - Add inline comments explaining why
asyncExec()is used to prevent the race.
.../org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
Outdated
Show resolved
Hide resolved
09d36f5 to
441a36b
Compare
akurtakov
left a comment
There was a problem hiding this comment.
Looks like a good next step to me.
|
I am unsure what is better to push it for M1 now with the risk to have to delay contribution or delay it for M2. |
|
It would not be a big problem to delay m1 to Saturday if that’s better for the team. I would recommend that. I think we just need to let @MohananRahul know. |
There was a problem hiding this comment.
It seems not harmful here, the only improvement I see is we can make the lambda a static final field. If I remember correctly SWT even accept a null argument here.
I don't think this is required for M1 but also won't harm... I do not expect any special improvement or risk with having it or not in real world use-cases.
Due to a race condition between the BusyIndicator's event loop spinning and the display.wake() call performed after the future to wait for is done, the BusyIndicator execution may get stuck in a display.sleep() call. While on Windows and MacOS the wake() call will effectively still ensure that display.sleep() return immediately if invoked display.sleep() was called, this is neither guaranteed nor does that happen on Linux. This fixes the race condition by replacing the wake() call in the future with scheduling an empty task that ensures that the event queue remains spinned (like everywhere else). Contributes to eclipse-platform#3044
Makes sense. I updated the PR so that we use a static final field. You could also pass
We are now beyond M1 anyway. I propose to merge this now so that we could find any unexpected suspicious behavior soon. |
Due to a race condition between the BusyIndicator's event loop spinning and the display.wake() call performed after the future to wait for is done, the BusyIndicator execution may get stuck in a display.sleep() call. While on Windows and MacOS the wake() call will effectively still ensure that display.sleep() return immediately if invoked display.sleep() was called, this is neither guaranteed nor does that happen on Linux.
This fixes the race condition by replacing the wake() call in the future with scheduling an empty task that ensures that the event queue remains spinned (like everywhere else).
Contributes to #3044