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

Flutter App runs more slowly in Profile mode through the VS Code debugger compared to the terminal #3838

Closed
eddiesTime opened this issue Feb 19, 2022 · 4 comments
Labels
in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is bug is performance
Milestone

Comments

@eddiesTime
Copy link

Describe the bug
We've discovered during our work on RSA encryption that there are significant performance differences when running the app in profile mode via launch.json configuration compared to executing flutter run --profile in the terminal. It seems to us, that the IDE (VS Code) and the app believe they are in profile mode, device does not and restricts the performance as in debug mode.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/eddiesTime/profile_bug_example
  2. Click on clone the repository and set it up locally
  3. Connect a physical device to the computer
  4. Use the launch.json profile config to run the app.
  5. Tap the button, run the crypto tasks and take note of the output
  6. Stop the app and start it with flutter run --profile
  7. Repeat step 5

Expected behavior
Regardless of starting the app with the launch.config or the terminal command, the performance should be the same.

Screenshots

Debug console output running the app via launch.config

Screenshot 2022-02-19 at 17 42 42

Terminal output running the app flutter run --profile

Screenshot 2022-02-19 at 17 51 43

Crypto performance results of config run

IMG_1156

Crypto performance results of flutter run --profile

IMG_1157

Versions (please complete the following information):

  • VS Code version: Version: 1.64.2 (Universal)
    Commit: f80445acd5a3dadef24aa209168452a3d97cc326
  • Dart extension version: v3.34.0
  • Dart/Flutter SDK version: Dart SDK version: 2.16.0 (stable) (Mon Jan 31 15:28:59 2022 +0100) on "macos_x64"
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.0, on macOS 11.5.1 20G80 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.64.2)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

• No issues found!
@DanTup DanTup added in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is performance labels Feb 22, 2022
@DanTup DanTup added this to the v3.36.0 milestone Feb 22, 2022
@DanTup
Copy link
Member

DanTup commented Feb 22, 2022

Thanks for the detailed info + repro!

It turns out the code wasn't running any slower, but we were running with the --start-paused flag in Profile mode. This is used in debug mode to ensure we can send breakpoints before the app (or any new isolates) start running to avoid race conditions between setting breakpoints and executing code at startup.

We'd previously considered "connecting to the VM Service" and "running in debug mode" to be mostly the same thing, but that means in profile mode if you spawn any new isolates, they would start paused and then be unpaused by the debugger - which adds a short delay.

I'm testing a change to not use --start-paused for profile which should resolve the issue.

@DanTup DanTup changed the title Significant performance loss using launch.json Flutter App runs more slowly in Profile mode through the VS Code debugger compared to the terminal Feb 22, 2022
@DanTup DanTup closed this as completed in d2f5d2a Feb 22, 2022
@DanTup
Copy link
Member

DanTup commented Feb 22, 2022

The fix is available in the pre-release channels if you want access to it before the next stable release. You can switch to them in VS Code from the Extensions section:

image

Screenshot 2022-02-22 at 15 17 10

Please let me know if you still see any differences. Thanks!

@eddiesTime
Copy link
Author

Sorry for the late response =/

It works like a charm! Thank you very much for the quick response and implementation from your side.

@DanTup
Copy link
Member

DanTup commented Mar 7, 2022

np! Thanks for highlighting the issue!

In case you didn't notice, the fix shipped in a stable release so there's no need to use the pre-release channel now (although, all testing and feedback from pre-release uses is appreciated!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps is bug is performance
Projects
None yet
Development

No branches or pull requests

2 participants