-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[flutter_tools] Serve DevTools at app start #73366
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
Conversation
| await Future.wait(<Future<void>>[ | ||
| connectToServiceProtocol(), | ||
| serveDevToolsGracefully(), | ||
| ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attach wasn't being called from flutter run for profile mode like it was for debug mode, so I had to add this to run in addition to attach for the cold runner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when we attach to a running profile mode app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attach is called in run_cold.dart
| status.cancel(); | ||
| _logger.printError('Error running `pub global activate ' | ||
| 'devtools`:\n${_devToolsActivateProcess.stderr}'); | ||
| await http.head('https://pub.dev'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to include a check for https://flutter.dev/community/china#configuring-flutter-to-use-a-mirror-site , since otherwise this will fail in China.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pub.dev won't be accessible though, so one of these will always fail. Instead you should look up if there is a pub url override in the environment variable (the user could have some arbitrary pub mirror configured) and use that if present, falling back to pub.dev
|
@DanTup see the latest commit for --devtools-server-address flag |
| status.cancel(); | ||
| _logger.printError('Error running `pub global activate ' | ||
| 'devtools`:\n${_devToolsActivateProcess.stderr}'); | ||
| await http.head('https://pub.dev'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pub.dev won't be accessible though, so one of these will always fail. Instead you should look up if there is a pub url override in the environment variable (the user could have some arbitrary pub mirror configured) and use that if present, falling back to pub.dev
| } else { | ||
| try { | ||
| return await _devToolsLauncher.serve(openInBrowser: openInBrowser); | ||
| } catch (e) { // ignore: avoid_catches_without_on_clauses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ignore errors here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want a failed devtools serve to halt a flutter run / attach process, so we swallow the error to fail gracefully. Do you have another suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but you are catching all errors, including things like TypeError. What exceptions are you expecting here - could the _devToolsLauncher handle that instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Friendly ping here - please don't ignore avoid_catches_without_on_clauses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed try catch from resident_runner and pushed exception swallowing into devtools_launcher
|
Done addressing review comments PTAL |
packages/flutter_tools/test/general.shard/devtools_launcher_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/test/general.shard/devtools_launcher_test.dart
Outdated
Show resolved
Hide resolved
|
|
||
| Future<void> serveDevToolsGracefully({ | ||
| Uri devToolsServerAddress, | ||
| bool openInBrowser = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the functionality of openInBrowser now? Can we let the user click on the link themselves so they get their preferred browser/existing instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I'm following up with @helin24 on this to see what we do from IntelliJ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO to remove this in a cleanup CL, as it will require a g3fix, and I'd like to get this landed sooner than later to start working on iterative CLs. AFAIK the 'v' hotkey was the only place using this functionality openInBrowser: true, so removing the param should be safe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable!
| } else { | ||
| try { | ||
| return await _devToolsLauncher.serve(openInBrowser: openInBrowser); | ||
| } catch (e) { // ignore: avoid_catches_without_on_clauses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Friendly ping here - please don't ignore avoid_catches_without_on_clauses
Co-authored-by: Jonah Williams <[email protected]>
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@kenzieschmoll are there any existing deep-links generated by Flutter that I can use to test |
|
@DanTup No, not yet. But if you pass a server address with a port number different than the default 9100, you should be able to verify that devtools is running on the port you specified, like 9105 for example. |
|
@kenzieschmoll that seems to work great. I was mainly curious about how the links would appear in VS Code - for example wondering if we could route them to the internal embedded view in future if that's enabled. I'll come back to that once there are some links. Thanks! |
This PR:
--devtools-server-addressso that an existing DevTools server can be passed to flutter_tools (this will be used by VS Code @DanTup)Fixes #70129
Fixes #71688
FYI @helin24 @DanTup