Commit 54b8aa2
Fix race condition in CleanupAddon.subscribeRenderingChanged
The test ensureCleanUpAddonCleansUp was failing intermittently because
CleanupAddon deferred container cleanup via Display.asyncExec(), creating
a race condition where event loop pumping during part activation could
interfere with async cleanup tasks.
Root cause analysis:
- When hidePart() is called on parts with REMOVE_ON_HIDE_TAG, it triggers
synchronous EMF model change events via UIEventPublisher
- Event delivery is fully synchronous: EventBroker.send() ->
EventAdmin.sendEvent() -> Display.syncExec() -> handler execution
- The subscribeRenderingChanged handler detected visCount==0 but deferred
cleanup via asyncExec (line 352)
- Meanwhile, activate() calls during hidePart() pumped the event loop
(via focusGui/SWT focus handling), potentially consuming queued asyncExecs
before they could observe the final state
- This created timing-dependent behavior where cleanup could be skipped
Fix:
- Remove asyncExec wrapper from subscribeRenderingChanged's visCount==0 path
- Since event delivery is synchronous, visCount already reflects the actual
state at event time - no need to defer and re-check
- Container is now hidden immediately when last renderable child becomes
non-renderable, before any event loop pumping can interfere
- Update test to use simple spinEventLoop + assertFalse instead of
30-second waitForCondition, as cleanup is now synchronous
This fixes the flaky test that failed ~1-3% of the time even with the
30-second timeout. The subscribeTopicChildren handler still uses asyncExec
for children removal/sash unwrapping, but toBeRendered cleanup is now
deterministic.
Fixes #3581
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 883c8c8 commit 54b8aa2
2 files changed
Lines changed: 10 additions & 17 deletions
File tree
- bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/cleanupaddon
- tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench
Lines changed: 7 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
359 | 356 | | |
360 | 357 | | |
361 | 358 | | |
| |||
Lines changed: 3 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
| |||
2447 | 2446 | | |
2448 | 2447 | | |
2449 | 2448 | | |
2450 | | - | |
2451 | | - | |
2452 | | - | |
2453 | | - | |
2454 | | - | |
2455 | | - | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2456 | 2452 | | |
2457 | 2453 | | |
2458 | 2454 | | |
| |||
0 commit comments