flutter / flutter-intellij

Flutter Plugin for IntelliJ
https://flutter.dev/using-ide
BSD 3-Clause "New" or "Revised" License
1.98k stars 318 forks source link

Open project dialog hangs indefinitely with Flutter IntellIj plugin enabled #4979

Closed mikeryder closed 4 years ago

mikeryder commented 4 years ago

Steps to Reproduce

  1. Enable Flutter Intellij plugin (Restart)
  2. Press "File" -> "Open"

Version info

[√] Flutter (Channel beta, 1.20.2, on Microsoft Windows [Version 10.0.19041.572], locale en-US) • Flutter version 1.20.2 at c:\Utils\flutter • Framework revision bbfbf1770c (10 weeks ago), 2020-08-13 08:33:09 -0700 • Engine revision 9d5b21729f • Dart version 2.9.1

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at C:\Users\Mike\AppData\Local\Android\sdk • Platform android-29, build-tools 28.0.3 • Java binary at: C:\Program Files\Java\jdk-13.0.1\bin\java.exe • Java version Java(TM) SE Runtime Environment (build 13.0.1+9) X Android license status unknown. Try re-installing or updating your Android SDK Manager. See https://developer.android.com/studio/#downloads or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

[√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] IntelliJ IDEA Ultimate Edition (version 2019.3) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2018.2 • Flutter plugin version 45.1.2 • Dart plugin version 193.6911.31

[√] VS Code (version 1.48.0) • VS Code at C:\Users\Mike\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.13.2

[√] Connected device (3 available) • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.75 • Edge (web) • edge • web-javascript • Microsoft Edge 86.0.622.38

Here is the excerpt from idea.log when the hang occurred:

2020-10-19 10:15:15,550 [ 32766] ERROR - til.concurrency.QueueProcessor - java.lang.AssertionError java.lang.RuntimeException: java.lang.AssertionError at com.intellij.ide.util.treeView.AbstractTreeUi$50$1.perform(AbstractTreeUi.java:3386) at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:20) at com.intellij.ide.util.treeView.AbstractTreeBuilder$2.perform(AbstractTreeBuilder.java:391) at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:20) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:840) at com.intellij.ide.util.treeView.AbstractTreeBuilder.runBackgroundLoading(AbstractTreeBuilder.java:388) at com.intellij.ide.util.treeView.AbstractTreeUi$50.perform(AbstractTreeUi.java:3341) at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:20) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:170) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:629) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:581) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:157) at com.intellij.ide.util.treeView.AbstractTreeUi$51.perform(AbstractTreeUi.java:3403) at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:20) at com.intellij.ide.util.treeView.AbstractTreeUi.lambda$new$0(AbstractTreeUi.java:96) at com.intellij.util.concurrency.QueueProcessor.lambda$wrappingProcessor$0(QueueProcessor.java:81) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.concurrency.QueueProcessor.lambda$wrappingProcessor$1(QueueProcessor.java:81) at com.intellij.util.concurrency.QueueProcessor.lambda$startProcessing$3(QueueProcessor.java:214) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.concurrency.QueueProcessor.lambda$startProcessing$4(QueueProcessor.java:214) at com.intellij.util.RunnableCallable.call(RunnableCallable.java:20) at com.intellij.util.RunnableCallable.call(RunnableCallable.java:11) at com.intellij.openapi.application.impl.ApplicationImpl$1.call(ApplicationImpl.java:268) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 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) Caused by: java.lang.AssertionError at io.flutter.pub.PubRoot.(PubRoot.java:41) at io.flutter.pub.PubRoot.forDirectory(PubRoot.java:146) at io.flutter.project.FlutterProjectOpenProcessor.canOpenProject(FlutterProjectOpenProcessor.java:54) at com.intellij.projectImport.ProjectOpenProcessor.lambda$getImportProvider$0(ProjectOpenProcessor.java:88) at com.intellij.openapi.extensions.impl.ExtensionProcessingHelper.lambda$findFirstSafe$0(ExtensionProcessingHelper.java:45) at com.intellij.openapi.extensions.impl.ExtensionProcessingHelper.computeSafeIfAny(ExtensionProcessingHelper.java:55) at com.intellij.openapi.extensions.impl.ExtensionProcessingHelper.findFirstSafe(ExtensionProcessingHelper.java:45) at com.intellij.openapi.extensions.ExtensionPointName.findFirstSafe(ExtensionPointName.java:53) at com.intellij.projectImport.ProjectOpenProcessor.getImportProvider(ProjectOpenProcessor.java:87) at com.intellij.projectImport.ProjectOpenProcessor.getImportProvider(ProjectOpenProcessor.java:79) at com.intellij.ide.actions.OpenProjectFileChooserDescriptor.getImporterIcon(OpenProjectFileChooserDescriptor.java:76) at com.intellij.ide.actions.OpenProjectFileChooserDescriptor.getIcon(OpenProjectFileChooserDescriptor.java:50) at com.intellij.openapi.fileChooser.impl.FileTreeStructure.createDescriptor(FileTreeStructure.java:174) at com.intellij.ide.util.treeView.AbstractTreeUi$40.perform(AbstractTreeUi.java:2672) at com.intellij.ide.util.treeView.TreeRunnable.run(TreeRunnable.java:20) at com.intellij.ide.util.treeView.AbstractTreeUi.execute(AbstractTreeUi.java:1828) at com.intellij.ide.util.treeView.AbstractTreeUi.access$2600(AbstractTreeUi.java:56) at com.intellij.ide.util.treeView.AbstractTreeUi$50$1.perform(AbstractTreeUi.java:3350) ... 32 more 2020-10-19 10:15:15,552 [ 32768] ERROR - til.concurrency.QueueProcessor - IntelliJ IDEA 2020.2.3 Build #IU-202.7660.26 2020-10-19 10:15:15,552 [ 32768] ERROR - til.concurrency.QueueProcessor - JDK: 11.0.8; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o. 2020-10-19 10:15:15,552 [ 32768] ERROR - til.concurrency.QueueProcessor - OS: Windows 10 2020-10-19 10:15:15,552 [ 32768] ERROR - til.concurrency.QueueProcessor - Plugin to blame: Flutter version: 50.0 2020-10-19 10:15:15,552 [ 32768] ERROR - til.concurrency.QueueProcessor - Last Action: OpenFile

stevemessick commented 4 years ago

@alexander-doroshko Can you think of a way the assertion in the PubRoot constructor could fail? I just stepped into the code and it looks like there will never be a slash at the end of the path. But I'm using a Mac; it looks like generic code but I suppose it could be different on Windows. (Note the flutter doctor --verbose output is all wrong. The log has correct versions.)

alexander-doroshko commented 4 years ago

@stevemessick Well, trailing slash is used if FsRoot and CoreJarVirtualFile but I don't know for sure if any of them can reach PubRoot constructor via the provided stack. Normal folders don't have trailing slashes in their paths.

stevemessick commented 4 years ago

Thanks, Alex!

@mikeryder It looks like you have IntelliJ installed in two places and flutter doctor is only finding the old one.

From the stack trace, it seems you selected a file to open. What was your selection? A screen shot of the file picker would be great. Can you open a different project

alexander-doroshko commented 4 years ago

From the stack trace, it seems you selected a file to open.

I think the stack trace says that File Chooser was rendering its tree nodes (files/folders) and failed to calculate an icon for one or more of them. I tried to reproduce it by having a zip file with pubspec inside but I failed (zips are not shown in this file chooser for me). Still I believe that the path that caused that exception was like ...foo/bar.zip!/ or ...foo/bar.jar!/.

@mikeryder Any hints to reproduce would be appreciated.

mikeryder commented 4 years ago

@alexander-doroshko For me to reproduce, I only need to enable the Flutter IntelliJ plugin and click File->Open.

This is what the dialog looks like hung:

image

If I disable the Flutter plugin and restart IntelliJ, the dialog opens immediately:

image

mikeryder commented 4 years ago

Thanks, Alex!

@mikeryder It looks like you have IntelliJ installed in two places and flutter doctor is only finding the old one.

From the stack trace, it seems you selected a file to open. What was your selection? A screen shot of the file picker would be great. Can you open a different project

I have IntelliJ 2020.2 (despite what the output of flutter doctor shows) and several other Jetbrains IDEs (Datagrip, Android Studio, PHPStorm).

What pops up in the dialog is whatever I opened last in that window. As you can see from the screen shots in my last post, there was a folder selected initially. I am able to cause it to hang if the dialog opens to a different starting folder.

alexander-doroshko commented 4 years ago

@mikeryder Thanks for the screenshots! We know how to fix the issue but unfortunately we still have not been able to reproduce it or to understand the root cause.

The exception says that there's some node in the dialog that ends with slash. Slash is not allowed as a part of a folder name but IntelliJ may use trailing slash for internal representation of, for example, roots of zip files. The visible area of the file system on your screenshot doesn't contain anything suspicious. Maybe there's something unusual in the file system tree if you scroll up/down in the file chooser?

I'm just curious. You don't have to dig deeper, we can fix the exception with the information that we already have. But understanding the root cause may allow us to make a better fix.

alexander-doroshko commented 4 years ago

@mikeryder @stevemessick I managed to reproduce it! Just place a file with pubspec.yaml name to the root of a Windows drive. Pubspec's parent folder will have name like "C:/" in IntelliJ's file system! :)

I've verified that it's fixed now.

stevemessick commented 4 years ago

@alexander-doroshko Thanks for checking!