Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppCenter SDK 5.0.0 P1 on iOS does not send crash reports #1687

Closed
rogerbriggen opened this issue Oct 7, 2022 · 11 comments
Closed

AppCenter SDK 5.0.0 P1 on iOS does not send crash reports #1687

rogerbriggen opened this issue Oct 7, 2022 · 11 comments

Comments

@rogerbriggen
Copy link

Description

I am using preview 1 of the sdk for MAUI. Now I can use it also on ios, thanks for that. The distribute module works and also the analytics. But I don't get any crash reports even so they are enabled. If I throw an exception (or use Crashes.GenerateTestCrash()). My app gets closed but nothing is sent to the appcenter, also not after a restart of the app.

Repro Steps

Please list the steps used to reproduce your issue.

  1. Setup appcenter with Crash enabled, add a button in the app which throws an exception
  2. You see in the appcenter the analytics (model, os version) but nothing about the crash

Currently, I don't have any special linker adjustments done in the csproj. Is there anything we need to do?

Details

  1. What is your app platform (Xamarin.Android or Xamarin.iOS or UWP)?
    • MAUI
  2. Which SDK version are you using?
    • e.g. 5.0.0 Preview 1
  3. Which OS version did you experience the issue on?
    • e.g. iOS 15.4, Android 8.1.0
  4. What device version did you see this error on? Were you using an emulator or a physical device?
    • e.g. iPhone 13 Mini
  5. What third party libraries are you using?
    • Automapper, Autofac, ...
  6. Please enable verbose logging for your app using AppCenter.LogLevel = LogLevel.Verbose before your call to AppCenter.Start(...) and include the logs here:
    I enabled it but don't find any log entries in my logs. Where do you log your stuff?
@DmitriyKirakosyan
Copy link
Contributor

Hi @rogerbriggen , thank you for reaching out!
Crashes work for me well on MAUI iOS.
Make sure AppCenter.LogLevel = LogLevel.Verbose is called before AppCenter.Start. You will be able to see the logs in the app output.

You also mentioned that you are targeting Android. Do you experience this issue on Android as well?

@rogerbriggen
Copy link
Author

It works fine on Android. But does not work on MAUI Windows Packaged App (Version 4.5.1 did work there).
I will try with the log level and report back.
In my project, I have multiple assemblies, and my app.xaml.cs where I start app center is not in the main assembly. Also, I more or less only call appcenter.start and don't assign any callback handlers.

@DmitriyKirakosyan
Copy link
Contributor

Initial issue was about iOS. Do crashes work on iOS now for you?
Will be waiting for your app logs.

@rogerbriggen
Copy link
Author

When I run it in the simulator with the debugger, it does not fisnish but will show me that there is an uncaught exception forever (even if I press Continue it just shows up immediatly again.

ObjCRuntime.ObjCException
Nachricht = Objective-C exception thrown. Name: System.NotImplementedException Reason: The method or operation is not implemented. (System.NotImplementedException)
at Edelweiss.GO.Presentation.Pages.Develop.DevelopViewModel.SendPingAsync() in C:\git\edw\go\Edelweiss.GO.Presentation\Pages\Develop\DevelopViewModel.cs:line 53
at CommunityToolkit.Mvvm.Input.AsyncRelayCommand.AwaitAndThrowIfFailed(Task executionTask)
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply()

Native stack trace:
0 CoreFoundation 0x00007fff20406d44 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff201a4a65 objc_exception_throw + 48
2 libxamarin-dotnet-debug.dylib 0x0000000109c67ddf xamarin_process_managed_exception + 943
3 Edelweiss.GO 0x0000000109067719 _ZL31native_to_managed_trampoline_10P11objc_objectP13objc_selectorPP11_MonoMethodj + 361
4 Edelweiss.GO 0x0000000109067ef9 -[__MonoMac_NSAsyncSynchronizationContextDispatcher xamarinApplySelector] + 41
5 Foundation 0x00007fff208513bf __NSThreadPerformPerform + 179
6 CoreFoundation 0x00007fff20373833 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
7 CoreFoundation 0x00007fff2037372b __CFRunLoopDoSource0 + 180
8 CoreFoundation 0x00007fff20372bf8 __CFRunLoopDoSources0 + 242
9 CoreFoundation 0x00007fff2036d2f4 __CFRunLoopRun + 871
10 CoreFoundation 0x00007fff2036ca90 CFRunLoopRunSpecific + 562
11 GraphicsServices 0x00007fff2cb72c8e GSEventRunModal + 139
12 UIKitCore 0x00007fff2508e90e -[UIApplication _run] + 928
13 UIKitCore 0x00007fff25093569 UIApplicationMain + 101
14 libmonosgen-2.0.dylib 0x000000010a455aa2 do_icall + 194
15 libmonosgen-2.0.dylib 0x000000010a454abd do_icall_wrapper + 253
16 libmonosgen-2.0.dylib 0x000000010a446cda interp_exec_method + 2970
17 libmonosgen-2.0.dylib 0x000000010a444f5f interp_runtime_invoke + 239
18 libmonosgen-2.0.dylib 0x000000010a33cbab mono_jit_runtime_invoke + 1227
19 libmonosgen-2.0.dylib 0x000000010a25f198 mono_runtime_invoke_checked + 136
20 libmonosgen-2.0.dylib 0x000000010a265f3b mono_runtime_exec_main_checked + 107
21 libmonosgen-2.0.dylib 0x000000010a39f042 mono_jit_exec + 354
22 libxamarin-dotnet-debug.dylib 0x0000000109c7be9d xamarin_main + 1949
23 Edelweiss.GO 0x00000001090f9344 main + 52
24 dyld 0x000000010985cf21 start_sim + 10
25 ??? 0x000000011578351e 0x0 + 4655166750

Quelle = Microsoft.iOS
Stapelüberwachung:
at ObjCRuntime.Runtime.ThrowNSException(IntPtr ns_exception)
at ObjCRuntime.Runtime.throw_ns_exception(IntPtr exc)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
at Edelweiss.GO.Program.Main(String[] args) in C:\git\edw\go\Edelweiss.GO\Platforms\iOS\Program.cs:line 12

appcenter_ios_log.zip

@rogerbriggen
Copy link
Author

Here the log from the console without debugger attached
appcenter_ios_log_without_debugger.zip

@DmitriyKirakosyan
Copy link
Contributor

From the logs I can't see anything suspicious. AppCenter is started successfully and sent some system logs. I can't see any crash in the logs.

Make sure you are not debugging the app while it is crashing, as your visual studio debugger will catch the crash. Make sure your app crashes after AppCenter is initialized. Then run the app again, so the AppCenter SDK would able to send the collected crash data. If it doesn't work, I will need two log files. The one when the app crashed and the one the app was restarted after the crash.

@rogerbriggen
Copy link
Author

Hi,
Thanks for your help. Attached you find a log where I created a crash (search for "appcenter test") with a NotImplementedException. Then i started the app again. This is on a real device, no debugger attached.
appcenter_real_device.zip

@DmitriyKirakosyan
Copy link
Contributor

Thank you for the logs! I've just updated dotnet and stuff and created a new MAUI app and faced the same issue, crashes were not sending from SDK. I'm creating a bug on our board and will update you on the progress.

@rogerbriggen
Copy link
Author

Thanks

@DmitriyKirakosyan
Copy link
Contributor

Hi @rogerbriggen , It appears it is a xamarin-macios bug. See xamarin/xamarin-macios#15252.
We rely on the AppDomain.CurrentDomain.UnhandledException which is not firing in a MAUI iOS (or just net6.0-ios/net7.0-ios) app.

The workaround is adding this on the app start:

ObjCRuntime.Runtime.MarshalManagedException += (s, a) =>
            a.ExceptionMode = ObjCRuntime.MarshalManagedExceptionMode.UnwindNativeCode;

@rogerbriggen
Copy link
Author

Hi @DmitriyKirakosyan
Thanks, it works with this workaround.
Maybe this should be somewhere prominent in the readme or even in the nuget itself... but I will close the ticket for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants