braze-inc / braze-swift-sdk

Braze SDK for the Apple ecosystem, including: iOS, macOS, iPadOS, visionOS, tvOS
https://www.braze.com
Other
52 stars 19 forks source link

[Bug]: Occasional crash when entering foreground after being backgrounded #145

Open pyrtsa opened 1 week ago

pyrtsa commented 1 week ago

Platform

iOS

Platform Version

iOS 16.7.10

Braze SDK Version

11.0.0

Xcode Version

16.0

Computer Processor

Apple (M1)

Repro Rate

Rarely

Steps To Reproduce

We have a low number of crashes reported where the app had been in the background for some time and just being brought to foreground by the user. The crash log points inside Braze SDK running on a background queue named com.braze.core; see stack trace excerpt under Verbose Logs.

Expected Behavior

The app should not crash.

Actual Incorrect Behavior

💥 EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010

Verbose Logs

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010

Crashed: com.braze.core

com.apple.main-thread
0  (redacted)                     0x73084 (redacted)
1  (redacted)                     0x21818 (redacted)
2  (redacted)                     0x18ec0 (redacted)
3  CoreFoundation                 0x347c4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 120
4  CoreFoundation                 0xd10c0 ___CFXRegistrationPost_block_invoke + 84
5  CoreFoundation                 0xb58a8 _CFXRegistrationPost + 404
6  CoreFoundation                 0x47eec _CFXNotificationPost + 680
7  Foundation                     0x57fd4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
8  UIKitCore                      0x18e198 <redacted> + 220
9  UIKitCore                      0x18dd3c <redacted> + 1180
10 UIKitCore                      0x94bf8 _UIScenePerformActionsWithLifecycleActionMask + 96
11 UIKitCore                      0x3aabcc <redacted> + 188
12 UIKitCore                      0x26cde4 <redacted> + 212
13 UIKitCore                      0x26cc14 <redacted> + 588
14 UIKitCore                      0x26c7e4 <redacted> + 248
15 UIKitCore                      0x26c6c4 <redacted> + 140
16 UIKitCore                      0x8eba7c <redacted> + 656
17 UIKitCore                      0x97f7b8 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 196
18 UIKitCore                      0x12b13c <redacted> + 288
19 UIKitCore                      0x55f3b0 <redacted> + 552
20 UIKitCore                      0x1f173c <redacted> + 208
21 UIKitCore                      0x1f15d0 <redacted> + 220
22 UIKitCore                      0x1f142c <redacted> + 308
23 FrontBoardServices             0x3c40 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 392
24 FrontBoardServices             0x3a98 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 124
25 FrontBoardServices             0x6efc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 160
26 FrontBoardServices             0x6e24 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 312
27 libdispatch.dylib              0x64780 _dispatch_client_callout + 16
28 libdispatch.dylib              0x3c2d0 _dispatch_block_invoke_direct$VARIANT$armv81 + 212
29 FrontBoardServices             0x10410 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 44
30 FrontBoardServices             0x1004c -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176
31 FrontBoardServices             0x12600 -[FBSSerialQueue _performNextFromRunLoopSource] + 24
32 CoreFoundation                 0xc90e8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
33 CoreFoundation                 0xd4d5c __CFRunLoopDoSource0 + 172
34 CoreFoundation                 0x5ffc4 __CFRunLoopDoSources0 + 232
35 CoreFoundation                 0x75138 __CFRunLoopRun + 784
36 CoreFoundation                 0x79d20 CFRunLoopRunSpecific + 584
37 GraphicsServices               0x1998 GSEventRunModal + 160
38 UIKitCore                      0x37134c <redacted> + 868
39 UIKitCore                      0x370fc4 UIApplicationMain + 312
40 SwiftUI                        0x183c68 OUTLINED_FUNCTION_895 + 2184
41 SwiftUI                        0xfdf1c block_copy_helper.1 + 452
42 SwiftUI                        0xeaf6c OUTLINED_FUNCTION_901 + 2312
43 (redacted)                     0x8678 main + 4370335352 (redacted)
44 ???                            0x1f9890344 (Missing)

[...]

Crashed: com.braze.core
0  (redacted)                     0xfab544 Cancellable.cancel() + 4386731332
1  (redacted)                     0xfd0efc closure #1 in closure #2 in closure #1 in Effect.cancellable(id:cancelInFlight:) + 4386885372
2  (redacted)                     0xfd0e0c closure #2 in closure #1 in Effect.cancellable(id:cancelInFlight:) + 4386885132
3  (redacted)                     0xfab558 Cancellable.cancel() + 4386731352
4  (redacted)                     0xfd12f8 closure #4 in closure #1 in Effect.cancellable(id:cancelInFlight:) + 4386886392
5  (redacted)                     0xfbd528 closure #1 in closure #1 in PublisherType.handleEvents(ncombine_receiveSubscriber:ncombine_receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:ncombine_receiveRequest:) + 4386805032
6  (redacted)                     0xfc8038 Subscriber.receive(completion:) + 4386848824
7  (redacted)                     0xfc6ed8 partial apply for closure #1 in Subject.send(completion:) + 4386844376
8  libswiftCore.dylib             0xaecf0 Sequence.forEach(_:) + 492
9  (redacted)                     0xfc6d6c Subject.send(completion:) + 4386844012
10 (redacted)                     0xfd0ed0 closure #1 in closure #2 in closure #1 in Effect.cancellable(id:cancelInFlight:) + 4386885328
11 (redacted)                     0xfd0e0c closure #2 in closure #1 in Effect.cancellable(id:cancelInFlight:) + 4386885132
12 (redacted)                     0xfab558 Cancellable.cancel() + 4386731352
13 (redacted)                     0xfbd668 closure #3 in closure #1 in PublisherType.handleEvents(ncombine_receiveSubscriber:ncombine_receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:ncombine_receiveRequest:) + 4386805352
14 (redacted)                     0xfab610 Cancellable.deinit + 4386731536
15 (redacted)                     0xfab648 Cancellable.__deallocating_deinit + 4386731592
16 libswiftCore.dylib             0x2f7184 _swift_release_dealloc + 28
17 libswiftCore.dylib             0x2f8060 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 184
18 libswiftCore.dylib             0x48060 Dictionary.subscript.setter + 260
19 (redacted)                     0xfc0e8c Publisher.unsubscribe(_:) + 4386819724
20 (redacted)                     0xfc121c protocol witness for PublisherType.unsubscribe(_:) in conformance Publisher<A, B> + 4386820636
21 (redacted)                     0xfb3534 partial apply for closure #1 in PublisherType.sink(name:receiveCompletion:receiveValue:) + 4386764084
22 (redacted)                     0xfab610 Cancellable.deinit + 4386731536
23 (redacted)                     0xfab648 Cancellable.__deallocating_deinit + 4386731592
24 libswiftCore.dylib             0x2f7184 _swift_release_dealloc + 28
25 libswiftCore.dylib             0x2f8060 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 184
26 libswiftCore.dylib             0x48060 Dictionary.subscript.setter + 260
27 (redacted)                     0xfc0e8c Publisher.unsubscribe(_:) + 4386819724
28 (redacted)                     0xfc121c protocol witness for PublisherType.unsubscribe(_:) in conformance Publisher<A, B> + 4386820636
29 (redacted)                     0xfb3534 partial apply for closure #1 in PublisherType.sink(name:receiveCompletion:receiveValue:) + 4386764084
30 (redacted)                     0xfab610 Cancellable.deinit + 4386731536
31 (redacted)                     0xfab648 Cancellable.__deallocating_deinit + 4386731592
32 libswiftCore.dylib             0x2f7184 _swift_release_dealloc + 28
33 libswiftCore.dylib             0x2f8060 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 184
34 libswiftCore.dylib             0x48060 Dictionary.subscript.setter + 260
35 (redacted)                     0xfc0e8c Publisher.unsubscribe(_:) + 4386819724
36 (redacted)                     0xfab484 closure #2 in closure #1 in PublisherType.append(_:) + 4386731140
37 (redacted)                     0xfab610 Cancellable.deinit + 4386731536
38 (redacted)                     0xfab648 Cancellable.__deallocating_deinit + 4386731592
39 libswiftCore.dylib             0x2f7184 _swift_release_dealloc + 28
40 libswiftCore.dylib             0x2f8060 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 184
41 libswiftCore.dylib             0x48060 Dictionary.subscript.setter + 260
42 (redacted)                     0xfc0e8c Publisher.unsubscribe(_:) + 4386819724
43 (redacted)                     0xfc121c protocol witness for PublisherType.unsubscribe(_:) in conformance Publisher<A, B> + 4386820636
44 (redacted)                     0xfb3534 partial apply for closure #1 in PublisherType.sink(name:receiveCompletion:receiveValue:) + 4386764084
45 (redacted)                     0xfab610 Cancellable.deinit + 4386731536
46 (redacted)                     0xfab648 Cancellable.__deallocating_deinit + 4386731592
47 libswiftCore.dylib             0x2f7184 _swift_release_dealloc + 28
48 libswiftCore.dylib             0x2f8060 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 184
49 libswiftCore.dylib             0x48060 Dictionary.subscript.setter + 260
50 (redacted)                     0xfc0e8c Publisher.unsubscribe(_:) + 4386819724
51 (redacted)                     0xfc121c protocol witness for PublisherType.unsubscribe(_:) in conformance Publisher<A, B> + 4386820636
52 (redacted)                     0xfc6130 closure #1 in PublisherType.cancellableSink(name:receiveCompletion:receiveValue:) + 4386840880
53 (redacted)                     0xfab558 Cancellable.cancel() + 4386731352
54 (redacted)                     0xfc0970 closure #1 in closure #1 in PublisherType.innerOutput(name:in:) + 4386818416
55 (redacted)                     0xfc6540 closure #2 in closure #2 in PublisherType.cancellableSink(name:receiveCompletion:receiveValue:) + 4386841920
56 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
57 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
58 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
59 (redacted)                     0xfbd610 partial apply for closure #2 in closure #1 in PublisherType.handleEvents(ncombine_receiveSubscriber:ncombine_receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:ncombine_receiveRequest:) + 4386805264
60 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
61 (redacted)                     0xfc6e58 partial apply for closure #1 in Subject.send(_:) + 4386844248
62 libswiftCore.dylib             0xaecf0 Sequence.forEach(_:) + 492
63 (redacted)                     0xfc6a34 Subject.send(_:) + 4386843188
64 (redacted)                     0xfc1468 partial apply for implicit closure #4 in implicit closure #3 in PublisherType.subscribe(_:) + 4386821224
65 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
66 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
67 (redacted)                     0xfab510 partial apply for implicit closure #2 in implicit closure #1 in closure #1 in PublisherType.mapError<A>(_:) + 4386731280
68 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
69 (redacted)                     0xfc7fd8 Subscriber.receive(_:) + 4386848728
70 (redacted)                     0xfc6e58 partial apply for closure #1 in Subject.send(_:) + 4386844248
71 libswiftCore.dylib             0xaecf0 Sequence.forEach(_:) + 492
72 (redacted)                     0xfc6a34 Subject.send(_:) + 4386843188
73 (redacted)                     0xfd0568 closure #1 in closure #2 in Publishers.Timer.init(every:tolerance:scheduler:options:) + 4386882920
74 (redacted)                     0x277150 thunk for @escaping @callee_guaranteed @Sendable () -> () + 4372885840 (<compiler-generated>:4372885840)
75 libdispatch.dylib              0x64780 _dispatch_client_callout + 16
76 libdispatch.dylib              0x3bd48 _dispatch_continuation_pop$VARIANT$armv81 + 436
77 libdispatch.dylib              0x4d780 _dispatch_source_invoke$VARIANT$armv81 + 1552
78 libdispatch.dylib              0x3f5d4 _dispatch_lane_serial_drain$VARIANT$armv81 + 304
79 libdispatch.dylib              0x401b0 _dispatch_lane_invoke$VARIANT$armv81 + 380
80 libdispatch.dylib              0x49f14 _dispatch_workloop_worker_thread + 608
81 libsystem_pthread.dylib        0x1bd0 _pthread_wqthread + 284
82 libsystem_pthread.dylib        0x1720 start_wqthread + 8

Additional Information

No response

jerielng commented 1 week ago

Hi @pyrtsa, could you write in to support@braze.com with this stack trace along with any additional details of your Braze integration (i.e. which features you are using, any sample code you may have)? And to clarify, could you also confirm if you are seeing this same stack trace for each crash that is being reported?

Thanks!