Skip to content

Add reflection utility to fix split debugger error#8878

Merged
auto-submit[bot] merged 8 commits into
flutter:mainfrom
helin24:split-debugging-recursion
Apr 1, 2026
Merged

Add reflection utility to fix split debugger error#8878
auto-submit[bot] merged 8 commits into
flutter:mainfrom
helin24:split-debugging-recursion

Conversation

@helin24
Copy link
Copy Markdown
Member

@helin24 helin24 commented Mar 31, 2026

Fixes #8831

There is an API change somewhere in 2025.3 which causes the error to be thrown during debugging.

I considered making this a separate plugin branch in #8877.

To test this change in IntelliJ IDEA 2026.1:

  • Debug an app
  • Debug a test
  • Attach an app (Run menu > Flutter Attach, then start the app on device)
  • I don't have a way to test bazel code. It should probably be removed.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces FlutterDebugSessionUtils, a utility class that uses reflection to manage debug session starts, ensuring compatibility across different IntelliJ Platform versions. Several launch and test runner classes have been refactored to use this utility. Feedback focuses on improving the utility class by reducing code duplication and method length, caching reflection Method objects for performance, and refining exception handling to properly unwrap InvocationTargetException for better error reporting.

Comment thread src/io/flutter/run/FlutterDebugSessionUtils.java Outdated
Comment thread src/io/flutter/run/FlutterDebugSessionUtils.java Outdated
Comment thread src/io/flutter/run/FlutterDebugSessionUtils.java
@helin24 helin24 force-pushed the split-debugging-recursion branch from deae97d to 6cfea4e Compare March 31, 2026 22:20
@helin24 helin24 marked this pull request as ready for review March 31, 2026 22:20
@helin24 helin24 requested a review from pq March 31, 2026 22:22
@pq
Copy link
Copy Markdown
Collaborator

pq commented Mar 31, 2026

Comment thread src/io/flutter/run/FlutterDebugSessionUtils.java
Comment thread src/io/flutter/run/FlutterDebugSessionUtils.java
@helin24 helin24 added autosubmit When this label is applied to a PR, the PR will be submitted as soon as all checks are green. 🤖 AI-assisted labels Mar 31, 2026
@auto-submit auto-submit Bot merged commit 76d8e58 into flutter:main Apr 1, 2026
8 checks passed
@helin24 helin24 deleted the split-debugging-recursion branch April 1, 2026 15:39
auto-submit Bot pushed a commit that referenced this pull request May 4, 2026
## Summary

- restore device-qualified Run/Debug tab titles on the newer IntelliJ split-debugger path
- keep the existing descriptor mutation as a fallback for the older path
- add a regression test that fails loudly if the reflective builder hooks disappear again

Fixes #8907.

## Problem

#8796 fixed the original `RunContentDescriptor.setDisplayName()` regression, but Blasko reported that plain IntelliJ still lost device labels while Android Studio worked:

- #8795 (comment)

The later split-debugger helper from #8878 moved newer IntelliJ builds onto `XDebuggerManager.newSessionBuilder()`, but that path never seeded the builder with the device-qualified session title. On split-debugger builds the visible tab title is derived from the builder configuration rather than the later descriptor mutation alone, so IntelliJ could regress while Android Studio stayed fine.

## Fix

Pass the device-qualified title through `LaunchState` and `AttachState` into `FlutterDebugSessionUtils`, then configure the builder with:

- `sessionName(...)`
- `showTab(true)`
- `contentToReuse(...)`

before `startSession()` runs.

The existing `RunContentDescriptor.setDisplayName()` reflection stays in place as a fallback for the older path.

## Tests

- `./gradlew compileJava --console=plain`
- `./gradlew test --tests io.flutter.run.LaunchStateTest --tests io.flutter.run.FlutterDebugSessionUtilsTest --console=plain`

Manually tested and did indeed verify, the labels are back once again with this fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit When this label is applied to a PR, the PR will be submitted as soon as all checks are green.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error during debug application for IDEA 2026.1

2 participants