Skip to content

Support mdns when attaching to proxied devices. #146021

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

Merged
merged 4 commits into from
Apr 9, 2024

Conversation

chingjun
Copy link
Contributor

@chingjun chingjun commented Mar 29, 2024

Also move the vm service discovery logic into platform-specific implementation of Devices. This is to avoid having platform-specific code in attach.dart.

Pre-launch Checklist

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

@github-actions github-actions bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop labels Mar 29, 2024
Also move the vm service discovery logic into platform-specific
implementation of `Device`s. This is to avoid having platform-specific
code in attach.dart.
@chingjun chingjun force-pushed the discovery-for-attach branch from 7f482ca to 13d0145 Compare April 2, 2024 00:18
@chingjun chingjun marked this pull request as ready for review April 2, 2024 01:08
@vashworth vashworth self-requested a review April 3, 2024 21:31
},
onError: (Object e) {
// Daemon throws string types.
if (e is String && e.contains('command not understood')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it safe to ignore other errors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Forwarded the error to the stream instead.

@chingjun chingjun force-pushed the discovery-for-attach branch from 080de5a to 5541b8d Compare April 8, 2024 22:53
timeout: const Duration(seconds: 30),
slowWarningCallback: () {
// If relying on mDNS to find Dart VM Service, remind the user to allow local network permissions.
if (vmServiceDiscovery.usesMdns) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This status message is only relevant to iOS devices.

Suggested change
if (vmServiceDiscovery.usesMdns) {
if (vmServiceDiscovery.usesMdns && _isIOSDevice(device)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You made me realize that I misunderstood the comment and the message. I thought it was asking me to click "Allow" on the mac, when the dart binary wants to access network. It makes a lot more sense now.

In that case, usesMdns is not actually needed, I've removed that field. I also updated the comment and the message slightly to be clear that the permission.

Also updated _isIOSDevice below to check for device.platformType == PlatformType.ios instead of checking the type, to better support proxied devices.

PTAL, thanks!

} on Exception {
isolateDiscoveryProtocol?.dispose();
final List<ForwardedPort> ports = portForwarder.forwardedPorts.toList();
ports.forEach(portForwarder.unforward);
Copy link
Contributor

Choose a reason for hiding this comment

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

So previously, it was

for (final ForwardedPort port in ports) {
await device.portForwarder.unforward(port);
}

Does putting it in a forEach wait for each?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On re-reading the code, the try-catch was not added in the right place. I have moved it to the Stream<Uri> get uris getter below, and added the await back.

Thanks.

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.

This LGTM but I'll defer to Victoria for final approval (she knows this code the best)

Removed `usesMdns`, and restore platform checking in attach.dart when
showing the message asking user to allow network access on device.

Fix error handling in FuchsiaDevice.
Copy link
Contributor

@vashworth vashworth left a comment

Choose a reason for hiding this comment

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

LGTM!

@vashworth
Copy link
Contributor

Analyzer issue in test

Unused import: '../ios/simulators.dart' • packages/flutter_tools/lib/src/commands/attach.dart:26:8 • unused_import

@chingjun
Copy link
Contributor Author

chingjun commented Apr 9, 2024

Analyzer issue in test

Unused import: '../ios/simulators.dart' • packages/flutter_tools/lib/src/commands/attach.dart:26:8 • unused_import

Oops, missed that one. Fixed, thanks for the review!

@chingjun chingjun added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 9, 2024
@auto-submit auto-submit bot merged commit 8004212 into flutter:master Apr 9, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 10, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 10, 2024
flutter/flutter@4967a94...97cd47a

2024-04-10 engine-flutter-autoroll@skia.org Roll Flutter Engine from eaf73cd39cf8 to cee489a4e275 (2 revisions) (flutter/flutter#146541)
2024-04-10 engine-flutter-autoroll@skia.org Roll Flutter Engine from e4e274898efc to eaf73cd39cf8 (6 revisions) (flutter/flutter#146538)
2024-04-09 goderbauer@google.com Correct doc for AnimationMin (flutter/flutter#146531)
2024-04-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5dca50d3e268 to e4e274898efc (2 revisions) (flutter/flutter#146527)
2024-04-09 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.2.0 to 4.3.0 (flutter/flutter#146528)
2024-04-09 leroux_bruno@yahoo.fr Fix InputDecorator label position ignore visual density (flutter/flutter#146488)
2024-04-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5a824e22deb2 to 5dca50d3e268 (10 revisions) (flutter/flutter#146524)
2024-04-09 chingjun@google.com Support mdns when attaching to proxied devices. (flutter/flutter#146021)
2024-04-09 jacksongardner@google.com Fix skwasm tests (flutter/flutter#145570)
2024-04-09 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#146515)
2024-04-09 engine-flutter-autoroll@skia.org Roll Packages from 6b4d8b6 to 17f55d3 (6 revisions) (flutter/flutter#146508)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
Also move the vm service discovery logic into platform-specific implementation of `Device`s. This is to avoid having platform-specific code in attach.dart.
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
flutter/flutter@4967a94...97cd47a

2024-04-10 engine-flutter-autoroll@skia.org Roll Flutter Engine from eaf73cd39cf8 to cee489a4e275 (2 revisions) (flutter/flutter#146541)
2024-04-10 engine-flutter-autoroll@skia.org Roll Flutter Engine from e4e274898efc to eaf73cd39cf8 (6 revisions) (flutter/flutter#146538)
2024-04-09 goderbauer@google.com Correct doc for AnimationMin (flutter/flutter#146531)
2024-04-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5dca50d3e268 to e4e274898efc (2 revisions) (flutter/flutter#146527)
2024-04-09 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.2.0 to 4.3.0 (flutter/flutter#146528)
2024-04-09 leroux_bruno@yahoo.fr Fix InputDecorator label position ignore visual density (flutter/flutter#146488)
2024-04-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5a824e22deb2 to 5dca50d3e268 (10 revisions) (flutter/flutter#146524)
2024-04-09 chingjun@google.com Support mdns when attaching to proxied devices. (flutter/flutter#146021)
2024-04-09 jacksongardner@google.com Fix skwasm tests (flutter/flutter#145570)
2024-04-09 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#146515)
2024-04-09 engine-flutter-autoroll@skia.org Roll Packages from 6b4d8b6 to 17f55d3 (6 revisions) (flutter/flutter#146508)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop autosubmit Merge PR when tree becomes green via auto submit App platform-ios iOS applications specifically 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