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

Can not set a breakpoint on an if statement with only a boolean variable in DevTools #3289

Closed
jsroest opened this issue Aug 18, 2021 · 4 comments
Assignees

Comments

@jsroest
Copy link

jsroest commented Aug 18, 2021

It is not possible to set a breakpoint on an if statement with only a boolean variable.

image

Android Studio lets you set a breakpoint, but it will not get hit the first time. The second time the breakpoint is passed, it breaks a few lines further in the code.

DevTools does not allow to set a breakpoint.

Especially with Android Studio, this is confusing, because it looks like the code where the breakpoint is, is not executed.

I suggests two fixes:

  • Do not allow to set a breakpoint in Android Studio where it is also not allowed in DevTools (to be consistent and clear to the developer).
  • Allow to set a breakpoint on an if statement with just a variable like the example.

Sample project can be found here:
https://github.com/jsroest/breakpoint_bug

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-x64, locale en-NL)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.56.2)
[✓] Connected device (2 available)

Sample here in Android Studio:
The breakpoint is skipped on the first button press and hits somewhere below on the second button press.

  1. Hot restart
  2. Press Floating Action Button
  3. One of the breakpoints is not hit
  4. Press Floating Action Button
  5. The app breaks a few lines below the breakpoint
Screen.Recording.2021-08-18.at.11.53.47.mov

Related issues:
flutter/flutter#88306
flutter/flutter#81051 (comment)

@jsroest
Copy link
Author

jsroest commented Sep 13, 2021

Hi @kenzieschmoll,

I would like to ask your attention to this issue. I filled the issue 26 days ago and it seems to get lost or forgotten.

At this point, I experienced this issue above again while debugging my own code and thought that it might be a good idea to write this reminder.

Thanks.
Sander

@kenzieschmoll
Copy link
Member

@bkonyi looks like we are grabbing the breakable positions here:

Future<List<SourcePosition>> _getBreakablePositions(Script script) async {
. Any idea why the case described above wouldn't be showing up in the list of breakable lines?

@bkonyi
Copy link
Contributor

bkonyi commented Sep 13, 2021

It looks like we're missing a DebugStepCheck in cases where we're not invoking a function as part of evaluating the condition (the 3 working cases described in the issue all invoke either a getter, operator==, or both, which will all insert DebugStepChecks). This should just need a simple fix in the flow graph builder in the VM.

@bkonyi bkonyi self-assigned this Sep 13, 2021
dart-bot pushed a commit to dart-lang/sdk that referenced this issue Sep 16, 2021
with simple boolean conditions

Fixes flutter/devtools#3289

TEST=runtime/observatory/tests/service/breakpoint_on_simple_conditions_test.dart

Change-Id: I5ed0b78b4e462615d0d0c7dff1581b38dcf00aee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213421
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
@bkonyi
Copy link
Contributor

bkonyi commented Sep 16, 2021

Fixed in dart-lang/sdk@c51f885.

@bkonyi bkonyi closed this as completed Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants