Skip to content

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

Closed

Description

@eddiesTime

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!

Activity

  1. added a commit that references this issue on Feb 22, 2022
    d2f5d2a
  2. added
    in debuggingRelates to the debug adapter or process of running debug sessions
    in flutterRelates to running Flutter apps
    on Feb 22, 2022
  3. added this to the v3.36.0 milestone on Feb 22, 2022
  4. DanTup commented on Feb 22, 2022

    @DanTup
    Member

    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.

  5. 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[/+] on Feb 22, 2022
  6. DanTup commented on Feb 22, 2022

    @DanTup
    Member

    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!

  7. eddiesTime commented on Mar 7, 2022

    @eddiesTime
    Author

    Sorry for the late response =/

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

  8. DanTup commented on Mar 7, 2022

    @DanTup
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsin flutterRelates to running Flutter appsis bugis performance

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions