newrelic / newrelic-maui-plugin

New Relic Mobile instrumentation for MAUI
Apache License 2.0
9 stars 5 forks source link

iOS app not reporting unhandled crashes #42

Closed sgreifeneder closed 1 month ago

sgreifeneder commented 3 months ago

Description

I've set up 2 entities in NewRelic, one for Android and one for iOS. It should monitor some basic app usages, but also (un)handled crashes.

I've followed the readme to setup my MAUI app:

In MauiProgram.cs:

            .ConfigureLifecycleEvents(lifecycle =>
            {
#if ANDROID
                lifecycle.AddAndroid(android => android.OnCreate((activity, savedInstanceState) => StartNewRelic()));
#endif
#if IOS
                lifecycle.AddiOS(ios => ios.WillFinishLaunching((_, __) =>
                {
                    StartNewRelic();
                    return false;
                }));
#endif
            })
    private static void StartNewRelic()
    {
        CrossNewRelic.Current.HandleUncaughtException();

        if (DeviceInfo.Current.Platform == DevicePlatform.Android)
        {
            CrossNewRelic.Current.Start("xxxxxxxx");
        }
        else if (DeviceInfo.Current.Platform == DevicePlatform.iOS)
        {
            CrossNewRelic.Current.Start("xxxxxxxxx");
        }
    }

Now, when I try to manual trigger crashes/exceptions, they will show up in NewRelic dashboard for Android but not for iOS.

Steps to Reproduce

Expected Behavior

Crash should show up in NewRelic dashboard.

akrol95 commented 2 months ago

I have the same problem. I am using the latest version of the package (1.1.1).

akrol95 commented 2 months ago

I fixed the issue. It was on my side.

In my code there wastry...catchblock around:

UIApplication.Main(args, null, typeof(AppDelegate));

and it was blocking NewRelic mechanism from saving the exception. Now crashes are reported correctly.

sgreifeneder commented 2 months ago

It seems that not all crashes are reported, but I can't reproduce that yet. However, the biggest issue is something else: just learnt from NewRelic support, that MAUI apps don't support symbolication on iOS ... so that's useless anyway because you can't read crash reports.

ndesai-newrelic commented 2 months ago

@sgreifeneder @akrol95 have you trie to upload dsysm using this? https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios/configuration/upload-dsyms-bitcode-apps/#manual-dsym

ndesai-newrelic commented 1 month ago

@sgreifeneder @akrol95 To capture unhandled exceptions in iOS, you can introduce the following code when initializing the agent. We will start capturing these exceptions from the next release:

AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
    CrossNewRelic.Current.RecordException((Exception)e.ExceptionObject);
};
sgreifeneder commented 1 month ago

@ndesai-newrelic I'm already manually uploading the dSYM file. The issue is something else.

As per https://forum.newrelic.com/s/hubtopic/aAXPh0000000kyvOAA/autouploading-dsym-for-net-maui-ios-app-built-solely-with-visualstudio2022:

Please note that although, you are able to upload the dSYMs, they won't symbolicate the stack traces for a platform other than iOS because our hybrid agents (including the MAUI plugin) don't currently support the symbolication of crashes.

ndesai-newrelic commented 1 month ago

@sgreifeneder They are discussing .NET symbolication. We provide support for iOS crash symbolication using dsyms. Have you attempted to use the unhandled exception code that I recommended?

sgreifeneder commented 1 month ago

Where should I add this? After CrossNewRelic.Current.Start(...) and only for iOS?

ndesai-newrelic commented 1 month ago

@sgreifeneder you can add after you start agent. it is only for iOS.

sgreifeneder commented 1 month ago

ok will try

ndesai-newrelic commented 1 month ago

@sgreifeneder it is released now.

sgreifeneder commented 1 month ago

@ndesai-newrelic Are you referring to v1.1.4 of the New Relic .NET MAUI mobile plugin, released on Oct 11th? I also see a lot of data NOT being reported for iOS ... e.g. monthly active users. Android seems fine, though.

ndesai-newrelic commented 1 month ago

@sgreifeneder yes, can you share what data is missing from ios?

sgreifeneder commented 1 month ago

I am using v1.1.1 in production, and I released an Android and iOS app (built with .NET MAUI) approx. 2 weeks ago. While Android seems to be reporting fine, on iOS I'm missing: monthly active users (it's just 0), devices, OS versions, ... basically everything that's under USERS in the NewRelic menu for my app. I hope that's fixed with v1.1.4? Because I need to report these numbers on a monthly basis to my customers ...

ndesai-newrelic commented 1 month ago

@sgreifeneder can you test it with 1.1.4? it should fixed all the issues.

sgreifeneder commented 1 month ago

@ndesai-newrelic I had a quick test with 1.1.4 locally on my iPhone and I could see some data coming in. Will update here again once I release my app.

sgreifeneder commented 3 weeks ago

@ndesai-newrelic while it's working locally, my app crashes immediately when opened from TestFlight (everytime). Maybe an issue with release builds, I'm investigating it currently ... any known issues there?
see also https://github.com/newrelic/newrelic-maui-plugin/issues/50#issuecomment-2441831981