Bug 476382 - UI freeze in SearchableEnvironment.findTypes
Summary: UI freeze in SearchableEnvironment.findTypes
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-01 15:19 EDT by Stefan Xenos CLA
Modified: 2022-05-24 20:04 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2015-09-01 15:19:52 EDT
One of our users has reported frequent UI freezes of up to a minute with the following stack trace (attached below). 

Looking through the code in question...

org.eclipse.jdt.internal.core.NameLookup.findAllTypes(NameLookup.java:328)

This seems to be doing an exhaustive search over all the packages.

org.eclipse.jdt.internal.core.NameLookup.seekTypesInBinaryPackage(NameLookup.java:1085)

That's doing an exhaustive search over all the class files in each package.

org.eclipse.jdt.internal.core.ClassFile.getBinaryTypeInfo(ClassFile.java:284)
        at 

That's opening each class file and unpacking some data from it.

The consequence is that JDT is exhaustively reading every single .class file in the project, in the UI thread. I also don't see it accessing the index at any point in that call chain.

Is there any way we can do any of the following?
- Speed this up
- Move it to a background thread
- Terminate the prefix search early if it takes excessively long and just skip offering suggestions.


        at java.util.zip.ZipFile.close(Native Method)
        at java.util.zip.ZipFile.close(ZipFile.java:648)
        at org.eclipse.jdt.internal.core.JavaModelManager.closeZipFile(JavaModelManager.java:1669)
        at org.eclipse.jdt.internal.core.ClassFile.getJarBinaryTypeInfo(ClassFile.java:376)
        at org.eclipse.jdt.internal.core.ClassFile.getBinaryTypeInfo(ClassFile.java:290)
        at org.eclipse.jdt.internal.core.ClassFile.getBinaryTypeInfo(ClassFile.java:284)
        at org.eclipse.jdt.internal.core.ClassFile.buildStructure(ClassFile.java:93)
        at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:259)
        at org.eclipse.jdt.internal.core.SourceRefElement.generateInfos(SourceRefElement.java:107)
        at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:579)
        at org.eclipse.jdt.internal.core.BinaryType.getElementInfo(BinaryType.java:287)
        at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:302)
        at org.eclipse.jdt.internal.core.BinaryType.getFlags(BinaryType.java:319)
        at org.eclipse.jdt.internal.core.SearchableEnvironmentRequestor.acceptType(SearchableEnvironmentRequestor.java:115)
        at org.eclipse.jdt.internal.core.NameLookup.seekTypesInBinaryPackage(NameLookup.java:1085)
        at org.eclipse.jdt.internal.core.NameLookup.seekTypes(NameLookup.java:1019)
        at org.eclipse.jdt.internal.core.NameLookup.seekTypes(NameLookup.java:962)
        at org.eclipse.jdt.internal.core.NameLookup.findAllTypes(NameLookup.java:328)
        at org.eclipse.jdt.internal.core.NameLookup.seekTypes(NameLookup.java:995)
        at org.eclipse.jdt.internal.core.NameLookup.seekTypes(NameLookup.java:962)
        at org.eclipse.jdt.internal.core.SearchableEnvironment.findTypes(SearchableEnvironment.java:641)
        at org.eclipse.jdt.internal.core.SearchableEnvironment.findTypes(SearchableEnvironment.java:474)
        at org.eclipse.jdt.internal.codeassist.CompletionEngine.findTypesAndPackages(CompletionEngine.java:10707)
        at org.eclipse.jdt.internal.codeassist.CompletionEngine.completionOnSingleNameReference(CompletionEngine.java:3306)
        at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1713)
        at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1939)
        at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:131)
        at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:357)
        at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:351)
        at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:339)
        at org.eclipse.jdt.internal.ui.text.correction.SimilarElementsRequestor.process(SimilarElementsRequestor.java:143)
        at org.eclipse.jdt.internal.ui.text.correction.SimilarElementsRequestor.findSimilarElement(SimilarElementsRequestor.java:90)
        at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.addSimilarTypeProposals(UnresolvedElementsSubProcessor.java:756)
        at org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor.getVariableProposals(UnresolvedElementsSubProcessor.java:274)
        at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:361)
        at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.getCorrections(QuickFixProcessor.java:316)
        at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:378)
        at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:339)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
        at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:335)
        at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:468)
        at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getJavaAnnotationFixes(ProblemHover.java:225)
        at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getCompletionProposals(ProblemHover.java:199)
        at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.deferredCreateContent(AbstractAnnotationHover.java:285)
        at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.setInput(AbstractAnnotationHover.java:186)
        at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1181)
        at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1150)
        at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:902)
        at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:243)
        at org.eclipse.jface.text.TextViewerHoverManager$5.run(TextViewerHoverManager.java:233)
Comment 1 Stefan Xenos CLA 2015-09-01 15:20:39 EDT
Possibly related to bug 414324 and bug 371555.
Comment 2 Jay Arthanareeswaran CLA 2015-09-04 01:11:04 EDT
Manoj, please advise what we want to do here.
Comment 3 Manoj N Palat CLA 2015-09-04 01:28:21 EDT
(In reply to Jay Arthanareeswaran from comment #2)
> Manoj, please advise what we want to do here.
Looking through the suggestions  - speedup is something which we(jdt.core) can look into (and may be a little long term) but the suggestion of spawning another thread from ui for this may be an immediate option. Noopur : is there any blocker for doing this from jdt.ui?
Comment 4 Noopur Gupta CLA 2015-09-10 07:45:16 EDT
(In reply to Manoj Palat from comment #3)
> (In reply to Jay Arthanareeswaran from comment #2)
> > Manoj, please advise what we want to do here.
> Looking through the suggestions  - speedup is something which we(jdt.core)
> can look into (and may be a little long term) but the suggestion of spawning
> another thread from ui for this may be an immediate option. Noopur : is
> there any blocker for doing this from jdt.ui?

We had a discussion about it in jdt.ui call. In this case, the jdt.core api is called when the quick fix is invoked (See stacktrace: org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:361)). Moving the call to a background thread is not a good solution in case of the quick fix and may also result in sync issues.
Comment 5 Eclipse Genie CLA 2020-05-31 12:12:34 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 6 Eclipse Genie CLA 2022-05-24 20:04:59 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.