Skip to content

dotnet-dsrouter android does not appear to work for Android devices #4337

@jonathanpeppers

Description

@jonathanpeppers

Description

If I do:

> dotnet-dsrouter android --verbose debug
WARNING: dotnet-dsrouter is a development tool not intended for production environments.

Start an application on android emulator with one of the following environment variables set:
DOTNET_DiagnosticPorts=127.0.0.1:9000,nosuspend,connect
DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend,connect

info: dotnet-dsrouter[0]
      Starting dotnet-dsrouter using pid=31220
dbug: dotnet-dsrouter[0]
      Using default IPC server path, dotnet-diagnostic-dsrouter-31220.
dbug: dotnet-dsrouter[0]
      Attach to default dotnet-dsrouter IPC server using --process-id 31220 diagnostic tooling argument.
dbug: dotnet-dsrouter[0]
      Executing D:\android-toolchain\sdk\\platform-tools\adb reverse --list.
dbug: dotnet-dsrouter[0]
      Executing D:\android-toolchain\sdk\\platform-tools\adb reverse tcp:9000 tcp:9000.
info: dotnet-dsrouter[0]
      Starting IPC server (dotnet-diagnostic-dsrouter-31220) <--> TCP server (127.0.0.1:9000) router.
dbug: dotnet-dsrouter[0]
      Trying to create new router instance.
dbug: dotnet-dsrouter[0]
      Waiting for a new TCP connection at endpoint "127.0.0.1:9000".
dbug: dotnet-dsrouter[0]
      Waiting for new ipc connection at endpoint "dotnet-diagnostic-dsrouter-31220".
dbug: dotnet-dsrouter[0]

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:

dbug: dotnet-dsrouter[0]
      Successfully connected TCP stream, runtime id=0c733d99-d2c3-432d-a611-543df3a824c5, runtime pid=27293.

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:

Executing D:\android-toolchain\sdk\\platform-tools\adb reverse tcp:9000 tcp:9000.

For the old method, I would normally do:

> adb reverse tcp:9000 tcp:9001
> adb shell setprop debug.mono.profile '127.0.0.1:9000,suspend'
> dotnet-dsrouter client-server -tcps 127.0.0.1:9001 -ipcc /tmp/maui-app --verbose debug
> dotnet-trace collect --diagnostic-port /tmp/maui-app

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 need adb reverse:

> 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...

Configuration

> dotnet --version
8.0.100-rc.2.23502.2
> 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

Regression?

No, this is a new command.

/cc @lateralusX

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions