Skip to content

Fix race condition in CleanupAddon.subscribeRenderingChanged#3725

Draft
vogella wants to merge 1 commit intoeclipse-platform:masterfrom
vogella:fix-cleanup-addon-race-condition
Draft

Fix race condition in CleanupAddon.subscribeRenderingChanged#3725
vogella wants to merge 1 commit intoeclipse-platform:masterfrom
vogella:fix-cleanup-addon-race-condition

Conversation

@vogella
Copy link
Contributor

@vogella vogella commented Feb 4, 2026

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

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 eclipse-platform#3581

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Test Results

 3 024 files  ±0   3 024 suites  ±0   2h 10m 19s ⏱️ - 12m 17s
 8 232 tests ±0   7 984 ✅ ±0  248 💤 ±0  0 ❌ ±0 
23 520 runs  ±0  22 729 ✅ ±0  791 💤 ±0  0 ❌ ±0 

Results for commit aa9e3b7. ± Comparison against base commit b44e9ab.

@vogella
Copy link
Contributor Author

vogella commented Feb 4, 2026

AFAICS this is a save change (famous last words) and should finally fix our forever flaky cleanup race condition revealed in the cleanup test.

@vogella
Copy link
Contributor Author

vogella commented Feb 4, 2026

I suggest to wait for the beginn of the next release developement for this one.

@vogella vogella marked this pull request as draft February 4, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PartRenderingEngineTests.ensureCleanUpAddonCleansUp still fails randomly

1 participant