AppsFlyerSDK / AppsFlyerFramework

AppsFlyer Apple SDK
https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS
Other
163 stars 90 forks source link

TvOS versions below `16.1` crashes when using version `6.10.X` #234

Closed romainehinds17 closed 12 months ago

romainehinds17 commented 1 year ago

Report

We noticed this while rolling out an updated version of our app. After triaging we confirmed that any tvOS versions below 16.1 crashes on launch assuming AppDelegate is being used to initialize the framework.

SDK Version

6.10.X

What did you do?

Ran app with framework integrated on tvOS 16.0.

What did you expect to happen?

App to launch without issue.

What happened instead?

Crashed

Please provide any other relevant information.

I did investigate this further and notice the app crashes when trying to call SKAdNetwork.updatePostbackConversionValue(_:coarseValue:lockWindow:completionHandler:)

Thread 4 Crashed::  Dispatch queue: com.appsflyer.serial
0   libobjc.A.dylib                        0x1800535fc objc_opt_respondsToSelector + 20
1   Foundation                             0x1815f00b8 _NSDescriptionWithStringProxyFunc + 52
2   CoreFoundation                         0x18071f098 __CFStringAppendFormatCore + 8204
3   CoreFoundation                         0x180720fd4 _CFStringCreateWithFormatAndArgumentsReturningMetadata + 176
4   CoreFoundation                         0x180720f18 _CFStringCreateWithFormatAndArgumentsAux2 + 40
5   *-tvOS                             0x105100ba0 AFLogDebug + 80
6   *-tvOS                             0x1051003bc -[AFSDKSKAdNetworkV4Impl __updatePostbackConversionValueWith:coarseValue:lockWindow:postbackSequenceIndex:nextWindowTime:requestTimestamp:requestUUID:] + 324
7   *-tvOS                             0x105100088 -[AFSDKSKAdNetworkV4Impl registerSKAdWithConversionValue:] + 128
8   *-tvOS                             0x105113784 __45-[AppsFlyerLib __startWithCompletionHandler:]_block_invoke + 196
9   libdispatch.dylib                      0x180187794 _dispatch_call_block_and_release + 24
10  libdispatch.dylib                      0x180188f54 _dispatch_client_callout + 16
11  libdispatch.dylib                      0x180190e6c _dispatch_lane_serial_drain + 756
12  libdispatch.dylib                      0x180191aa8 _dispatch_lane_invoke + 392
13  libdispatch.dylib                      0x18019d970 _dispatch_workloop_worker_thread + 764
14  libsystem_pthread.dylib                0x107f27878 _pthread_wqthread + 284
15  libsystem_pthread.dylib                0x107f2663c start_wqthread + 8

This caused the OS to crash when invoking objc_opt_respondsToSelector internally. It seems this SKAdNetwork function was added in iOS 16.1. The thing to note here is even though that function can't be invoked on tvOS the framework and symbols exists within tvOS 16.1+. This explains why we don't see a crash happening on 16.1+ because the OS would be able to resolve the symbols when invoking objc_opt_respondsToSelector and "drop the call" on tvOS.

I see that in 6.10.0: SKAdNetwork 4.0 support was added.

I recommend maybe wrapping the invocation of AFSDKSKAdNetworkV4Impl __updatePostbackConversionValueWith with

#if os(iOS)
#endif
amit-kremer93 commented 1 year ago

Thank you for that. We will check it and will reach out to you soon

abdul-rehman commented 12 months ago

@amit-kremer93 Any update on resolution of this issue ?

abdul-rehman commented 12 months ago

We are facing this issue on 6.11.x and 6.12 as well

andr-ggn commented 12 months ago

The fix will be released as part of 6.12.1 We have invocation check if (@available(iOS 16.1.1, macCatalyst 16.1.1, *)) and this check passes tvOS..