urbanairship / ios-library

Urban Airship iOS SDK
http://urbanairship.com
Apache License 2.0
478 stars 265 forks source link

Crash in SDK 17.1.1 #372

Closed WJacobsNL closed 1 year ago

WJacobsNL commented 1 year ago

❗For how-to inquiries involving Airship functionality or use cases, please contact (support)[https://support.airship.com/].

Preliminary Info

What Airship dependencies are you using?

SDK 17.1.1 via SPM

What are the versions of any relevant development tools you are using?

Xcode 14.3.1

Report

We see crashes being reported on our production app after upgrading Airship to version 17.1.1 I've included the relevant bit of the crash report below.

Crashed: com.apple.root.user-initiated-qos.cooperative
0  bol.com                        0x3f557c specialized static Airship.requireComponent<A>(ofType:) + 4380824956
1  bol.com                        0x5ef624 specialized RemoteConfigModuleAdapter.components(_:) + 152 (Airship.swift:152)
2  bol.com                        0x5e87b0 specialized Sequence.forEach(_:) + 4382869424
3  bol.com                        0x5e6f18 RemoteConfigManager.applyDisableInfos(_:) + 103 (RemoteConfigManager.swift:103)
4  bol.com                        0x5e6818 RemoteConfigManager.processRemoteConfig(_:) + 59 (RemoteConfigManager.swift:59)
5  bol.com                        0x5e81c0 closure #1 in closure #1 in RemoteConfigManager.updateRemoteConfigSubscription() + 164 (RemoteConfigManager.swift:164)
6  Combine                        0xaf44 Subscribers.Sink.receive(_:) + 96
7  Combine                        0xaa60 protocol witness for Subscriber.receive(_:) in conformance Subscribers.Sink<A, B> + 24
8  Combine                        0x33e98 FilterProducer.receive(_:) + 2520
9  Combine                        0x1ca4c protocol witness for Subscriber.receive(_:) in conformance FilterProducer<A, B, C, D, E> + 24
10 Combine                        0x367d4 Publishers.Concatenate.Inner.prefixReceive(_:) + 340
11 Combine                        0x7eb8 Publishers.Concatenate.Inner.PrefixSubscriber.receive(_:) + 24
12 Combine                        0x2856c Future.Conduit.fulfill(_:) + 1928
13 Combine                        0x8014 Future.Conduit.offer(_:) + 336
14 Combine                        0x7990 partial apply for closure #1 in Future.promise(_:) + 68
15 Combine                        0x26d6c ConduitList.forEach(_:) + 272
16 Combine                        0x38f20 Future.promise(_:) + 1284
17 Combine                        0x76b0 partial apply for closure #1 in Future.init(_:) + 28
18 bol.com                        0x5f5ae4 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<[RemoteDataPayload], Never>) -> () + 4382923492 (<compiler-generated>:4382923492)
19 bol.com                        0x5f3220 closure #1 in closure #1 in RemoteData.payloadsFuture(types:) + 401 (RemoteData.swift:401)
20 libswift_Concurrency.dylib     0x41948 swift::runJobInEstablishedExecutorContext(swift::Job*) + 416
21 libswift_Concurrency.dylib     0x42868 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 72
22 libdispatch.dylib              0x15944 _dispatch_root_queue_drain + 396
23 libdispatch.dylib              0x16158 _dispatch_worker_thread2 + 164
24 libsystem_pthread.dylib        0xda0 _pthread_wqthread + 228
25 libsystem_pthread.dylib        0xb7c start_wqthread + 8
oristanovic commented 1 year ago

Thanks for the report, we're looking into this

oristanovic commented 1 year ago

How many users does this crash affect and is it reproducible on your side? Could you share the integration code?

WJacobsNL commented 1 year ago

I have not been able to reproduce, but it is our new #1 crash (affected about 30 customers this week, so still low percentage). Since I'm not sure which part of Airship is calling this code, I'm not sure what to share

WJacobsNL commented 1 year ago

Crashlytics does report a second "variant", stack trace looks like this:

Crashed: com.apple.main-thread
0  bol.com                        0x3f557c specialized static Airship.requireComponent<A>(ofType:) + 4338390396
1  bol.com                        0x5ef664 specialized RemoteConfigModuleAdapter.components(_:) + 163 (Airship.swift:163)
2  bol.com                        0x5e87b0 specialized Sequence.forEach(_:) + 4340434864
3  bol.com                        0x5e6f18 RemoteConfigManager.applyDisableInfos(_:) + 103 (RemoteConfigManager.swift:103)
4  bol.com                        0x5e6818 RemoteConfigManager.processRemoteConfig(_:) + 59 (RemoteConfigManager.swift:59)
5  bol.com                        0x5e81c0 closure #1 in closure #1 in RemoteConfigManager.updateRemoteConfigSubscription() + 164 (RemoteConfigManager.swift:164)
6  Combine                        0x9034 Subscribers.Sink.receive(_:) + 88
7  Combine                        0x8b0c protocol witness for Subscriber.receive(_:) in conformance Subscribers.Sink<A, B> + 20
8  Combine                        0x288dc FilterProducer.receive(_:) + 1724
9  Combine                        0x16884 protocol witness for Subscriber.receive(_:) in conformance FilterProducer<A, B, C, D, E> + 20
10 Combine                        0x2a668 Publishers.Concatenate.Inner.prefixReceive(_:) + 232
11 Combine                        0x63f4 Publishers.Concatenate.Inner.PrefixSubscriber.receive(_:) + 20
12 Combine                        0x2b194 Future.Conduit.request(_:) + 1660
13 Combine                        0x69c0 protocol witness for Subscription.request(_:) in conformance ConduitBase<A, B> + 28
14 Combine                        0x24a24 Publishers.Concatenate.Inner.request(_:) + 296
15 Combine                        0x2f0b4 protocol witness for Subscription.request(_:) in conformance Publishers.Concatenate<A, B>.Inner<A1> + 20
16 Combine                        0x2e400 FilterProducer.request(_:) + 244
17 Combine                        0x33a30 protocol witness for Subscription.request(_:) in conformance FilterProducer<A, B, C, D, E> + 20
18 Combine                        0x5da8 Subscribers.Sink.receive(subscription:) + 280
19 Combine                        0x4270 protocol witness for Subscriber.receive(subscription:) in conformance Subscribers.Sink<A, B> + 20
20 Combine                        0x136fc FilterProducer.receive(subscription:) + 360
21 Combine                        0x3754c protocol witness for Subscriber.receive(subscription:) in conformance FilterProducer<A, B, C, D, E> + 20
22 Combine                        0x40bcc Publishers.Concatenate.Inner.prefixReceive(subscription:) + 328
23 Combine                        0x3264c Publishers.Concatenate.Inner.PrefixSubscriber.receive(subscription:) + 20
24 Combine                        0x24884 Future.Conduit.subscribe() + 1004
25 Combine                        0xeb84 Future.receive<A>(subscriber:) + 844
26 Combine                        0xcc04 protocol witness for Publisher.receive<A>(subscriber:) in conformance Future<A, B> + 20
27 Combine                        0x379ec Publishers.Concatenate.receive<A>(subscriber:) + 356
28 Combine                        0x1cb24 PublisherBox.receive<A>(subscriber:) + 36
29 Combine                        0x2a60 AnyPublisher.receive<A>(subscriber:) + 36
30 Combine                        0x1f0c8 Publishers.RemoveDuplicates.receive<A>(subscriber:) + 368
31 Combine                        0x10250 Publisher<>.sink(receiveValue:) + 276
32 bol.com                        0x5e80f4 closure #1 in RemoteConfigManager.updateRemoteConfigSubscription() + 163 (RemoteConfigManager.swift:163)
33 bol.com                        0x41fb34 specialized RemoteConfigManager.init(remoteData:privacyManager:moduleAdapter:notificationCenter:appVersion:) + 14 (Lock.swift:14)
34 bol.com                        0x414ffc AirshipInstance.init(config:) + 30 (RemoteConfigManager.swift:30)
35 bol.com                        0x3f5724 specialized static Airship.commonTakeOff(_:) + 4338390820 (AirshipInstance.swift:4338390820)
36 bol.com                        0x3f5ce0 specialized static Airship.takeOff(_:launchOptions:) + 234 (Airship.swift:234)
37 bol.com                        0x17c8e4 static PushMessageHelper.createAirshipConfiguration(launchOptions:) + 36 (PushMessageHelper.swift:36)
38 bol.com                        0x399664 AppDelegate.startup(launchOptions:) + 52 (AppDelegate+Startup.swift:52)
39 bol.com                        0x34aba4 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 59 (AppDelegate.swift:59)
40 UIKitCore                      0x331ab8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 296
41 UIKitCore                      0x3311fc -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 2776
42 UIKitCore                      0x330230 -[UIApplication _runWithMainScene:transitionContext:completion:] + 852
43 UIKitCore                      0x32fe90 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 128
44 UIKitCore                      0x96a40 _UIScenePerformActionsWithLifecycleActionMask + 92
45 UIKitCore                      0x3b0a48 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 188
46 UIKitCore                      0x270e8c -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 212
47 UIKitCore                      0x270cbc -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 588
48 UIKitCore                      0x27088c -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 248
49 UIKitCore                      0x27076c __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 140
50 UIKitCore                      0x8e6330 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 656
51 UIKitCore                      0x974cc8 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 196
52 UIKitCore                      0x12dc34 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 288
53 UIKitCore                      0x5642e4 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.189 + 552
54 UIKitCore                      0x1f5918 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 208
55 UIKitCore                      0x1f57ac -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220
56 UIKitCore                      0x1f4d18 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 496
57 UIKitCore                      0x1f4abc -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 260
58 FrontBoardServices             0x25d4 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 316
59 FrontBoardServices             0x3bd50 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke.59 + 92
60 FrontBoardServices             0x5f70 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 160
61 FrontBoardServices             0x3b9d8 __92-[FBSWorkspaceScenesClient createSceneWithIdentity:parameters:transitionContext:completion:]_block_invoke + 296
62 libdispatch.dylib              0x647c8 _dispatch_client_callout + 16
63 libdispatch.dylib              0x3c408 _dispatch_block_invoke_direct$VARIANT$armv81 + 212
64 FrontBoardServices             0xf474 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 44
65 FrontBoardServices             0xf0b0 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176
66 FrontBoardServices             0x11574 -[FBSSerialQueue _performNextFromRunLoopSource] + 24
67 CoreFoundation                 0xcc2b8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
68 CoreFoundation                 0xd7c18 __CFRunLoopDoSource0 + 172
69 CoreFoundation                 0x61fa8 __CFRunLoopDoSources0 + 232
70 CoreFoundation                 0x76fb0 __CFRunLoopRun + 780
71 CoreFoundation                 0x7bb7c CFRunLoopRunSpecific + 584
72 GraphicsServices               0x1984 GSEventRunModal + 160
73 UIKitCore                      0x3753c8 -[UIApplication _run] + 868
74 UIKitCore                      0x375040 UIApplicationMain + 312
75 bol.com                        0x34c8bc main + 15 (AppDelegate.swift:15)
76 ???                            0x1ba538df0 (Missing)
rlepinski commented 1 year ago

@WJacobsNL Could you provide the code you are using for takeOff ? Is Airship being called before applicationDidFinishLaunching returns or is it put off on another runloop?

WJacobsNL commented 1 year ago

Our call to takeOff is part of a helperMethod that is being called from within applicationDidFinishLaunching In this function we create the configuration and pass it on. This function is annotated with @MainActor, due to the @MainActor annotation on takeOff. We don't actually send it to another runloop though

(Sorry, am not allowed to share the actual code here)

The gist of it looks like this though:

@MainActor
    static func createAirshipConfiguration(launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) {
        let config = AirshipConfig.default()
        // setup config 
        Airship.takeOff(config, launchOptions: launchOptions)
        Airship.push.resetBadge()
        Airship.shared.privacyManager.enableFeatures(.all)

        let appDelegate = UIApplication.shared.delegate as? AppDelegate
        Airship.shared.deepLinkDelegate = appDelegate
}
rlepinski commented 1 year ago

I am sure its fine, but just to be sure, your applicationDidFinishLaunching you are calling createAirshipConfiguration(launchOptions:) directly without a Task right?

WJacobsNL commented 1 year ago

Correct, just a plain call site

rlepinski commented 1 year ago

I think I found the issue. Its a race condition between takeOff finishing loading (should be really fast) and a database read. I was only able to reproduce it with a Thread.sleep. I don't expect this to happen very often and surprised it could happen at all, but will have a fix for you. We have a release going out Monday. I will see if I can move that up.

WJacobsNL commented 1 year ago

Thanks, that’d be great! Then we can add it to our release of Monday ;)

rlepinski commented 1 year ago

17.2.0 is out with the fix

WJacobsNL commented 1 year ago

Our new release hasn't shown the same crash up until now, thanks for the quick fix!