Skip to content

Do not block the UI thread on the workspace lock when opening a match - #4563

Open
fedejeanne wants to merge 1 commit into
eclipse-platform:masterfrom
fedejeanne:search-editoropener-lock-convoy
Open

fedejeanne wants to merge 1 commit into
eclipse-platform:masterfrom
fedejeanne:search-editoropener-lock-convoy

Conversation

@fedejeanne

@fedejeanne fedejeanne commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Contributes to: eclipse-pde/eclipse.pde#1715

Problem

Opening a search match in an editor that is not a text editor (for example the plug-in manifest editor) freezes the UI while another thread holds the workspace lock. The search selects the match through a temporary marker and creates, changes and deletes that marker on the UI thread. Each of these steps waits for the workspace lock, so a slow resource change listener blocks the UI up to three times per click. CPU samples of real IDEs during startup show waits of 4 s, 44 s (14 s + 30 s) and 52 s, while JDT's DeltaProcessor.resourceChanged held the lock in a POST_CHANGE notification:

OrderedLock.acquire ← WorkManager.checkIn ← Workspace.prepareOperation ← Resource.createMarker
← EditorOpener.showWithMarker ← EditorOpener.openAndSelect ← FileSearchPage.showMatch

How to reproduce it manually

I observed this UI freeze when I did this in my Committer IDE (m2e is necessary for the reproduction) version I20261025-2300 :

  • Start the IDE
  • While the Initializing Java Tooling job is still running (you have to be fast), open a search (Ctrl + h) and search for profiles in pom.xml
  • In the Search View, double click one of the results (this may or may not reproduce the UI freeze already)
  • Keep moving through all of the matches with the Up / Down arrows image in the Search view

What it does

Opening a match no longer waits for the workspace lock. Editors that provide a text editor through an adapter, like many multi-page and wrapper editors, select the match directly without a marker; in a multi-page editor this selects in the active text page. All other editors open at once and show the selection as soon as the workspace allows it. When the user opens several matches in a row, only the latest one is selected, and nothing is selected in an editor that was closed or shows another input meanwhile. A failure to create the marker is now logged instead of shown in a dialog.

Technical concept

The marker is created in one workspace operation (createMarker(type, attributes)) by a background job, and the editor reveals it asynchronously in the UI thread; the marker is deleted in the background afterwards. All these jobs share one scheduling rule, so pending requests that are superseded are cancelled before they touch the workspace instead of each waiting for the lock.

How to test

Locally

  1. Start a runtime workbench with JDT and PDE and create a plug-in project.
  2. In the host IDE, set a breakpoint (suspend thread) in org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged.
  3. In the runtime workbench, add or remove an entry in the .classpath of a Java project. The notification stops at the breakpoint and holds the workspace lock.
  4. Press Ctrl+H, search the files for Bundle-SymbolicName, and double-click the match in META-INF/MANIFEST.MF.
  5. Without this change, the UI freezes until the breakpoint is resumed. With it, the manifest editor opens at once and selects the match after the breakpoint is resumed.

Automated

EditorOpenerTest holds the workspace lock in a blocking POST_CHANGE listener (a WorkspaceJob does not hold the lock while runInWorkspace runs) and opens matches in two test editors. Without the fix, the UI thread waits about 5 s in each test; with it, AllSearchTests passes.

🤖 Generated with Claude Code

Opening a search match in an editor that is not a text editor (for example
the plug-in manifest editor) froze the UI for as long as another thread held
the workspace lock, up to several tens of seconds during startup. The search
selected the match through a temporary marker and created, changed and
deleted that marker on the UI thread. Each of these steps waited for the
workspace lock, so a slow resource change listener, such as the Java model
update after a classpath change, blocked the UI up to three times per click.

Opening a match no longer waits for the workspace lock. Editors that provide
a text editor through an adapter, like many multi-page and wrapper editors,
select the match directly, without a marker. In multi-page editors this
selects in the active text page. All other editors open at once and show the
selection as soon as the workspace allows it. When the user opens several
matches in a row, only the latest one is selected, and nothing is selected
in an editor that was closed or shows another input meanwhile. A failure to
create the marker is now logged instead of shown in a dialog.

The marker is created in one workspace operation by a background job, and
the editor reveals it asynchronously in the UI thread. The jobs share one
scheduling rule, so pending requests that are superseded are cancelled
before they touch the workspace.

Contributes to: eclipse-pde/eclipse.pde#1715

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the search-result navigation changes.

No open issues 🎉

What changed in this PR

This PR updates search-result navigation to avoid blocking the UI thread on workspace-locked marker operations when opening non-text editors.

Changes:

  • Selects matches directly in editors that adapt to ITextEditor.
  • Moves temporary marker creation and deletion to background jobs, with checks for superseded requests and closed or changed editors.
  • Adds regression tests, supporting test editors, and localized job names.
File Description
tests/​org.eclipse.search.tests/​src/​org/​eclipse/​search/​tests/​TextEditorWrapper.java Adds a wrapper editor for testing direct text selection.
tests/​org.eclipse.search.tests/​src/​org/​eclipse/​search/​tests/​GotoMarkerOnlyEditor.java Adds an editor that records marker-based navigation.
tests/​org.eclipse.search.tests/​src/​org/​eclipse/​search/​tests/​filesearch/​EditorOpenerTest.java Tests responsiveness, request cancellation, editor closure, and marker cleanup.
tests/​org.eclipse.search.tests/​src/​org/​eclipse/​search/​tests/​filesearch/​AllFileSearchTests.java Includes the new regression tests in the suite.
tests/​org.eclipse.search.tests/​plugin.xml Registers both test editors.
bundles/​org.eclipse.search/​search/​org/​eclipse/​search/​internal/​ui/​text/​EditorOpener.java Adds adapter-based selection and asynchronous marker handling.
bundles/​org.eclipse.search/​search/​org/​eclipse/​search/​internal/​ui/​SearchMessages.properties Defines localized marker-job labels.
bundles/​org.eclipse.search/​search/​org/​eclipse/​search/​internal/​ui/​SearchMessages.java Exposes the new job-label message fields.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ± 0     867 suites  ±0   49m 31s ⏱️ - 9m 36s
 8 550 tests + 5   8 310 ✅ + 5  240 💤 ±0  0 ❌ ±0 
21 522 runs  +15  20 846 ✅ +15  676 💤 ±0  0 ❌ ±0 

Results for commit 6205f1b. ± Comparison against base commit 6ff7172.

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.

2 participants