Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSPCodeActionMarkerResolution.getResolutions freezes UI #894

Open
sebthom opened this issue Jan 14, 2024 · 2 comments
Open

LSPCodeActionMarkerResolution.getResolutions freezes UI #894

sebthom opened this issue Jan 14, 2024 · 2 comments

Comments

@sebthom
Copy link
Member

sebthom commented Jan 14, 2024

I'm trying to navigate through the sourcecode of a hello world nuxt.js example project in wildwebdevelopers (Eclipse 2023-12). Each file I open seems to freezes the Eclipse for ten or more seconds.

I took some threaddumps: org.eclipse.lsp4e.operations.codeactions.LSPCodeActionMarkerResolution.getResolutions blocks the UI because it waits for the language server(s) to start. Can this be made a non-blocking operation or return nothing if the servers are not yet ready?

Triggered via org.eclipse.jface.text.TextViewerHoverManager:

"main" #1 prio=6 os_prio=0 cpu=4625015.62ms elapsed=158140.50s tid=0x00000253601f75c0 nid=0x29ac waiting on condition  [0x000000e79efcd000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@17.0.9/Native Method)
        - parking to wait for  <0x000000077a2a2590> (a java.util.concurrent.CompletableFuture$Signaller)
        at java.util.concurrent.locks.LockSupport.parkNanos(java.base@17.0.9/LockSupport.java:252)
        at java.util.concurrent.CompletableFuture$Signaller.block(java.base@17.0.9/CompletableFuture.java:1866)
        at java.util.concurrent.ForkJoinPool.unmanagedBlock(java.base@17.0.9/ForkJoinPool.java:3465)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@17.0.9/ForkJoinPool.java:3436)
        at java.util.concurrent.CompletableFuture.timedGet(java.base@17.0.9/CompletableFuture.java:1939)
        at java.util.concurrent.CompletableFuture.get(java.base@17.0.9/CompletableFuture.java:2095)
        at org.eclipse.lsp4e.LanguageServerWrapper.getServerCapabilities(LanguageServerWrapper.java:835)
        at org.eclipse.lsp4e.LanguageServiceAccessor.capabilitiesComply(LanguageServiceAccessor.java:205)
        at org.eclipse.lsp4e.LanguageServiceAccessor.getStartedWrappers(LanguageServiceAccessor.java:415)
        at org.eclipse.lsp4e.LanguageServers$LanguageServerProjectExecutor.getServers(LanguageServers.java:340)
        at org.eclipse.lsp4e.LanguageServers.anyMatching(LanguageServers.java:246)
        at org.eclipse.lsp4e.operations.codeactions.LSPCodeActionMarkerResolution.checkMarkerResolution(LSPCodeActionMarkerResolution.java:130)
        at org.eclipse.lsp4e.operations.codeactions.LSPCodeActionMarkerResolution.getResolutions(LSPCodeActionMarkerResolution.java:101)
        at org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry.getResolutions(MarkerHelpRegistry.java:394)
        at org.eclipse.ui.internal.genericeditor.markers.MarkerInformationControl.setInput(MarkerInformationControl.java:107)
        at org.eclipse.ui.internal.genericeditor.hover.CompositeInformationControl.setInput(CompositeInformationControl.java:76)
        at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1151)
        at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1120)
        at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:884)
        at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:237)
        at org.eclipse.jface.text.TextViewerHoverManager.lambda$3(TextViewerHoverManager.java:227)
        at org.eclipse.jface.text.TextViewerHoverManager$$Lambda$2225/0x00000007c145f3e8.run(Unknown Source)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
        - locked <0x000000077a35c230> (a org.eclipse.swt.widgets.RunnableLock)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4046)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3662)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
        at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:648)
        at org.eclipse.ui.internal.Workbench$$Lambda$362/0x00000007c0316750.run(Unknown Source)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:555)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@17.0.9/Native Method)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@17.0.9/NativeMethodAccessorImpl.java:77)
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@17.0.9/DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(java.base@17.0.9/Method.java:568)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1459)

Triggered via org.eclipse.ui.internal.views.markers.MarkersTreeViewer.doUpdateItem:

"main" #1 prio=6 os_prio=0 cpu=4634046.88ms elapsed=158226.94s tid=0x00000253601f75c0 nid=0x29ac waiting on condition  [0x000000e79efcd000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@17.0.9/Native Method)
        - parking to wait for  <0x0000000791027a70> (a java.util.concurrent.CompletableFuture$Signaller)
        at java.util.concurrent.locks.LockSupport.parkNanos(java.base@17.0.9/LockSupport.java:252)
        at java.util.concurrent.CompletableFuture$Signaller.block(java.base@17.0.9/CompletableFuture.java:1866)
        at java.util.concurrent.ForkJoinPool.unmanagedBlock(java.base@17.0.9/ForkJoinPool.java:3465)
        at java.util.concurrent.ForkJoinPool.managedBlock(java.base@17.0.9/ForkJoinPool.java:3436)
        at java.util.concurrent.CompletableFuture.timedGet(java.base@17.0.9/CompletableFuture.java:1939)
        at java.util.concurrent.CompletableFuture.get(java.base@17.0.9/CompletableFuture.java:2095)
        at org.eclipse.lsp4e.LanguageServerWrapper.getServerCapabilities(LanguageServerWrapper.java:835)
        at org.eclipse.lsp4e.LanguageServiceAccessor.capabilitiesComply(LanguageServiceAccessor.java:205)
        at org.eclipse.lsp4e.LanguageServiceAccessor.getStartedWrappers(LanguageServiceAccessor.java:415)
        at org.eclipse.lsp4e.LanguageServers$LanguageServerProjectExecutor.getServers(LanguageServers.java:340)
        at org.eclipse.lsp4e.LanguageServers.anyMatching(LanguageServers.java:246)
        at org.eclipse.lsp4e.operations.codeactions.LSPCodeActionMarkerResolution.checkMarkerResolution(LSPCodeActionMarkerResolution.java:130)
        at org.eclipse.lsp4e.operations.codeactions.LSPCodeActionMarkerResolution.hasResolutions(LSPCodeActionMarkerResolution.java:208)
        at org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry.hasResolution(MarkerHelpRegistry.java:264)
        at org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry.hasResolutions(MarkerHelpRegistry.java:234)
        at org.eclipse.ui.views.markers.MarkerField.annotateImage(MarkerField.java:87)
        at org.eclipse.ui.internal.views.markers.MarkerProblemSeverityAndMessageField.update(MarkerProblemSeverityAndMessageField.java:80)
        at org.eclipse.ui.internal.views.markers.MarkerColumnLabelProvider.update(MarkerColumnLabelProvider.java:57)
        at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:146)
        at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:983)
        at org.eclipse.ui.internal.views.markers.MarkersTreeViewer.doUpdateItem(MarkersTreeViewer.java:70)
        at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:130)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
        at org.eclipse.ui.internal.JFaceUtil$$Lambda$242/0x00000007c02f6c40.run(Unknown Source)
        at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174)
        at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:1058)
        at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:427)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
        at org.eclipse.ui.internal.JFaceUtil$$Lambda$242/0x00000007c02f6c40.run(Unknown Source)
        at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174)
        at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2116)
        at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:877)
        at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:855)
        at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:615)
        at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1838)
        at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1154)
        at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1126)
        at org.eclipse.ui.internal.views.markers.ExtendedMarkersView.reexpandCategories(ExtendedMarkersView.java:1211)
        at org.eclipse.ui.internal.views.markers.UIUpdateJob.runInUIThread(UIUpdateJob.java:106)
        at org.eclipse.ui.progress.UIJob.lambda$0(UIJob.java:148)
        at org.eclipse.ui.progress.UIJob$$Lambda$1036/0x00000007c0b52630.run(Unknown Source)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
        - locked <0x0000000791c503b8> (a org.eclipse.swt.widgets.RunnableLock)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4046)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3662)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
        at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:648)
        at org.eclipse.ui.internal.Workbench$$Lambda$362/0x00000007c0316750.run(Unknown Source)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:555)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@17.0.9/Native Method)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@17.0.9/NativeMethodAccessorImpl.java:77)
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@17.0.9/DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(java.base@17.0.9/Method.java:568)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
@sebthom
Copy link
Member Author

sebthom commented Jan 14, 2024

The underlying issue seems to be the blocking call getInitializedServer().get(10, TimeUnit.SECONDS) on the UI thread through this chain when opening a source file:

org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation() or
org.eclipse.ui.internal.views.markers.MarkersTreeViewer.doUpdateItem()
-> LSPCodeActionMarkerResolution.checkMarkerResolution()
   -> LanguageServerProjectExecutor.withCapability(ServerCapabilities::getCodeActionProvider).anyMatching()
      -> LanguageServerProjectExecutor.getServers()
         -> LanguageServiceAccessor.getStartedWrappers()
            -> ...capabilitiesComply(ServerCapabilities::getCodeActionProvider)
               -> LanguageServerWrapper.getServerCapabilities()
                  -> ...getInitializedServer().get(10, TimeUnit.SECONDS);

I think in case of LSPCodeActionMarkerResolution the LanguageServerProjectExecutor.anyMatching() call should only match already initialized servers and not wait for just started servers still initializing.


This also means that the following javadoc statement for LanguageServerProjectExecutor.anyMatching() is currently not true, as it waits for a fully initialized server (and btw. even if LanguageServerProjectExecutor.excludeInactive() was specified):

	/**
	 *  Waits if necessary for at most 50 milliseconds for getting a server...
	 */
	public boolean anyMatching() {
		return getServers().stream().filter(this::matches).findFirst().isPresent();
	}

@mickaelistria
Copy link
Contributor

I think in case of LSPCodeActionMarkerResolution the LanguageServerProjectExecutor.anyMatching() call should only match already initialized servers and not wait for just started servers still initializing.

I think it makes sense to implement things as you're suggesting here.

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

No branches or pull requests

2 participants