Skip to content

[dap] Don't wait for appStarted before responding to launch/attach + don't call app.stop for unstarted app - #109386

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
DanTup:dont-wait-launch
Aug 25, 2022
Merged

auto-submit[bot] merged 5 commits into
flutter:masterfrom
DanTup:dont-wait-launch

Conversation

@DanTup

@DanTup DanTup commented Aug 11, 2022

Copy link
Copy Markdown
Contributor

This removes some code that would wait for the app.started event before responding to the DAP's launch (or attach) requests. VS Code waits for the response to this event before performing some actions (such as showing the Debug Console) and the legacy DAPs never waited for this (I think I did this originally to simplify some tests knowing when the debugger was initialised, but since there are side-effects it's not the right way).

It also prevents us trying to send an app.stop event if an app never really started (we would send null as an appId to Flutter which would generate an error).

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

+ don't call app.stop for an app that never started.
@flutter-dashboard flutter-dashboard Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 11, 2022
@DanTup

DanTup commented Aug 11, 2022 •

Copy link
Copy Markdown
Contributor Author

Working on the test failures, and a little bit more cleanup, so changing this back to Draft..

Edit: Apparently I can't.. I'll ping when it's ready again.

@DanTup
DanTup removed the request for review from christopherfujino August 11, 2022 14:33
+ ensure it's only ever called from one place.
@DanTup

DanTup commented Aug 11, 2022

Copy link
Copy Markdown
Contributor Author

@christopherfujino ok, it's good now. There was a method _connectDebuggerIfReady that was called in two places, and would only connect the debugger if both of the other methods had received their respective events. This was a bit clumsy, so now the the ifReady is gone and we only ever call that method in one place, and just await the other event before we do.

_appId = params['appId'] as String?;
assert(_appId != null);
appId = params['appId'] as String?;
assert(appId != null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we throw a StateError in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, throwing makes sense. Although I used DebugAdapterException instead of StateError since it's not really related to the state of this object, if we get a null here it means flutter run --machine has emitted an invalid app.start event (without a valid appId).

@christopherfujino christopherfujino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one question about crashing rather than asserting

@Jasguerrero

Copy link
Copy Markdown
Contributor

You are having windows build_tests failing can we address those?

@DanTup

DanTup commented Aug 22, 2022

Copy link
Copy Markdown
Contributor Author

@christopherfujino do you know what's wrong with that build? I'm not sure if I'm looking at the right part of the log, but I see some failures like this:

[+4088 ms] > Configure project :app
[        ] Evaluating project ':app' using build file 'C:\b\s\w\ir\x\w\flutter\examples\platform_channel\android\app\build.gradle'.
[        ] Compiling build file 'C:\b\s\w\ir\x\w\flutter\examples\platform_channel\android\app\build.gradle' using SubsetScriptTransformer.
[        ] Compiling build file 'C:\b\s\w\ir\x\w\flutter\examples\platform_channel\android\app\build.gradle' using BuildScriptTransformer.
[   +1 ms] FAILURE: Build failed with an exception.
[   +2 ms] * Where:
[        ] Script 'C:\b\s\w\ir\x\w\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 293
[        ] * What went wrong:
[        ] A problem occurred evaluating script.
[        ] > Failed to apply plugin class 'FlutterPlugin'.
[        ]    > Comparison method violates its general contract!
[        ] * Try:
[        ] > Run with --debug option to get more log output.
[        ] > Run with --scan to get full insights.
[        ] * Exception is:
[        ] org.gradle.api.GradleScriptException: A problem occurred evaluating script.
[        ] 	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
[        ] 	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:133)
[        ] 	at org.gradle.configuration.DefaultScriptTarget.addConfiguration(DefaultScriptTarget.java:74)
[        ] 	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:136)
[        ] 	at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
[        ] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
[        ] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)

If I'm understanding the log correctly, this might be a test unrelated to this PR:

Testing APK build for examples\platform_channel...
▌12:49:37▐ RUNNING: cd examples\platform_channel; ..\..\bin\flutter.bat build apk --debug -v

@christopherfujino

Copy link
Copy Markdown
Contributor

@christopherfujino do you know what's wrong with that build? I'm not sure if I'm looking at the right part of the log, but I see some failures like this:

[+4088 ms] > Configure project :app
[        ] Evaluating project ':app' using build file 'C:\b\s\w\ir\x\w\flutter\examples\platform_channel\android\app\build.gradle'.
[        ] Compiling build file 'C:\b\s\w\ir\x\w\flutter\examples\platform_channel\android\app\build.gradle' using SubsetScriptTransformer.
[        ] Compiling build file 'C:\b\s\w\ir\x\w\flutter\examples\platform_channel\android\app\build.gradle' using BuildScriptTransformer.
[   +1 ms] FAILURE: Build failed with an exception.
[   +2 ms] * Where:
[        ] Script 'C:\b\s\w\ir\x\w\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 293
[        ] * What went wrong:
[        ] A problem occurred evaluating script.
[        ] > Failed to apply plugin class 'FlutterPlugin'.
[        ]    > Comparison method violates its general contract!
[        ] * Try:
[        ] > Run with --debug option to get more log output.
[        ] > Run with --scan to get full insights.
[        ] * Exception is:
[        ] org.gradle.api.GradleScriptException: A problem occurred evaluating script.
[        ] 	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
[        ] 	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:133)
[        ] 	at org.gradle.configuration.DefaultScriptTarget.addConfiguration(DefaultScriptTarget.java:74)
[        ] 	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:136)
[        ] 	at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
[        ] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
[        ] 	at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)

If I'm understanding the log correctly, this might be a test unrelated to this PR:

Testing APK build for examples\platform_channel...
▌12:49:37▐ RUNNING: cd examples\platform_channel; ..\..\bin\flutter.bat build apk --debug -v

I've been out of office for a week and a half, so I don't recognize this, however I'm 99% sure it's unrelated to this PR. I'd try rebasing upstream.

@DanTup

DanTup commented Aug 25, 2022

Copy link
Copy Markdown
Contributor Author

Looks that fixed it, thanks!

@DanTup DanTup added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 25, 2022
@auto-submit
auto-submit Bot merged commit 676a426 into flutter:master Aug 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 25, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants