Skip to content

[Android, 9.0] dotnet-trace creates a broken nettrace file (and no Speedscope file) #28982

Closed
@janne-hmp

Description

@janne-hmp

Description

I tried to produce a Speedscope and nettrace files for my game GnollHack using dotnet-trace collect -p [pid] --format Speedscope while dotnet-dsrouter android is running ([pid] is the relevant process number). However, no Speedscore file is produced and nettrace file is corrupted. dotnet-trace version is 9.0.621003+ebd1db46a2395bd7de706694ff54f1c9526951d7. This used to work maybe a year ago.

Steps to Reproduce

  1. Clone the reproduction repository at https://github.com/hyvanmielenpelit/GnollHackMAUIEasyBuild and build it according to instructions
  2. Install Tools in Developer PowerShell:
    • Type: dotnet tool install -g dotnet-trace
    • Type: dotnet tool install -g dotnet-dsrouter
  3. Connect Android Device
    • Connect your physical Android device to the USB port.
    • Remember to enable USB Debugging in the Developer Options on the device.
    • Open the GnollHackM solution in Visual Studio.
    • Select the device in Visual Studio.
  4. dotnet-dsrouter
    • Start
      • Start Tools → Android → Android ADB Command Prompt (from Visual Studio)
    • Run:
      • Type: set ANDROID_SDK_ROOT=C:\Program Files (x86)\Android\android-sdk
      • Type: adb reverse tcp:9000 tcp:9001
      • Type: adb shell setprop debug.mono.profile '127.0.0.1:9000,nosuspend,connect'
      • Type: dotnet-dsrouter android
      • You will see the dotnet-dsrouter process ID (pid) on the screen. You will need this later.
  5. dotnet-trace
    • Create a directory: C:\Users{UserName}\dotnet-trace, where {UserName} is your Windows user name in the file system.
    • Start Windows PowerShell. It should open in the C:\Users{UserName} directory.
    • Type: cd dotnet-trace
    • Leave the window open.
  6. Launch Android App
    • Open the GnollHackM solution in Visual Studio.
    • Start Developer PowerShell (Terminal) in Visual Studio.
    • Check that you are in the GnollHackM project directory. If not, close the window and reopen it from View → Terminal.
    • In the Developer PowerShell, write:
      dotnet build .\GnollHackM.csproj -f net9.0-android -t:Run -c Release -p:AndroidEnableProfiler=true
    • GnollHackM should launch on the device.
  7. Collect trace with dotnet-trace
    • In the dotnet-trace window that you started in Step 5, write:
      dotnet-trace collect -p {dotnet-dsrouter-process-id} --format speedscope
      where {dotnet-dsrouter-process-id} is the process ID of dotnet-dsrouter that you saw in Step 4 or optionally wrote down in Step 5. This will begin tracing.
  8. Use Android App
    • In the Android app, do whatever you want to trace in the application.
  9. Stop dotnet-trace
    • Press Enter or Ctrl-C to stop tracing in the dotnet-trace window.
    • This should write .speedscope.json and .nettrace files to C:\Users{UserName}\dotnet-trace .
    • However, no .speedscope.json file is produced and .nettrace file is corrupted

Link to public reproduction project repository

https://github.com/hyvanmielenpelit/GnollHackMAUIEasyBuild

Version with bug

9.0.50 SR5

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.0-preview.3.10457

Affected platforms

Android

Affected platform versions

Android 15

Did you find any workaround?

No.

Relevant log output

PS C:\Users\janne\dotnet-trace> dotnet-trace --version
9.0.621003+ebd1db46a2395bd7de706694ff54f1c9526951d7
PS C:\Users\janne\dotnet-trace> dotnet-trace convert .\dotnet-dsrouter.exe_20250414_211529.nettrace --format Speedscope
Processing trace data file 'C:\Users\janne\dotnet-trace\dotnet-dsrouter.exe_20250414_211529.nettrace' to create a new Speedscope file 'C:\Users\janne\dotnet-trace\dotnet-dsrouter.exe_20250414_211529.speedscope.json'.
Detected a potentially broken trace. Continuing with best-efforts to convert the trace, but resulting speedscope file may contain broken stacks as a result.
Conversion complete
(Note: The file does not work, though)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-toolingXAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debuggingplatform/android 🤖t/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions