Skip to content

Conversation

@jwren
Copy link
Member

@jwren jwren commented Jan 16, 2026

The custom FlutterStudioProjectOpenProcessor was causing hangs and crashes due to threading issues when delegating to the Platform's project opener in newer Android Studio versions.

This change:

  • Removes FlutterStudioProjectOpenProcessor entirely, allowing the robust standard Platform processor to handle project opening.
  • Moves the necessary Flutter configuration (setting module type, enabling Dart SDK) to FlutterStudioStartupActivity, ensuring it runs safely after startup.

Fixes #8661

This issue was identified by having the open project dialog not work on a valid flutter project, without a .idea directory:

flutter create flutter_no_idea && cd flutter_no_idea && rm -rf .idea

Flutter and Android Studio versions:

Flutter 3.41.0-1.0.pre-93 • channel [user-branch]
Framework • revision 5182dc0e89 (23 minutes ago) • 2026-01-16 15:27:15 -0800
Engine • hash 210577698f36ac84ce1c12e164f5024e23baf3fb (revision 3b7caba768) (2
days ago) • 2026-01-14 01:07:10.000Z
Tools • Dart 3.12.0 (build 3.12.0-17.0.dev) • DevTools 2.54.0
Android Studio Otter | 2025.2.1 Canary 5
Build #AI-252.25557.131.2521.14240541, built on October 9, 2025
Runtime version: 21.0.8+-14196175-b1038.72 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 15.7.3
Kotlin analyzer version: 2.2.255-dev-255
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 12
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
  gradle.phased.sync.enabled=true
Non-Bundled Plugins:
  Dart (252.25557.23)
  io.flutter (SNAPSHOT)

@jwren jwren requested a review from helin24 January 16, 2026 20:07
@jwren jwren added the 🤖 AI-assisted For PRs with significant code generated by AI label Jan 16, 2026
Copy link
Collaborator

@pq pq left a comment

Choose a reason for hiding this comment

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

Cool!

Do you have any insight into what was causing the hangs w/ the Kotlin-migrated code? Was it anything we could have noticed in a code review? (Do you recall if you used the IntelliJ tooling for the conversion BTW or was that Gemini?)

// Instead, we let the Platform open the project normally, and then apply our configuration here.
// This includes ensuring the module type is set to 'flutter' (for icons/facets) and enabling the Dart SDK.
// See https://github.com/flutter/flutter-intellij/issues/8661
for (com.intellij.openapi.module.Module module : FlutterModuleUtils.getModules(project)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you remove this qualified name by adding an import for com.intellij.openapi.module? (That seems generally preferred -- Gemini will confirm -- and is consistent with the rest of our codebase.)

Unless there's a conflict?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you update your prompt to do this in general?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't use the "finalize this code before review" prompt, but I should have. Yes, this is something we should add to the prompts.md file.

}

// Ensure Flutter project configuration is applied.
// This logic was previously in FlutterStudioProjectOpenProcessor. However, that processor
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is great. Thanks!

@pq
Copy link
Collaborator

pq commented Jan 16, 2026

Thinking ahead to automated, if not just manual testing, could you consider adding some notes about how this fix was verified and how we can be sure removing FlutterStudioProjectOpenProcessor doesn't cause any behavior regressions? (Or even just some notes on what to look out for?)

Thanks!

for (com.intellij.openapi.module.Module module : FlutterModuleUtils.getModules(project)) {
if (FlutterModuleUtils.declaresFlutter(module) && !FlutterModuleUtils.isFlutterModule(module)) {
ApplicationManager.getApplication().invokeLater(() -> {
ApplicationManager.getApplication().runWriteAction(() -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding logging here?

And maybe a note to add analytics when we have them?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@jwren
Copy link
Member Author

jwren commented Jan 16, 2026

Thinking ahead to automated, if not just manual testing, could you consider adding some notes about how this fix was verified and how we can be sure removing FlutterStudioProjectOpenProcessor doesn't cause any behavior regressions? (Or even just some notes on what to look out for?)

Thanks!

Updating the commit message.

…(projects with missing .idea directories)

The custom `FlutterStudioProjectOpenProcessor` was causing hangs and crashes due to threading issues when delegating to the Platform's project opener in newer Android Studio versions.
This change:
- Removes `FlutterStudioProjectOpenProcessor` entirely, allowing the robust standard Platform processor to handle project opening.
- Moves the necessary Flutter configuration (setting module type, enabling Dart SDK) to FlutterStudioStartupActivity, ensuring it runs safely after startup.

Fixes flutter#8661
@jwren jwren merged commit f61d7c7 into flutter:main Jan 17, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 AI-assisted For PRs with significant code generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flutter plugin failed opening some projects

3 participants