Appboy / appboy-ios-sdk

Public repo for the Braze iOS SDK
https://www.braze.com
Other
164 stars 142 forks source link

[Bug]: ABKCustomPropertyUtils validateArray #361

Closed charlesgregorybu closed 5 months ago

charlesgregorybu commented 1 year ago

Platform

iOS

Platform Version

16.3.1

Braze SDK Version

4.5.2

Xcode Version

14.1

Integration Method

Cocoapods

Computer Processor

Intel

Repro Rate

10%

Steps To Reproduce

There appears to be an issue with tracking events and segment integration. This occurs when tracking an event: 0 libobjc.A.dylib objc_release_x0 + 8 1 libobjc.A.dylib objc_release + 8 2 libswiftCore.dylib swift_arrayDestroy + 124 3 libswiftCore.dylib SwiftDeferredNSArray.withUnsafeBufferOfObjects(_:) + 128 4 libswiftCore.dylib @objc SwiftNativeNSArrayWithContiguousStorage.countByEnumerating(with:objects:count:) + 184 5 Appboy_iOS_SDK +[ABKCustomPropertyUtils validateArray:] + 148 6 Appboy_iOS_SDK +[ABKCustomPropertyUtils validateValue:] + 1016 7 Appboy_iOS_SDK +[ABKCustomPropertyUtils validateDictionary:] + 552 8 Appboy_iOS_SDK +[ABKCustomPropertyUtils validateValue:] + 1116 9 Appboy_iOS_SDK -[NSDictionary(ABKEventCustomProperty) abk_validatedCustomProperties:] + 64 10 Appboy_iOS_SDK -[Appboy logCustomEvent:withProperties:] + 1224 11 Segment_Appboy -[SEGAppboyIntegration track:] + 1992 12 CoreFoundation invoking_ + 148 13 CoreFoundation -[NSInvocation invoke] + 428 14 CoreFoundation -[NSInvocation invokeWithTarget:] + 64 15 Segment -[SEGIntegrationsManager invokeIntegration:key:selector:arguments:options:] + 1008 16 CoreFoundation NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK + 24 17 CoreFoundation -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 212 18 Segment -[SEGIntegrationsManager forwardSelector:arguments:options:] + 168

Expected Behavior

Tracking an event should not result in a crash.

Actual Incorrect Behavior

An array or related object appears to be accessed after dealloced. The app is crashing for an increasing number of users.

Verbose Logs

0
libobjc.A.dylib
objc_release_x0 + 8
1
libobjc.A.dylib
objc_release + 8
2
libswiftCore.dylib
swift_arrayDestroy + 124
3
libswiftCore.dylib
__SwiftDeferredNSArray.withUnsafeBufferOfObjects<A>(_:) + 128
4
libswiftCore.dylib
@objc __SwiftNativeNSArrayWithContiguousStorage.countByEnumerating(with:objects:count:) + 184
5
Appboy_iOS_SDK
+[ABKCustomPropertyUtils validateArray:] + 148
6
Appboy_iOS_SDK
+[ABKCustomPropertyUtils validateValue:] + 1016
7
Appboy_iOS_SDK
+[ABKCustomPropertyUtils validateDictionary:] + 552
8
Appboy_iOS_SDK
+[ABKCustomPropertyUtils validateValue:] + 1116
9
Appboy_iOS_SDK
-[NSDictionary(ABKEventCustomProperty) abk_validatedCustomProperties:] + 64
10
Appboy_iOS_SDK
-[Appboy logCustomEvent:withProperties:] + 1224
11
Segment_Appboy
-[SEGAppboyIntegration track:] + 1992
12
CoreFoundation
__invoking___ + 148
13
CoreFoundation
-[NSInvocation invoke] + 428
14
CoreFoundation
-[NSInvocation invokeWithTarget:] + 64
15
Segment
-[SEGIntegrationsManager invokeIntegration:key:selector:arguments:options:] + 1008
16
CoreFoundation
__NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 24
17
CoreFoundation
-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 212
18
Segment
-[SEGIntegrationsManager forwardSelector:arguments:options:] + 168

Additional Information

Please reach out to charles.gregory@betterup.co with any questions or more details.

cbowns commented 1 year ago

Hi @charlesgregorybu, thanks for sending this over. This issue looks like it might be data-dependent inside the Obj-C layer, or an issue with the type markup as it bridges into the Swift runtime. Can you write in to support@braze.com and reference this issue so we can get some more information from you there?

(By the way, you noted the repro rate was 10%; was that a typo for 100%, or do you have some data on what does and doesn't cause this crash?)

cbowns commented 1 year ago

@charlesgregorybu Do you have any updates or additional information for us?

charlesgregorybu commented 1 year ago

Hey @cbowns, apologies for the radio silence; I've been OOO. We identified that the issue is the payload size of our event going through Appboy (we have a long array or possibly too much nested data) and we are mitigating the problem by sending to segment directly for now. I'll catch up with my colleagues and have them add their updates here. Thank you!

charlesgregorybu commented 1 year ago

We've mitigated the issue by limiting an array we send with each analytics event (it was up to 30-40 strings). The docs state that payloads should not exceed 50kb, but when checking the size of our payload it is not exceeding 50k. For now we are okay truncating our array, but it seems that there is some kind of issue with the SDK. Let me know if you would like more information.

cbowns commented 1 year ago

Gotcha, thanks for the info. If you have any example payloads that reliably reproduced it, we'd love to take a look. Can you contact support@braze.com, reference this Github thread, and send in some of that information?

hokstuff commented 5 months ago

I am closing out this public issue due to its possible staleness and encourage you to migrate to our Braze Swift SDK (see migration guide here). We are under a month away from the end-of-life of our legacy AppboyKit ObjC SDK and this issue is likely not present on that repo.

Thanks!