You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flutter App runs more slowly in Profile mode through the VS Code debugger compared to the terminal #3838
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.
Click on clone the repository and set it up locally
Connect a physical device to the computer
Use the launch.json profile config to run the app.
Tap the button, run the crypto tasks and take note of the output
Stop the app and start it with flutter run --profile
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
Terminal output running the app flutter run --profile
Crypto performance results of config run
Crypto performance results of flutter run --profile
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!
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.
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
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:
Please let me know if you still see any differences. Thanks!
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!).
Activity
Disable debugging/don't use --pause-start in profile mode
DanTup commentedon 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-pausedflag 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-pausedfor profile which should resolve the issue.[-]Significant performance loss using launch.json[/-][+]Flutter App runs more slowly in Profile mode through the VS Code debugger compared to the terminal[/+]DanTup commentedon 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:
Please let me know if you still see any differences. Thanks!
eddiesTime commentedon Mar 7, 2022
Sorry for the late response =/
It works like a charm! Thank you very much for the quick response and implementation from your side.
DanTup commentedon 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!).