How can I avoid the Kotlin plugin crashing all day...
# intellij
d
How can I avoid the Kotlin plugin crashing all day long? Are there any ceremonial sacrifices that needs to be done?
a
Can you please report an issue to http://kotl.in/issue with at least the full IDE logs, so we can investigate the problem?
d
I'm clicking submit to jetbrains every time the IDEA notices an exception in the plugin.
a
Right, but these reports are processed semi-automatically, clustered into groups, etc. Also, we might need additional information (for example, from your logs) to properly diagnose the problem).
d
Lets see what I have in the bag atm....
Copy code
java.lang.StackOverflowError
	at com.intellij.psi.impl.source.codeStyle.JavaIndentHelper.getIndentInner(JavaIndentHelper.java:48)
	at com.intellij.psi.impl.source.codeStyle.JavaIndentHelper.getIndentInner(JavaIndentHelper.java:100)
	at com.intellij.psi.impl.source.codeStyle.JavaIndentHelper.getIndentInner(JavaIndentHelper.java:93)
	at com.intellij.psi.impl.source.codeStyle.JavaIndentHelper.getIndentInner(JavaIndentHelper.java:93)
	at com.intellij.psi.impl.source.codeStyle.JavaIndentHelper.getIndentInner(JavaIndentHelper.java:100)

java.lang.RuntimeException: com.intellij.psi.PsiInvalidElementAccessException: Element class com.intellij.psi.impl.source.tree.java.ImportListElement of type IMPORT_LIST (class com.intellij.psi.impl.java.stubs.JavaImportListElementType)
	at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:149)
	at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:477)
	at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:482)
	at org.jetbrains.kotlin.idea.conversion.copy.PlainTextPasteImportResolver$tryResolveReferences$task$1$1.invoke(PlainTextPasteImportResolver.kt:145)
	at org.jetbrains.kotlin.idea.conversion.copy.PlainTextPasteImportResolver$tryResolveReferences$task$1$2.invoke(PlainTextPasteImportResolver.kt:172)
	at org.jetbrains.kotlin.idea.conversion.copy.PlainTextPasteImportResolver$tryResolveReferences$task$1.invoke(PlainTextPasteImportResolver.kt:224)
	at org.jetbrains.kotlin.idea.conversion.copy.PlainTextPasteImportResolver$tryResolveReferences$task$1.invoke(PlainTextPasteImportResolver.kt:43)
	at org.jetbrains.kotlin.idea.conversion.copy.PlainTextPasteImportResolver$sam$java_lang_Runnable$0.run(PlainTextPasteImportResolver.kt)
	at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:304)
	at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:962)
	at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:520)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$new$0(ProgressRunner.java:80)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:236)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:62)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:236)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:834)

com.intellij.psi.PsiInvalidElementAccessException: Element class com.intellij.psi.impl.source.tree.CompositeElement of type PROPERTY (class org.jetbrains.kotlin.psi.stubs.elements.KtPropertyElementType)
	at com.intellij.psi.PsiInvalidElementAccessException.createByNode(PsiInvalidElementAccessException.java:80)
	at com.intellij.psi.impl.source.SubstrateRef$2.getContainingFile(SubstrateRef.java:101)
	at com.intellij.extapi.psi.StubBasedPsiElementBase.getContainingFile(StubBasedPsiElementBase.java:239)
	at com.intellij.extapi.psi.StubBasedPsiElementBase.getProject(StubBasedPsiElementBase.java:277)
	at org.jetbrains.uast.kotlin.KotlinUastLanguagePlugin.isJvmElement(KotlinUastLanguagePlugin.kt:78)
	at org.jetbrains.uast.kotlin.KotlinUastLanguagePlugin.convertElementWithParent(KotlinUastLanguagePlugin.kt:88)
	at org.jetbrains.uast.UastFacade.convertElementWithParent(UastContext.kt:68)
	at org.jetbrains.uast.UastContextKt.toUElement(UastContext.kt:111)
	at org.jetbrains.uast.kotlin.KotlinInternalUastUtilsKt.getMaybeLightElement(kotlinInternalUastUtils.kt:527)
	at org.jetbrains.uast.kotlin.KotlinInternalUastUtilsKt.resolveToDeclaration(kotlinInternalUastUtils.kt:337)
	at org.jetbrains.uast.kotlin.KotlinInternalUastUtilsKt.resolveToDeclaration(kotlinInternalUastUtils.kt:330)
	at org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression$resolvedDeclaration$2.invoke(KotlinUSimpleReferenceExpression.kt:44)
	at org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression$resolvedDeclaration$2.invoke(KotlinUSimpleReferenceExpression.kt:40)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression.getResolvedDeclaration(KotlinUSimpleReferenceExpression.kt)
	at org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression.resolve(KotlinUSimpleReferenceExpression.kt:48)
	at com.intellij.codeInspection.i18n.TitleCapitalizationInspection.getTitleValue(TitleCapitalizationInspection.java:134)
	at com.intellij.codeInspection.i18n.TitleCapitalizationInspection$1.visitElement(TitleCapitalizationInspection.java:39)
	at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:62)
	at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:65)
	at com.intellij.codeInspection.InspectionEngine.createVisitorAndAcceptElements(InspectionEngine.java:56)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.runToolOnElements(LocalInspectionsPass.java:298)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$3(LocalInspectionsPass.java:267)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:156)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:148)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$4(LocalInspectionsPass.java:266)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:127)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:116)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$5(LocalInspectionsPass.java:266)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:136)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:149)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:149)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:149)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1138)
	at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:92)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:62)
	at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:104)
	at com.intellij.concurrency.ApplierCompleter.lambda$compute$0(ApplierCompleter.java:83)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:172)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:183)
	at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:83)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
and lots of variations of the latter one, for once it hasn't caused the editor to break down on me, other than being slow as usual.
l
@Daniel Svensson Alexey is asking for the
idea.log
files that you can reveal from the Help menu of the IDE (e.g. "Show log in Finder" on macOS). Better to put that in a proper issue with proper attachements instead of rendering that chat thread unreadable with super-long stacktraces
d
check... I'll do that next time it tips over.
But that's just half the problem. The crazy latency from opening a file until it's interactive does not always involve a boatload of exceptions. 😕
a
Thanks. * StackOverflowError from
getIndentInner
- not sure what that is. If you see this often and have an idea of how to reproduce - please report a bug to https://youtrack.jetbrains.com/issues/IDEA * PsiInvalidElementAccessException - these generally happen on specific actions (copy paste, some refactoring, quickfix, etc), so they should be reproducible. Again, please report a bug to http://kotl.in/issue with steps to reproduce if possible. Such problems can be hard to fix without sample code. About performance issues: it's generally ideal to report a bug according to https://youtrack.jetbrains.com/issue/KT-37700 (pay attention to the point about thread dumps and CPU snapshots). Usually this gives us a rough idea of how we can avoid a particular problem. However, many performance problems are inherently due to the quite slow Kotlin compiler, so workarounds in the IDE may be not possible. We are working on the completely new compiler though, it will be several times faster than the current compiler frontend. But I can't give any ETA on that.
d
1.4.20-M1 became available today, and initially it seems like a huge improvement.
Large test classes highlight within ~2-3 seconds on a fast computer.
The bug where all imports are smashed up on the same line still exists.
l
Can you link its corresponding issue?
d
Haven't managed to get youtrack filter out fixed issues, but I guess I could file an issue even if risking adding a duplicate.
l
You can search for "Unresolved" issues to filter out resolved ones, but note that this might not be what you want as an issue might be resolved but its fix not deployed yet.
d
Alright, all user experience of the issue poured down at least. Sounds like a horrible bug to troubleshoot.