-
Notifications
You must be signed in to change notification settings - Fork 356
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
dotnet-dsrouter android
does not appear to work for Android devices
#4337
Comments
OK, I don't have a physical Android device to test on, but I tried using the "android" argument against an emulator and in that case the port reverse worked as expected using the same port on emulator and host. I was under the impression that you actually could use the same port, and since it worked running with the same port using the "android" argument on emulator I simplified that configuration, but apparently it have issues. @jonathanpeppers Fix is simple, maybe you could do local build and test it on a real Android device to make sure defaults works? Alternative is to simulate what the default argument would have done, so you could do like this: adb reverse tcp:9000 tcp:9001 //Run the app using 127.0.0.1:9000,suspend,connect So I guess we should follow the defaults you used in the past? device port 9000 and host port 9001 in case we do adb reverse or forward of ports. In the case when doing manual config with the --port-forward argument (dsrouter runs adb forward/reverse) and user pass in host port as part of tcps or tcpc arguments then device port would be selected host port - 1 in order to be in sync with old defaults, so if host port would be something like 9232 and passed to dotnet-dsrouter then the device port for the port forwarding would end up as 9231. |
These instructions appear to work on an Android device:
In the case that doesn't work,
Then it seems like Mono is just trying to connect and can't:
Here is the full log: log.txt |
Context: dotnet/diagnostics#4081 Context: dotnet/diagnostics#4090 Context: dotnet/runtime#88634 Context: dotnet/diagnostics#4337 Using the latest `dotnet-trace` tooling: > dotnet tool list -g Package Id Version Commands -------------------------------------------------------------------------------------- dotnet-dsrouter 7.0.447801 dotnet-dsrouter dotnet-gcdump 7.0.447801 dotnet-gcdump dotnet-trace 7.0.447801 dotnet-trace There is a simplified way to profile Android apps. For an Android emulator: > dotnet-dsrouter android-emu Start an application on android emulator with one of the following environment variables set: DOTNET_DiagnosticPorts=10.0.2.2:9000,nosuspend,connect DOTNET_DiagnosticPorts=10.0.2.2:9000,suspend,connect > adb shell setprop debug.mono.profile '10.0.2.2:9000,suspend,connect' > dotnet-trace ps 3248 dotnet-dsrouter > dotnet-trace collect -p 3248 ... [00:00:00:09] Recording trace 3.2522 (MB) Press <Enter> or <Ctrl+C> to exit... For an Android device you will eventually be able to do `dotnet-dsrouter android`, except we found one issue. Until dotnet/diagnostics#4337 is resolved, we can instead do: > adb reverse tcp:9000 tcp:9001 > dotnet-dsrouter server-server -tcps 127.0.0.1:9001 > adb shell setprop debug.mono.profile '127.0.0.1:9000,suspend,connect' > dotnet-trace ps > dotnet-trace collect -p 3248 We can also now use `dotnet-gcdump`! Instead of `dotnet-trace collect -p`, you can simply do: > dotnet-gcdump collect -p 3248 In both cases these tools *know* that the process ID is a `dotnet-dsrouter` process and to do the right thing.
Context: dotnet/diagnostics#4081 Context: dotnet/diagnostics#4090 Context: dotnet/runtime#88634 Context: dotnet/diagnostics#4337 Using the latest `dotnet-trace` tooling: > dotnet tool list -g Package Id Version Commands -------------------------------------------------------------------------------------- dotnet-dsrouter 7.0.447801 dotnet-dsrouter dotnet-gcdump 7.0.447801 dotnet-gcdump dotnet-trace 7.0.447801 dotnet-trace There is a simplified way to profile Android apps. For an Android emulator: > dotnet-dsrouter android-emu Start an application on android emulator with one of the following environment variables set: DOTNET_DiagnosticPorts=10.0.2.2:9000,nosuspend,connect DOTNET_DiagnosticPorts=10.0.2.2:9000,suspend,connect > adb shell setprop debug.mono.profile '10.0.2.2:9000,suspend,connect' > dotnet-trace ps 3248 dotnet-dsrouter > dotnet-trace collect -p 3248 ... [00:00:00:09] Recording trace 3.2522 (MB) Press <Enter> or <Ctrl+C> to exit... For an Android device you will eventually be able to do `dotnet-dsrouter android`, except we found one issue. Until dotnet/diagnostics#4337 is resolved, we can instead do: > adb reverse tcp:9000 tcp:9001 > dotnet-dsrouter server-server -tcps 127.0.0.1:9001 > adb shell setprop debug.mono.profile '127.0.0.1:9000,suspend,connect' > dotnet-trace ps > dotnet-trace collect -p 3248 We can also now use `dotnet-gcdump`! Instead of `dotnet-trace collect -p`, you can simply do: > dotnet-gcdump collect -p 3248 In both cases these tools *know* that the process ID is a `dotnet-dsrouter` process and to do the right thing.
@jonathanpeppers Do you have ability to do local build of #4342 and try out the fix to make sure it solves the issue when running against a physical Android device? |
The use of automatic port forwarding on Android device used the same port as local and remote, that should be possible, but turns out there is some issue with `adb` around that configuration when running against a physical Android device (works when using port forwarding/reverse against Android emulator). This PR change the port defaults and align to Xamarin Android documentation as well as using different ports for local and remove when using -`tcps` or -`tcpc` arguments together with `--forward-port android`. When running using the "Android" connect profile, `dotnet-dsrouter android` we will default to 9001 as local/host and 9000 as remote/device port. When running with -`tcps` or -`tcpc` we will use passed port as local/host port and then set the remote/device port to local/host port - 1 in call to `adb reverse|forward`. Fixes #4337
Should the documentation be updated now that this issue is resolved?
|
@jeanplevesque send a PR! I planned to update when I got a chance. Thanks. |
Description
If I do:
At this point, I can launch an Android application on the device, but it appears to never be able to connect. I never get a log message like:
I had run
adb shell setprop debug.mono.profile '127.0.0.1:9000,suspend,connect'
as the log message mentions, but I believe the forwarded port is incorrect:For the old method, I would normally do:
https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/tracing.md
I think the "old way" works because it uses two different ports 9000 and 9001.
The
android-emu
method also works fine, because it doesn't needadb reverse
:Configuration
Regression?
No, this is a new command.
/cc @lateralusX
The text was updated successfully, but these errors were encountered: