OneSignal / OneSignal-iOS-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native iOS app with OneSignal. https://onesignal.com
Other
496 stars 263 forks source link

[Bug]: OneSignalOSCore __swift_instantiateConcreteTypeFromMangledName Crash #1368

Closed danhalliday closed 6 months ago

danhalliday commented 9 months ago

What happened?

iOS app crashed in production with a stack trace showing OneSignal frames.

Steps to reproduce?

No idea. This is a remote crash report from Crashlytics.

What did you expect to happen?

The library should not cause a crash, regardless of what I may be doing wrong in using it.

OneSignal iOS SDK version

5.1.0

iOS version

11 or below

Specific iOS version

* 17.2.1

Relevant log output

Crashed: com.apple.main-thread
0  OneSignalOSCore                0x8c9c __swift_instantiateConcreteTypeFromMangledName + 3788
1  OneSignalUser                  0x86fc __swift_project_boxed_opaque_existential_1 + 14568
2  OneSignalFramework             0xd54c +[OneSignalTracker applicationBackgrounded] + 276
3  CoreFoundation                 0x2f2d8 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
4  CoreFoundation                 0x2eca0 ___CFXRegistrationPost_block_invoke + 88
5  CoreFoundation                 0x2ebe8 _CFXRegistrationPost + 440
6  CoreFoundation                 0x2e138 _CFXNotificationPost + 724
7  Foundation                     0x2a7a4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
8  UIKitCore                      0x2110cc -[UIApplication _deactivateForReason:notify:] + 1216
9  UIKitCore                      0x13abb4 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 176
10 UIKitCore                      0x139658 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 608
11 UIKitCore                      0x138fc0 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 248
12 UIKitCore                      0x138e90 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 148
13 UIKitCore                      0x138d98 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 736
14 UIKitCore                      0x138620 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 224
15 UIKitCore                      0x1382d0 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 316
16 UIKitCore                      0x4bc0a8 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.225 + 612
17 UIKitCore                      0x137454 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 216
18 UIKitCore                      0x1372c4 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 244
19 UIKitCore                      0x137104 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 336
20 FrontBoardServices             0xe5b4 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 660
21 FrontBoardServices             0xe300 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 152
22 FrontBoardServices             0xe19c -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168
23 FrontBoardServices             0xe0b8 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 344
24 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
25 libdispatch.dylib              0x7d48 _dispatch_block_invoke_direct + 284
26 FrontBoardServices             0xa520 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 52
27 FrontBoardServices             0xa4a0 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240
28 FrontBoardServices             0xa378 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28
29 CoreFoundation                 0x3712c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
30 CoreFoundation                 0x363a8 __CFRunLoopDoSource0 + 176
31 CoreFoundation                 0x34b5c __CFRunLoopDoSources0 + 244
32 CoreFoundation                 0x33898 __CFRunLoopRun + 828
33 CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
34 GraphicsServices               0x34f8 GSEventRunModal + 164
35 UIKitCore                      0x22c62c -[UIApplication _run] + 888
36 UIKitCore                      0x22bc68 UIApplicationMain + 340
37 SwiftUI                        0x11664b8 OUTLINED_FUNCTION_31 + 604
38 SwiftUI                        0x11662fc OUTLINED_FUNCTION_31 + 160
39 SwiftUI                        0xdd6e90 OUTLINED_FUNCTION_26 + 2196
40 MY_APP_NAME                    0x8adf4 main + 4364217844 (MY_APP_NAME.swift:4364217844)
41 ???                            0x1caf16dcc (Missing)

Code of Conduct

nan-li commented 9 months ago

Hi @danhalliday, thanks for reporting.

Is this all the information from the crash log?

Is there any information about what the error is like this:

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000102afb3d0

I don't have enough information to figure out what is happening here. Do you have any more information or other stack traces?

0  OneSignalOSCore                0x8c9c __swift_instantiateConcreteTypeFromMangledName + 3788
1  OneSignalUser                  0x86fc __swift_project_boxed_opaque_existential_1 + 14568

Additionally, how many users / what percent of users have been affected by this crash?

Notes to self: looks like it may be in the method flushDeltaQueue.

danhalliday commented 8 months ago

@nan-li Yes I’m afraid this is all I have from Crashlytics and the crash is rare enough that I never see it in development (but common enough with thousands of users that it’s a very real problem). Judging by your WIP PR it looks like there’s just a lot of code that isn’t thread safe, which is super disappointing.

What can I do from my side while the thread safety fixes are ongoing? Is it worth me locking around my calls to the SDK? Or is that not going to help because the issue is concurrent access to shared resources from threads within the SDK? Will it help for me to make all my SDK calls on the main thread?

danhalliday commented 8 months ago

@nan-li This one looks promising for 5.1.3. Not seen it again yet.

ethanwa commented 8 months ago

Saw this today from 5.1.3 in my Firebase. I think it's the same crash? Maybe not?

Crashed: OneSignal.OSOperationRepo
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010

0  libobjc.A.dylib                0x4820 objc_msgSend + 32
1  Foundation                     0x21b30 <redacted> + 180
2  OneSignalUser                  0x12a14 __swift_destroy_boxed_opaque_existential_0 + 6928
3  OneSignalUser                  0x12a74 __swift_destroy_boxed_opaque_existential_0 + 7024
4  Foundation                     0x21f18 <redacted> + 1180
5  OneSignalOSCore                0xe634 __swift_destroy_boxed_opaque_existential_0 + 5612
6  OneSignalOSCore                0xe748 __swift_destroy_boxed_opaque_existential_0 + 5888
7  Foundation                     0x21f18 <redacted> + 1180
8  Foundation                     0x218b8 <redacted> + 460
9  Foundation                     0x54008 <redacted> + 588
10 Foundation                     0x21f18 <redacted> + 1180
11 Foundation                     0x6e766c <redacted> + 104
12 OneSignalCore                  0xd69c -[OneSignalUserDefaults saveCodeableDataForKey:withValue:] + 88
13 OneSignalOSCore                0x7db4 __swift_instantiateConcreteTypeFromMangledName + 2856
14 OneSignalOSCore                0x763c __swift_instantiateConcreteTypeFromMangledName + 944
15 libdispatch.dylib              0x26a8 <redacted> + 32
16 libdispatch.dylib              0x4300 <redacted> + 20
17 libdispatch.dylib              0xb894 <redacted> + 748
18 libdispatch.dylib              0xc3c4 <redacted> + 380
19 libdispatch.dylib              0x17004 <redacted> + 288
20 libdispatch.dylib              0x16878 <redacted> + 404
21 libsystem_pthread.dylib        0x1964 _pthread_wqthread + 288
22 libsystem_pthread.dylib        0x1a04 start_wqthread + 8
danhalliday commented 8 months ago

@ethanwa I think your crash is more likely this: https://github.com/OneSignal/OneSignal-iOS-SDK/issues/1365? Or perhaps they are the same root cause. There’s some very bad stuff going on with OneSignal’s user default implementation...

ihijazi commented 7 months ago

I'm having the same issue. I've posted also about another issue which might be relevant but still no updated on it: https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/858

One thing I noted is the crash happens when not using cellular data (i.e not WiFi)

nan-li commented 6 months ago

Hi @danhalliday thank you for following up this particular stacktrace seems resolved. I'll close out this issue and follow up with the rest of the crash reports.

HI @ethanwa, your stack trace looks exactly like this post: https://github.com/OneSignal/OneSignal-iOS-SDK/issues/1409. We released a fix for this crash in Release 5.1.6. Please update and let us know if your crashes are resolved, or what crashes are still ongoing.