JaneySprings / DotNet.Meteor

A VSCode extension that can run and debug .NET apps (Xamarin, MAUI, Avalonia)
https://marketplace.visualstudio.com/items?itemName=nromanov.dotnet-meteor
MIT License
268 stars 10 forks source link

Not able to /dump and no traces are collected. #115

Closed haavamoa closed 1 month ago

haavamoa commented 2 months ago

Hi, this is an awesome project. I just tried it to memory profile my iOS app, but when I do a dump I get the following:

/dump -v
command handled by DotNet.Meteor.Debug.GCDumpLaunchAgent
Writing gcdump to '/Users/<myuser>/code/<myproject>/src/<myproject>/.meteor/<myproject>.gcdump'...
0,0s: Creating type table flushing task
0,0s: [Error] Exception during gcdump: System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
at System.IO.BinaryReader.InternalRead(Int32 numBytes)
at System.IO.BinaryReader.ReadUInt16()
at Microsoft.Diagnostics.NETCore.Client.IpcHeader.Parse(BinaryReader reader) in /Users/runner/work/1/s/src/DotNet.Diagnostics/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcHeader.cs:line 55
at Microsoft.Diagnostics.NETCore.Client.IpcMessage.Parse(Stream stream) in /Users/runner/work/1/s/src/DotNet.Diagnostics/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs:line 117

Note; <myproject> is just me obfuscating.

I do get a connected successfully of dotnet-dsrouter:

info: dotnet-dsrouter-17120[0]
Starting dotnet-dsrouter using pid=17120
info: dotnet-dsrouter-17120[0]
Starting IPC server (/Users/<myuser>/ios-port.lock) <--> TCP client (127.0.0.1:11000) router.
info: dotnet-dsrouter-17120[0]
Successfully connected new device, id=3.

I've also tried the trace profiling, but no luck there as well :(

I've tried the troubleshooting, but no luck :(

Android works fine, but not iOS :(

haavamoa commented 2 months ago

➤ dotnet workload list

Installed Workload Id Manifest Version Installation Source

ios 17.5.8020/8.0.100 SDK 8.0.300
maui 8.0.72/8.0.100 SDK 8.0.300
android 34.0.113/8.0.100 SDK 8.0.300

JaneySprings commented 2 months ago

Hi, @haavamoa !

I've also tried the trace profiling, but no luck there as well :(

Let's try to find the problem using the trace mode:

haavamoa commented 2 months ago

Hi, @haavamoa !

I've also tried the trace profiling, but no luck there as well :(

Let's try to find the problem using the trace mode:

  • Run your iOS application (you can use debug + simulator) with trace. Can you see the following messages?
image
  • Can you see the Output File: message?
  • If you don't see this message, is your app currently showing your MainPage or it is .NET SplashScreen?

Unfortunately , trace seems to exit my application once the splash screen is gone. This was not the behaviour this morning.

I notice you deploy using simulator, I am using a device.

JaneySprings commented 2 months ago

Can you check this behavior with simulator?

haavamoa commented 2 months ago

I just did, now I get a infamous clang+++ error with AppCenter package when building.

usr/local/share/dotnet/x64/packs/Microsoft.iOS.Sdk.net8.0_17.5/17.5.8020/targets/Xamarin.Shared.Sdk.targets(1641,3): error : clang++ exited with code 1: [<my-repo-patch>/<my-csproj>csproj::TargetFramework=net8.0-ios]
/usr/local/share/dotnet/x64/packs/Microsoft.iOS.Sdk.net8.0_17.5/17.5.8020/targets/Xamarin.Shared.Sdk.targets(1641,3): error : ld: in <my-repo-patch>/obj/Debug/net8.0-ios/iossimulator-arm64/linker-cache/AppCenter.a(MSACAppCenter.o), building for iOS Simulator, but linking in object file built for iOS, file '<my-repo-path>/obj/Debug/net8.0-ios/iossimulator-arm64/linker-cache/AppCenter.a' [<my-repo-path>/<my-csproj>csproj::TargetFramework=net8.0-ios]
/usr/local/share/dotnet/x64/packs/Microsoft.iOS.Sdk.net8.0_17.5/17.5.8020/targets/Xamarin.Shared.Sdk.targets(1641,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation) [<my-repo-path>/<my-csproj>csproj::TargetFramework=net8.0-ios]

This is fixed by adding this to the csproj, which makes sure I can build in Rider, but somehow not when I am using .NET Meteor in VSCode :(

    <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
        <RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier> 
    </PropertyGroup>
haavamoa commented 2 months ago

Ah yeah, I notice that in VSCode it sets -p:RuntimeIdentifier=iossimulator-arm64 when building, and my property will get overridden.

I forgot to mention I run on Apple Sillicon.

I started using Meteor today, how can I override what it tries to set when building? :)

JaneySprings commented 2 months ago

Yes, you can override it. Update to the latest version (5.3.1 and higher) and use the following workaround:

And update your launch.json file

{
    "version": "0.2.0",
    "configurations": [
        {
        ...
        },
        // Your new configuration for simulator-x64 only
        {
            "name": "(simX64) .NET Meteor Debugger",
            "type": "dotnet-meteor.debugger",
            "request": "launch",
            // You can specify path to the application here
            "program": "${workspaceFolder}/bin/Debug/net8.0-ios/iossimulator-x64/MauiTestApp.app",
            "preLaunchTask": "dotnet-meteor: Build",
        }
    ]
}

And you can select your new configuration here:

image
haavamoa commented 2 months ago

Thanks, I followed your steps and added "-p:RuntimeIdentifier=iossimulator-x64" to my tasks.json. Now It builds, but it's unable to launch due to looking in the wrong folders:

Failed to launch the simulator: Could not find file '<my-repo-path>/bin/Debug/net8.0-ios/iossimulator-arm64/<myapp>.

We can continue trying to solve this, or can we focus on device? Testing simulator is nice, but device is what I will have to run on when collecting memory dumps / traces in the end of the day.

JaneySprings commented 2 months ago

Also you can try to reproduce it in the new empty project (dotnet new maui). Maybe some library is a reason of this behavior. I can't reproduce this on a simulator or device with the latest version of iOS.

haavamoa commented 2 months ago

Just tested with this project: https://github.com/DIPSAS/DIPS.Mobile.UI , and it works.

haavamoa commented 2 months ago

Its nice, but at the same time not as the actual app I want to profile does not work :(

Originally, I wanted to test gcdump on my project. As you see it runs, but it throws exceptions when I dump. Is there anything I can do to get some more details regarding that exception?

/dump -v
command handled by DotNet.Meteor.Debug.GCDumpLaunchAgent
Writing gcdump to '/Users/<myuser>/code/<myproject>/src/<myproject>/.meteor/<myproject>.gcdump'...
0,0s: Creating type table flushing task
0,0s: [Error] Exception during gcdump: System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
at System.IO.BinaryReader.InternalRead(Int32 numBytes)
at System.IO.BinaryReader.ReadUInt16()
at Microsoft.Diagnostics.NETCore.Client.IpcHeader.Parse(BinaryReader reader) in /Users/runner/work/1/s/src/DotNet.Diagnostics/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcHeader.cs:line 55
at Microsoft.Diagnostics.NETCore.Client.IpcMessage.Parse(Stream stream) in /Users/runner/work/1/s/src/DotNet.Diagnostics/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs:line 117
JaneySprings commented 2 months ago

I think you can try to remove some nuget packages for testing. Maybe AppCenter package that you mentioned above...