Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] Debug mode is paused when launched from IntelliJ/Android Studio #76680

Closed
Wissperwind opened this issue Feb 24, 2021 · 14 comments · Fixed by flutter/flutter-intellij#5286
Closed
Labels
a: debugging Debugging, breakpoints, expression evaluation c: regression It was better in the past than it is now d: intellij DevTools related - IntelliJ/flutter issues (most should be tracked in flutter/flutter-intellij) found in release: 1.26 Found to occur in 1.26 found in release: 1.27 Found to occur in 1.27 has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression platform-web Web applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@Wissperwind
Copy link

Wissperwind commented Feb 24, 2021

Hi,
I am developing a flutter web application using Android Studio.
I use the Chrome browser as my device.

If I press play, the website is launched and displayed by chrome.
But if I press debug, chrome displays only a white page. Even if I wait several minutes.
A workaround is to press the reload button once. After that my website is dislayed.

I don't know what code to include hence I can't include the whole project.

Anyone else facing this problems?

[√] Flutter (Channel beta, 1.26.0-17.3.pre, on Microsoft Windows [Version 10.0.19042.746], locale de-DE)
    • Flutter version 1.26.0-17.3.pre at C:\Users\akilian\Flutter SDK\flutter
    • Framework revision 4b50ca7f7f (3 weeks ago), 2021-02-04 19:44:27 -0800
    • Engine revision 2c527d6c7e
    • Dart version 2.12.0 (build 2.12.0-259.8.beta)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\akilian\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

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

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.52.1)
    • VS Code at C:\Users\akilian\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.182
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 88.0.705.56

! Doctor found issues in 1 category.

@TahaTesser TahaTesser added the in triage Presently being triaged by the triage team label Feb 24, 2021
@TahaTesser
Copy link
Member

TahaTesser commented Feb 24, 2021

Hi @Wissperwind
I can only see a white blank screen in Android Studio when running in debug mode on macOS and Windows, doesn't reproduce in VS Code or Terminal, reproducible on the beta, dev, and master, app launches in Android if you run without debug

Rethinking, this could be either intellij plugin or Flutter, I'm not sure so reopening the issue

Screenshot 2021-02-24 at 6 04 52 PM

flutter doctor -v
[✓] Flutter (Channel beta, 1.26.0-17.6.pre, on macOS 11.2.1 20D74 darwin-x64, locale en-GB)
    • Flutter version 1.26.0-17.6.pre at /Users/tahatesser/Code/flutter_beta
    • Framework revision a29104a69b (8 days ago), 2021-02-16 09:26:56 -0800
    • Engine revision 21fa8bb99e
    • Dart version 2.12.0 (build 2.12.0-259.12.beta)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.
[!] Xcode - develop for iOS and macOS
    • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0
[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.192
! Doctor found issues in 2 categories.
[✓] Flutter (Channel dev, 1.27.0-4.0.pre, on macOS 11.2.1 20D74 darwin-x64, locale en-GB)
    • Flutter version 1.27.0-4.0.pre at /Users/tahatesser/Code/flutter_dev
    • Framework revision f8cd24de95 (8 days ago), 2021-02-16 11:24:17 -0800
    • Engine revision 1d537824d6
    • Dart version 2.13.0 (build 2.13.0-30.0.dev)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.
[!] Xcode - develop for iOS and macOS
    • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0
[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.1 20D74 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 88.0.4324.192
! Doctor found issues in 2 categories.
[✓] Flutter (Channel master, 1.27.0-5.0.pre.134, on macOS 11.2.1 20D74 darwin-x64, locale en-GB)
    • Flutter version 1.27.0-5.0.pre.134 at /Users/tahatesser/Code/flutter_master
    • Framework revision 354bd53f62 (5 hours ago), 2021-02-24 02:36:05 -0500
    • Engine revision 9061823775
    • Dart version 2.13.0 (build 2.13.0-68.0.dev)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.
[!] Xcode - develop for iOS and macOS
    • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0
[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.1 20D74 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 88.0.4324.192
! Doctor found issues in 2 categories.

Thank you

@TahaTesser TahaTesser added the r: invalid Issue is closed as not valid label Feb 24, 2021
@TahaTesser TahaTesser reopened this Feb 24, 2021
@TahaTesser TahaTesser removed in triage Presently being triaged by the triage team r: invalid Issue is closed as not valid labels Feb 24, 2021
@TahaTesser TahaTesser added a: debugging Debugging, breakpoints, expression evaluation d: intellij DevTools related - IntelliJ/flutter issues (most should be tracked in flutter/flutter-intellij) found in release: 1.26 Found to occur in 1.26 found in release: 1.27 Found to occur in 1.27 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-web Web applications specifically c: regression It was better in the past than it is now tool Affects the "flutter" command-line tool. See also t: labels. labels Feb 24, 2021
@TahaTesser TahaTesser changed the title Flutter displays only a white page in debug mode [web] Debug mode is paused when launched IntelliJ/Android Studio Feb 24, 2021
@pedromassango
Copy link
Member

pedromassango commented Feb 24, 2021

As I mentioned in #76690, this is probably due to a crash. Sharing my logs here as my issue was close. I got those logs once you resume the debugger (that blue button above the webpage).

Running "flutter pub get" in app...
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
Debug service listening on ws://127.0.0.1:56126/1tWXqmQvm-Q=/ws

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Debug service listening on ws://127.0.0.1:56126/1tWXqmQvm-Q=/ws
Error: Unexpected null value.
    at Object.throw_ [as throw] (http://localhost:56000/dart_sdk.js:5347:11)
    at Object.nullCheck (http://localhost:56000/dart_sdk.js:5680:30)
    at _engine._PointerAdapter.new.[_getSanitizer] (http://localhost:56000/dart_sdk.js:166679:28)
    at http://localhost:56000/dart_sdk.js:166739:42
    at http://localhost:56000/dart_sdk.js:166697:16
    at http://localhost:56000/dart_sdk.js:166391:11
    at <anonymous>
    at http://localhost:56000/dart_sdk.js:50601:13
    at Generator.next (<anonymous>)
    at runBody (http://localhost:56000/dart_sdk.js:39187:34)
    at Object._async [as async] (http://localhost:56000/dart_sdk.js:39218:7)
    at http://localhost:56000/dart_sdk.js:50592:20
    at new Promise (<anonymous>)
    at Object._invokeExtension [as invokeExtension] (http://localhost:56000/dart_sdk.js:50589:12)
    at <anonymous>:1:31

@TahaTesser TahaTesser changed the title [web] Debug mode is paused when launched IntelliJ/Android Studio [web] Debug mode is paused when launched from IntelliJ/Android Studio Feb 24, 2021
@Wissperwind
Copy link
Author

Wissperwind commented Feb 24, 2021

I can confirm that chrome does not display my website in debug mode, because somehow the program is paused - I can press resume and my website appears perfectly debuggable, but in my case, no error is printed after I press resume.

@yjbanov
Copy link
Contributor

yjbanov commented Feb 24, 2021

Confirmed that this is happening in IntelliJ only. The app is launched in paused state and requires unpausing either by using the "play" icon in IntelliJ (I had to click it twice) or in Chrome DevTools.

flutter run -d chrome and VSCode work fine.

/cc @jacob314 @kenzieschmoll

@jacob314
Copy link
Contributor

@grouma
The expected behavior for VSCode and IntelliJ is that the app should start paused and then the IDE should resume it immediately. That enables setting breakpoints on startup, etc.
Most likely something is going wrong with DWDS indicating that the app is paused on startup so IntelliJ doesn't know it should resume. @DanTup did you do something to VSCode to not pause web apps on startup?

@DanTup
Copy link
Contributor

DanTup commented Feb 24, 2021

Nope, nothing special - it all seems to work in VS Code. Looking at the log, it looks like the isolate is already be paused at the start, and we trigger the resume based on its pauseEvent being a PauseStart.

As far as I can tell, there's no special handling for web here, it's all the same as for CLI.

@grouma
Copy link
Member

grouma commented Feb 24, 2021

@DanTup is correct. package:dwds doesn't handle this directly but instead exposes the necessary APIs to support pause on start. We expose an AppConnection which you can call runMain on.

It looks like Flutter Tools automatically calls runMain.

@jonahwilliams any thoughts here?

@grouma
Copy link
Member

grouma commented Feb 24, 2021

@jacob314 mentioned it may be due to the fact that Intellij expects a kPauseStart event. This is properly set when an Isolate is created in package:dwds here.

However, we don't emit this event. I'm not sure what the expected behavior is here but this likely could be the cause of the issue.

@DanTup
Copy link
Contributor

DanTup commented Feb 24, 2021

I think the comment there may be misleading, it only calls that if not starting paused:

// Always run main after connecting because start paused doesn't work yet.
if (!debuggingOptions.startPaused || !supportsServiceProtocol) {
_connectionResult.appConnection.runMain();

In VS Code, when we connect to the VM service, we:

  • subscribe to the debug streams to get pause events
  • fetch all existing isolates
  • process the pauseEvent on each isolate as if it arrived as a pause event

When we process a PauseStart event (whether it arrives in the stream, or was picked up on an existing isolate) we send breakpoints then call resume.

@yjbanov
Copy link
Contributor

yjbanov commented Feb 25, 2021

Retroactively categorizing as P2, just so we can make sure that the fix for this bug reaches users faster.

@Wissperwind
Copy link
Author

Wissperwind commented Mar 5, 2021

Is the fix already available? Or was it included in the last released version?
At the moment I have the problem again using Flutter (Channel beta, 2.0.0).

@helin24
Copy link
Member

helin24 commented Mar 5, 2021

@Wissperwind this change was included in v54 of the Flutter plugin. If that's the version you're using, maybe the issue we reproduced wasn't the same as yours despite having similar behavior. In that case, could you check if there's an error if you open up the Chrome inspector while it's on a blank screen?

@Wissperwind
Copy link
Author

No, it was my fault. You fixed the right bug. I didn't realize that a flutter update is not enough and I had to update the IDE Plugins.

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
@flutter-triage-bot flutter-triage-bot bot added P0 Critical issues such as a build break or regression and removed P2 labels Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: debugging Debugging, breakpoints, expression evaluation c: regression It was better in the past than it is now d: intellij DevTools related - IntelliJ/flutter issues (most should be tracked in flutter/flutter-intellij) found in release: 1.26 Found to occur in 1.26 found in release: 1.27 Found to occur in 1.27 has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression platform-web Web applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants