EndOfStreamException in dotnet-trace when tracing an Android app
MichaelRumpler opened this issue · 6 comments
Android framework version
net8.0-android
Affected platform version
.NET 8.0.300
Description
I tried to follow https://github.com/dotnet/android/blob/main/Documentation/guides/tracing.md#running-dotnet-trace-on-the-host
I ran adb reverse
and dotnet-dsrouter
without a problem, but when I try dotnet-trace
I get this output:
D:\src\RoyalConnect.Mobile.Android>dotnet-trace collect -p 4208 --format speedscope --dur
ation 00:00:05:00
No profile or providers specified, defaulting to trace profile 'cpu-sampling'Provider Name Keywords Level Enabled By
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profile[ERROR] System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.BinaryReader.InternalRead(Int32 numBytes)
at System.IO.BinaryReader.ReadUInt16()
at Microsoft.Diagnostics.NETCore.Client.IpcHeader.Parse(BinaryReader reader) in //src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcHeader.cs:line 55
at Microsoft.Diagnostics.NETCore.Client.IpcMessage.Parse(Stream stream) in //src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs:line 117
at Microsoft.Diagnostics.NETCore.Client.IpcClient.Read(Stream stream) in //src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs:line 107
at Microsoft.Diagnostics.NETCore.Client.IpcClient.SendMessageGetContinuation(IpcEndpoint endpoint, IpcMessage message) in //src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcClient.cs:line 44
at Microsoft.Diagnostics.NETCore.Client.EventPipeSession.Start(IpcEndpoint endpoint, EventPipeSessionConfiguration config) in //src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSession.cs:line 45
at Microsoft.Diagnostics.Tools.Trace.CollectCommandHandler.Collect(CancellationToken ct, IConsole console, Int32 processId, FileInfo output, UInt32 buffersize, String providers, String profile, TraceFileFormat format, TimeSpan duration, String clrevents, String clreventlevel, String name, String diagnosticPort, Boolean showchildio, Boolean resumeRuntime, String stoppingEventProviderName, String stoppingEventEventName, String stoppingEventPayloadFilter, Nullable`1 rundown) in //src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs:line 285
The two providers are listed at once. The error comes after about a minute even though I set duration to 5 minutes. I don't see
Waiting for connection on /tmp/maui-app
Start an application with the following environment variable: DOTNET_DiagnosticPorts=/tmp/maui-app
One minute is not enough to run dotnet build -t:Run -c Release -p:AndroidEnableProfiler=true --no-restore
in another window.
I also tried setting DOTNET_DiagnosticPorts
to some file in both windows, but then both commands are waiting for that file. How can I get dotnet-trace
and my Android app to sync?
I installed all three dotnet global tools today. dotnet-trace has version 8.0.532401+d98406ff95be0a8398d4c403056c5705389665f3.
Steps to Reproduce
- In a command window:
adb reverse tcp:9000 tcp:9001
dotnet-dsrouter android
- In another window:
adb shell setprop debug.mono.profile '127.0.0.1:9000,nosuspend,connect'
dotnet-trace ps
- look up pid of dsrouter and use it indotnet-trace collect -p 43512 --format speedscope --duration 00:00:05:00
Did you find any workaround?
No response
Relevant log output
No response
@jonathanpeppers Is this us or is this a dotnet/runtime
thing?
@MichaelRumpler you might watch this, and see if you missed a step:
I think we could move this to the dotnet/diagnostics repo, but it doesn't seem like I have permission:
Thanks for the fast response! In the video I also didn't see
Waiting for connection on /tmp/maui-app
But I saw that you started the app in advance. I thought I should start it when dotnet-trace is already running. This will probably be the reason. I'll let you know (but don't have time today anymore).
Yes, that was the problem. The app needs to be started already (at least with nosuspend) when you run dotnet-trace.
Maybe you can switch the order of "Running dotnet-trace on the Host" and "Running the .NET for Android Application" and remove the "Waiting for connection on /tmp/maui-app" in Documentation/guides/tracing.md.
dotnet-trace now saves something, but speedscope cannot get useful data out of it. But thats a different problem.
I feel like ?!?
appears if dotnet-trace
wasn't shut down cleanly. Did you press enter to stop it?
Do all the other threads look the same?
I added the --duration
in my previous attempts because I wanted it to wait until the app was started. It seems like when it ended via duration, the trace was not complete.
I started the app in advance and removed that parameter and now the trace is complete. Thank you!
Here again what I did.
Window 1:
adb reverse tcp:9000 tcp:9001
dotnet-dsrouter android
Window 2:
adb shell setprop debug.mono.profile '127.0.0.1:9000,nosuspend,connect'
dotnet build -t:Run -c Release -p:AndroidEnableProfiler=true --no-restore
dotnet-trace ps
- look up pid of dsrouter and use it indotnet-trace collect -p 43512 --format speedscope
Do the tests in the app and press return in dotnet-trace to write the trace.