[flutter_tools] Serve DevTools at app start#73366
[flutter_tools] Serve DevTools at app start#73366kenzieschmoll merged 20 commits intoflutter:masterfrom
Conversation
| await Future.wait(<Future<void>>[ | ||
| connectToServiceProtocol(), | ||
| serveDevToolsGracefully(), | ||
| ]); |
There was a problem hiding this comment.
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.
What happens when we attach to a running profile mode app?
There was a problem hiding this comment.
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.
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.
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.
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.
Why ignore errors here?
There was a problem hiding this comment.
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.
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.
Friendly ping here - please don't ignore avoid_catches_without_on_clauses
There was a problem hiding this comment.
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.
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.
Good question. I'm following up with @helin24 on this to see what we do from IntelliJ.
There was a problem hiding this comment.
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
| } else { | ||
| try { | ||
| return await _devToolsLauncher.serve(openInBrowser: openInBrowser); | ||
| } catch (e) { // ignore: avoid_catches_without_on_clauses |
There was a problem hiding this comment.
Friendly ping here - please don't ignore avoid_catches_without_on_clauses
Co-authored-by: Jonah Williams <[email protected]>
|
@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