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 and I have the following projects in my workspace, which I imported from the Oomph catalog (File > Import > Oomph > Projects from Catalog)

image image

Steps

  • 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 conditional breakpoint (suspend thread) in org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged. The condition is: !Thread.currentThread().getName().contains("main")
  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

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

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ± 0     867 suites  ±0   47m 21s ⏱️ - 12m 46s
 8 576 tests + 9   8 336 ✅ + 9  240 💤 ±0  0 ❌ ±0 
21 600 runs  +27  20 927 ✅ +27  673 💤 ±0  0 ❌ ±0 

Results for commit 5c92821. ± Comparison against base commit 50268ca.

♻️ This comment has been updated with latest results.

@fedejeanne
fedejeanne force-pushed the search-editoropener-lock-convoy branch from 6205f1b to 5126f11 Compare November 19, 2026 10:48

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 remain for the search-match navigation changes.

No open issues 🎉

Review effort: Balanced

@fedejeanne
fedejeanne force-pushed the search-editoropener-lock-convoy branch from 4200dcc to ab98bbb Compare November 23, 2026 14:40
@fedejeanne
fedejeanne requested a balanced review from Copilot November 24, 2026 07:49

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.

🟡 Changes recommended

A match can be selected in a hidden nested text editor because its containing wrapper page is not activated, requiring a fix and regression coverage.

1 open issue

Review effort: Balanced

@fedejeanne
fedejeanne force-pushed the search-editoropener-lock-convoy branch from ab98bbb to 087dff0 Compare November 25, 2026 14:00
@fedejeanne
fedejeanne requested review from r-mennig and a balanced review from Copilot November 25, 2026 14:13

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.

🟡 Changes recommended

A nested multi-page editor can return another file’s text editor, causing search offsets to be selected in the wrong file; recursive file matching and a regression test are needed.

1 open issue
1 resolved since last review

Review effort: Balanced

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

There are no active review issues for the changes addressing search-match UI freezes caused by workspace-lock contention.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@r-mennig r-mennig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes look so solid to me now. The only thing I've found is a behavior change we should keep in mind which could cause regressions in custom implementers.

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. Text editors, editors
that provide a text editor through an adapter and multi-page editors with a
text page for the matched file, like the plug-in manifest editor, select
the match directly, without a marker. A multi-page editor switches to the
page of the matched file, even when another of its pages was active. 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>
@fedejeanne
fedejeanne force-pushed the search-editoropener-lock-convoy branch from 8212ded to 5c92821 Compare November 26, 2026 14:20
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.

4 participants