getsentry / sentry-capacitor

The official Sentry SDK for Capacitor
https://sentry.io
MIT License
119 stars 34 forks source link

iOS issue - OutOfMemory on app launch #424

Closed ghost closed 1 year ago

ghost commented 1 year ago

Environment

Angular 16 Capacitor 5 Ionic 7 @sentry/angular-ivy: 7.54.0 @sentry/capacitor: 0.12.1 @sentry/tracing: 7.54.0

Steps to Reproduce

  1. Following the installation guide for angular/capacitor set up
  2. Run the iOS app

Expected Result

The app launches without reporting errors

Actual Result

The app launches without any problems for the user. But the error "OutOfMemory: The OS most likely terminated your app because it overused RAM." is logged on Sentry, without stack trace.

To see more informations about the error, I launched the app in debug mode, and below is the log from XCode console. If I remove Sentry.init call, the error doesn't show up.

================================================================= Main Thread Checker: UI API called on a background thread: -[UIApplication delegate] PID: 969, TID: 172129, Thread name: (none), Queue name: bridge, QoS: 0 Backtrace: 4 Sentry 0x0000000105737c90 -[SentryUIViewControllerSwizzling swizzleRootViewControllerFromUIApplication:] + 52 5 Sentry 0x0000000105736f3c -[SentryUIViewControllerSwizzling start] + 80 6 Sentry 0x00000001056fe434 -[SentryPerformanceTrackingIntegration installWithOptions:] + 456 7 Sentry 0x0000000105715bd4 +[SentrySDK installIntegrations] + 832 8 Sentry 0x0000000105714208 +[SentrySDK startWithOptionsObject:] + 440 9 SentryCapacitor 0x00000001050f4d18 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCF + 608 10 SentryCapacitor 0x00000001050f57b4 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCFTo + 52 11 Capacitor 0x0000000104dc7fd0 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0VtFyycfU0 + 856 12 Capacitor 0x0000000104dbc478 $sIeg_IeyB_TR + 48 13 libdispatch.dylib 0x00000001054a85a8 _dispatch_call_block_and_release + 32 14 libdispatch.dylib 0x00000001054aa05c _dispatch_client_callout + 20 15 libdispatch.dylib 0x00000001054b210c _dispatch_lane_serial_drain + 988 16 libdispatch.dylib 0x00000001054b2e34 _dispatch_lane_invoke + 420 17 libdispatch.dylib 0x00000001054bfcbc _dispatch_workloop_worker_thread + 740 18 libsystem_pthread.dylib 0x00000001e5615df8 _pthread_wqthread + 288 19 libsystem_pthread.dylib 0x00000001e5615b98 start_wqthread + 8 2023-07-31 11:04:36.381317+0200 App[969:172129] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication delegate] PID: 969, TID: 172129, Thread name: (none), Queue name: bridge, QoS: 0 Backtrace: 4 Sentry 0x0000000105737c90 -[SentryUIViewControllerSwizzling swizzleRootViewControllerFromUIApplication:] + 52 5 Sentry 0x0000000105736f3c -[SentryUIViewControllerSwizzling start] + 80 6 Sentry 0x00000001056fe434 -[SentryPerformanceTrackingIntegration installWithOptions:] + 456 7 Sentry 0x0000000105715bd4 +[SentrySDK installIntegrations] + 832 8 Sentry 0x0000000105714208 +[SentrySDK startWithOptionsObject:] + 440 9 SentryCapacitor 0x00000001050f4d18 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCF + 608 10 SentryCapacitor 0x00000001050f57b4 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCFTo + 52 11 Capacitor 0x0000000104dc7fd0 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0VtFyycfU0 + 856 12 Capacitor 0x0000000104dbc478 $sIeg_IeyB_TR + 48 13 libdispatch.dylib 0x00000001054a85a8 _dispatch_call_block_and_release + 32 14 libdispatch.dylib 0x00000001054aa05c _dispatch_client_callout + 20 15 libdispatch.dylib 0x00000001054b210c _dispatch_lane_serial_drain + 988 16 libdispatch.dylib 0x00000001054b2e34 _dispatch_lane_invoke + 420 17 libdispatch.dylib 0x00000001054bfcbc _dispatch_workloop_worker_thread + 740 18 libsystem_pthread.dylib 0x00000001e5615df8 _pthread_wqthread + 288 19 libsystem_pthread.dylib 0x00000001e5615b98 start_wqthread + 8

Main Thread Checker: UI API called on a background thread: -[UIWindow rootViewController] PID: 969, TID: 172129, Thread name: (none), Queue name: bridge, QoS: 0 Backtrace: 4 Sentry 0x0000000105737eac -[SentryUIViewControllerSwizzling swizzleRootViewControllerFromUIApplication:] + 592 5 Sentry 0x0000000105736f3c -[SentryUIViewControllerSwizzling start] + 80 6 Sentry 0x00000001056fe434 -[SentryPerformanceTrackingIntegration installWithOptions:] + 456 7 Sentry 0x0000000105715bd4 +[SentrySDK installIntegrations] + 832 8 Sentry 0x0000000105714208 +[SentrySDK startWithOptionsObject:] + 440 9 SentryCapacitor 0x00000001050f4d18 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCF + 608 10 SentryCapacitor 0x00000001050f57b4 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCFTo + 52 11 Capacitor 0x0000000104dc7fd0 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0VtFyycfU0 + 856 12 Capacitor 0x0000000104dbc478 $sIeg_IeyB_TR + 48 13 libdispatch.dylib 0x00000001054a85a8 _dispatch_call_block_and_release + 32 14 libdispatch.dylib 0x00000001054aa05c _dispatch_client_callout + 20 15 libdispatch.dylib 0x00000001054b210c _dispatch_lane_serial_drain + 988 16 libdispatch.dylib 0x00000001054b2e34 _dispatch_lane_invoke + 420 17 libdispatch.dylib 0x00000001054bfcbc _dispatch_workloop_worker_thread + 740 18 libsystem_pthread.dylib 0x00000001e5615df8 _pthread_wqthread + 288 19 libsystem_pthread.dylib 0x00000001e5615b98 start_wqthread + 8 2023-07-31 11:04:41.342079+0200 App[969:172129] [reports] Main Thread Checker: UI API called on a background thread: -[UIWindow rootViewController] PID: 969, TID: 172129, Thread name: (none), Queue name: bridge, QoS: 0 Backtrace: 4 Sentry 0x0000000105737eac -[SentryUIViewControllerSwizzling swizzleRootViewControllerFromUIApplication:] + 592 5 Sentry 0x0000000105736f3c -[SentryUIViewControllerSwizzling start] + 80 6 Sentry 0x00000001056fe434 -[SentryPerformanceTrackingIntegration installWithOptions:] + 456 7 Sentry 0x0000000105715bd4 +[SentrySDK installIntegrations] + 832 8 Sentry 0x0000000105714208 +[SentrySDK startWithOptionsObject:] + 440 9 SentryCapacitor 0x00000001050f4d18 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCF + 608 10 SentryCapacitor 0x00000001050f57b4 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCFTo + 52 11 Capacitor 0x0000000104dc7fd0 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0VtFyycfU0 + 856 12 Capacitor 0x0000000104dbc478 $sIeg_IeyB_TR + 48 13 libdispatch.dylib 0x00000001054a85a8 _dispatch_call_block_and_release + 32 14 libdispatch.dylib 0x00000001054aa05c _dispatch_client_callout + 20 15 libdispatch.dylib 0x00000001054b210c _dispatch_lane_serial_drain + 988 16 libdispatch.dylib 0x00000001054b2e34 _dispatch_lane_invoke + 420 17 libdispatch.dylib 0x00000001054bfcbc _dispatch_workloop_worker_thread + 740 18 libsystem_pthread.dylib 0x00000001e5615df8 _pthread_wqthread + 288 19 libsystem_pthread.dylib 0x00000001e5615b98 start_wqthread + 8 ⚡️ To Native -> SentryCapacitor addBreadcrumb 112770272

Main Thread Checker: UI API called on a background thread: -[UIViewController childViewControllers] PID: 969, TID: 172129, Thread name: (none), Queue name: bridge, QoS: 0 Backtrace: 4 Sentry 0x000000010573c388 -[UIViewController(Sentry) sentry_descendantViewControllers] + 80 5 Sentry 0x0000000105737fec -[SentryUIViewControllerSwizzling swizzleRootViewControllerAndDescendant:] + 72 6 Sentry 0x0000000105737f58 -[SentryUIViewControllerSwizzling swizzleRootViewControllerFromUIApplication:] + 764 7 Sentry 0x0000000105736f3c -[SentryUIViewControllerSwizzling start] + 80 8 Sentry 0x00000001056fe434 -[SentryPerformanceTrackingIntegration installWithOptions:] + 456 9 Sentry 0x0000000105715bd4 +[SentrySDK installIntegrations] + 832 10 Sentry 0x0000000105714208 +[SentrySDK startWithOptionsObject:] + 440 11 SentryCapacitor 0x00000001050f4d18 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCF + 608 12 SentryCapacitor 0x00000001050f57b4 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCFTo + 52 13 Capacitor 0x0000000104dc7fd0 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0VtFyycfU0 + 856 14 Capacitor 0x0000000104dbc478 $sIeg_IeyB_TR + 48 15 libdispatch.dylib 0x00000001054a85a8 _dispatch_call_block_and_release + 32 16 libdispatch.dylib 0x00000001054aa05c _dispatch_client_callout + 20 17 libdispatch.dylib 0x00000001054b210c _dispatch_lane_serial_drain + 988 18 libdispatch.dylib 0x00000001054b2e34 _dispatch_lane_invoke + 420 19 libdispatch.dylib 0x00000001054bfcbc _dispatch_workloop_worker_thread + 740 20 libsystem_pthread.dylib 0x00000001e5615df8 _pthread_wqthread + 288 21 libsystem_pthread.dylib 0x00000001e5615b98 start_wqthread + 8 2023-07-31 11:04:41.463434+0200 App[969:172129] [reports] Main Thread Checker: UI API called on a background thread: -[UIViewController childViewControllers] PID: 969, TID: 172129, Thread name: (none), Queue name: bridge, QoS: 0 Backtrace: 4 Sentry 0x000000010573c388 -[UIViewController(Sentry) sentry_descendantViewControllers] + 80 5 Sentry 0x0000000105737fec -[SentryUIViewControllerSwizzling swizzleRootViewControllerAndDescendant:] + 72 6 Sentry 0x0000000105737f58 -[SentryUIViewControllerSwizzling swizzleRootViewControllerFromUIApplication:] + 764 7 Sentry 0x0000000105736f3c -[SentryUIViewControllerSwizzling start] + 80 8 Sentry 0x00000001056fe434 -[SentryPerformanceTrackingIntegration installWithOptions:] + 456 9 Sentry 0x0000000105715bd4 +[SentrySDK installIntegrations] + 832 10 Sentry 0x0000000105714208 +[SentrySDK startWithOptionsObject:] + 440 11 SentryCapacitor 0x00000001050f4d18 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCF + 608 12 SentryCapacitor 0x00000001050f57b4 $s15SentryCapacitorAAC13initNativeSdkyySo13CAPPluginCallCFTo + 52 13 Capacitor 0x0000000104dc7fd0 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0VtFyycfU0 + 856 14 Capacitor 0x0000000104dbc478 $sIeg_IeyB_TR + 48 15 libdispatch.dylib 0x00000001054a85a8 _dispatch_call_block_and_release + 32 16 libdispatch.dylib 0x00000001054aa05c _dispatch_client_callout + 20 17 libdispatch.dylib 0x00000001054b210c _dispatch_lane_serial_drain + 988 18 libdispatch.dylib 0x00000001054b2e34 _dispatch_lane_invoke + 420 19 libdispatch.dylib 0x00000001054bfcbc _dispatch_workloop_worker_thread + 740 20 libsystem_pthread.dylib 0x00000001e5615df8 _pthread_wqthread + 288 21 libsystem_pthread.dylib 0x00000001e5615b98 start_wqthread + 8

github-actions[bot] commented 1 year ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

lucas-zimerman commented 1 year ago

Hey @beppemac sorry for the late response.

Could you try altering the initNativeSdk function from Plugin.swift by adding

DispatchQueue.main.async { [weak self] in
... initialization code
}

And see if the problem still happens?

ghost commented 1 year ago

Thank you for the suggestion @lucas-zimerman

I put under DispatchQueue Async only the call to the SentrySDK.start method and the error in XCode console seems to no longer appear.

Basically I edited the initNativeSdk function in Plugin.swift from

SentrySDK.start(options: options)

to

DispatchQueue.main.async { [weak self] in
    SentrySDK.start(options: options)
}
lucas-zimerman commented 1 year ago

You're welcome I'll discuss with the internal team if this is the best way to deal with this case on the official release but it should run without any issues for now.