Skip to content

Conversation

@kenzieschmoll
Copy link
Member

@kenzieschmoll kenzieschmoll commented Feb 27, 2024

Now that https://dart-review.googlesource.com/c/sdk/+/354460 has landed, DevTools server (or DDS depending on how DDS is started) will spawn the Dart Tooling Daemon (DTD). We need a way to access this URI from both the Dart CLI (dart-lang/sdk#55034) and Flutter CLI (#144270)

This PR

  • adds a command runner flag --print-dtd that is passed along to the DevToolsLauncher class. This value is then read when printing the DevTools output to determine whether we should also print a DTD uri.
    Screenshot 2024-03-25 at 7 56 05 AM

  • [cleanup for testing] merges multiple FakeDevtoolsLauncher classes into a single fake defined in fakes.dart

Fixes #144270.

@bkonyi @christopherfujino

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Feb 27, 2024
final Match? dtdMatch = _serveDtdPattern.firstMatch(line);
if (dtdMatch != null) {
final String uri = dtdMatch[1]!;
dtdUri = Uri.parse(uri);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, we can return here and not bother checking for _serveDevToolsPattern, right?

Copy link
Member Author

@kenzieschmoll kenzieschmoll Feb 28, 2024

Choose a reason for hiding this comment

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

No these are independent of one another. The _serveDevToolsPattern should always be in the stdout. The _serveDtdPattern might be there depending on whether the --print-dtd flag was passed to the dart devtools command above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would they be on the same line though?

Copy link
Member Author

Choose a reason for hiding this comment

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

No these will be on separate lines.


devToolsUrl = await completer.future;
// We do not need to wait for a [Completer] holding the DTD URI because
// the DTD URI will be output to stdout before the DevTools URI. Awaiting
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an implementation detail that could be inadvertently broken in a future refactor?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

The DTD uri won't always be available here, so we can't await a completer with the guarantee that it will complete. I can add tests in https://dart-review.googlesource.com/c/sdk/+/354460 that verify the order, with a comment that if the order or strings should change, that we will need to update the Flutter tools launcher. We could already get in a broken state with the existing "Serving DevTools" string if that were ever to change.

Copy link
Contributor

Choose a reason for hiding this comment

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

ahhhh, I see. A test sounds great, thanks!

@kenzieschmoll
Copy link
Member Author

Just added testing. Please review with "Hide whitespace" enabled. I fixed a formatting issue as a yak-shave.

argParser.addFlag(
FlutterGlobalOptions.kPrintDtdUri,
negatable: false,
help: 'Print the URI of the Dart Tooling Daemon, if one is hosted by the Flutter CLI.',
Copy link
Member Author

Choose a reason for hiding this comment

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

@christopherfujino is it okay to say "the Flutter CLI" here? Technically it is hosted by DevTools server, but that seemed like an implementation detail that wouldn't mean anything to the end user.

@kenzieschmoll kenzieschmoll changed the title Add a --print-dtd-uri flag to print the DTD address served by DevTools server Add a --print-dtd flag to print the DTD address served by DevTools server Feb 28, 2024
Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

LGTM

@christopherfujino
Copy link
Contributor

christopherfujino commented Feb 28, 2024

I'm seeing test failures that I'm 99% sure are not related to your change:

00:59 +597: test/commands.shard/hermetic/attach_test.dart: attach with one device and no specified target file local engine artifacts are passed to runner                                             
Error: Unable to find a built dart sdk at: "/path/to/local/engine/src/out/host_debug_unopt/dart-sdk" or a prebuilt dart sdk at: "/path/to/local/engine/src/flutter/prebuilts/linux-x64/dart-sdk"

https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8754867664597824945/+/u/run_test.dart_for_tool_tests_shard_and_subshard_commands/stdout

@christopherfujino
Copy link
Contributor

merging in upstream master, in case it was fixed there. it might also have been a recipe change...

@kenzieschmoll
Copy link
Member Author

kenzieschmoll commented Feb 29, 2024

The failure is being triggered from this line:
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/executable.dart/#L113

@christopherfujino any ideas on why that artifact would not be available in a test environment? Or how to make it so that it is available?

Another thought is to wrap DevtoolsLauncher.instance!.printDtdUri = shouldPrintDtdUri; in a try / catch in flutter_command_runner.dart and fail gracefully if this throws an exception. We likely don't want to crash the command runner if this fails anyway.

@kenzieschmoll
Copy link
Member Author

All tests are passing with the try / catch. @christopherfujino let me know if you think this is an acceptable solution.

@christopherfujino
Copy link
Contributor

All tests are passing with the try / catch. @christopherfujino let me know if you think this is an acceptable solution.

Hmm, a lot of this code (not from your PR) looks wrong to me, but I'm not fully grokking what happened. I'm investigating now...

@kenzieschmoll kenzieschmoll merged commit 31f4f2b into flutter:master Mar 25, 2024
@kenzieschmoll kenzieschmoll deleted the print-dtd-uri branch March 25, 2024 20:04
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a flag --print-dtd for printing the DTD address when served from DevTools server

3 participants