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]: prepareAndPresent stack.removeAll { $0.isApproximatelyEqual(to: message) } throwing an error #109

Open joaosouza-traxretail opened 9 months ago

joaosouza-traxretail commented 9 months ago

Platform

iOS

Platform Version

17.2

Braze SDK Version

8.0.1

Xcode Version

15.2

Computer Processor

Apple (M1)

Repro Rate

100% of the time

Steps To Reproduce

Made a migration from Appboy ObjC SDK to Braze Swift SDK and started doing some testings. Found this one when sending an In-App Message test from the admin panel. The app sets a custom BrazeInAppMessageUIDelegate but only to be able to listen to events not to customize the UI.

Screenshot 2024-02-22 at 15 52 50

The custom delegate is set on AppDelegate as the documentation states:

Screenshot 2024-02-22 at 15 52 08

Screenshot 2024-02-22 at 15 47 18

Expected Behavior

In-App message to display normally.

Actual Incorrect Behavior

The app crashes.

Verbose Logs

#0  (null) in specialized MutableCollection._halfStablePartition(isSuffixElement:) ()
#1  0x0000000102dca290 in BrazeInAppMessageUI.prepareAndPresent(message:) at /Users/itsmejohndoe/Library/Developer/Xcode/DerivedData/Shopkick-adofaigyzwflmrcsnujvuddvxkpl/SourcePackages/checkouts/braze-swift-sdk/Sources/BrazeUI/InAppMessageUI/InAppMessageUI.swift:148
#2  0x0000000102dc9c64 in BrazeInAppMessageUI.present(message:) at /Users/itsmejohndoe/Library/Developer/Xcode/DerivedData/Shopkick-adofaigyzwflmrcsnujvuddvxkpl/SourcePackages/checkouts/braze-swift-sdk/Sources/BrazeUI/InAppMessageUI/InAppMessageUI.swift:107
#3  0x0000000102dc9f20 in BrazeInAppMessageUI.present(message:) at /Users/itsmejohndoe/Library/Developer/Xcode/DerivedData/Shopkick-adofaigyzwflmrcsnujvuddvxkpl/SourcePackages/checkouts/braze-swift-sdk/Sources/BrazeUI/InAppMessageUI/InAppMessageUI.swift:120
#4  (null) in @objc BrazeInAppMessageUI.present(message:) ()
#5  (null) in _OBJC_BrazeInAppMessagePresenterWrapper.present(message:) ()
#6  (null) in closure #1 in Publisher<>.presentNewMessages(using:) ()
#7  (null) in Subscriber.receive(_:) ()
#8  (null) in partial apply for closure #1 in Subject.send(_:) ()
#9  (null) in Sequence.forEach(_:) ()
#10 (null) in Subject.send(_:) ()
#11 (null) in partial apply for implicit closure #2 in implicit closure #1 in closure #2 in closure #1 in PublisherType.innerFlatMap<A, B>(maxPublishers:_:) ()
#12 (null) in Subscriber.receive(_:) ()
#13 (null) in partial apply for implicit closure #2 in implicit closure #1 in closure #1 in PublisherType<>.setFailureType<A>(to:) ()
#14 (null) in Subscriber.receive(_:) ()
#15 (null) in closure #1 in Just.init(_:) ()
#16 (null) in Publisher.subscribe(_:) ()
#17 (null) in protocol witness for PublisherType.subscribe(_:) in conformance Publisher<A, B> ()
#18 (null) in PublisherType.sink(name:receiveCompletion:receiveValue:) ()
#19 (null) in closure #1 in PublisherType<>.setFailureType<A>(to:) ()
#20 (null) in Publisher.subscribe(_:) ()
#21 (null) in protocol witness for PublisherType.subscribe(_:) in conformance Publisher<A, B> ()
#22 (null) in PublisherType.sink(name:receiveCompletion:receiveValue:) ()
#23 (null) in closure #2 in closure #1 in PublisherType.innerFlatMap<A, B>(maxPublishers:_:) ()
#24 (null) in partial apply for closure #2 in closure #1 in PublisherType.innerFlatMap<A, B>(maxPublishers:_:) ()
#25 (null) in Subscriber.receive(_:) ()
#26 (null) in partial apply for closure #1 in closure #2 in closure #1 in PublisherType.receive<A>(on:options:) ()
#27 (null) in thunk for @escaping @callee_guaranteed @Sendable () -> () ()
#28 (null) in _dispatch_call_block_and_release ()
#29 (null) in _dispatch_client_callout ()
#30 (null) in _dispatch_main_queue_drain ()
#31 (null) in _dispatch_main_queue_callback_4CF ()
#32 (null) in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#33 (null) in __CFRunLoopRun ()
#34 (null) in CFRunLoopRunSpecific ()
#35 (null) in GSEventRunModal ()
#36 (null) in -[UIApplication _run] ()
#37 (null) in UIApplicationMain ()
#38 0x000000010292fcf4 in main at /Users/itsmejohndoe/Development/TraxRetail/client_ios/Shopkick/main.m:12
#39 (null) in start ()

Additional Information

No response

lowip commented 9 months ago

Hi @joaosouza-traxretail,

Thank you for opening this issue, we're tracking it internally and will update here once we have a fix ready. Are you able to reproduce the crash consistently?

Best,

joaosouza-traxretail commented 8 months ago

HI @lowip

Thanks for answering! The crash happens 100% of times after receiving an In-App Message (the app crashes before showing it to the user).

Best,