AppsFlyerSDK / AppsFlyerFramework

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

BUG IN CLIENT OF LIBPLATFORM. thermalState #191

Closed akinoavx13 closed 2 years ago

akinoavx13 commented 2 years ago

Report

SDK Version

6.4.2

What did you do?

Creation of a new version of my application without modifications, except for updating AppsFlyer to the latest version (6.4.2).

What did you expect to happen?

No crash due to AppsFlyer framework.

What happened instead?

Crashes occurred due to AppsFlyer framework.

EXC_BREAKPOINT AFSystemInfo
BUG IN CLIENT OF LIBPLATFORM: Trying to recursively lock an os_unfair_lock

0  libsystem_platform.dylib __os_unfair_lock_recursive_abort
1  libsystem_platform.dylib __os_unfair_lock_lock_slow
2  Foundation               -[NSProcessInfo(NSProcessInfoHardwareState) thermalState]
3  Scanner                  -[BugsnagClient thermalStateDidChange:] (BugsnagClient.m:506:51)
4  CoreFoundation           ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
5  CoreFoundation           ____CFXRegistrationPost_block_invoke
6  CoreFoundation           __CFXRegistrationPost
7  CoreFoundation           __CFXNotificationPost
8  Foundation               -[NSNotificationCenter postNotificationName:object:userInfo:]
9  Foundation               _NSProcessInfoNotifyThermalState
10 Foundation               -[NSProcessInfo(NSProcessInfoHardwareState) thermalState]
11 Scanner                  +[AFSystemInfo getSystemInfo] (Scanner)
12 Scanner                  -[AppsFlyerLib getEventParameters:] (Scanner)
13 Scanner                  -[AppsFlyerLib callServerWithEventName:eventValues:options:completion:] (Scanner)
14 Scanner                  __45-[AppsFlyerLib __startWithCompletionHandler:]_block_invoke (Scanner)
15 libdispatch.dylib        __dispatch_call_block_and_release
16 libdispatch.dylib        __dispatch_client_callout
17 libdispatch.dylib        __dispatch_lane_serial_drain$VARIANT$mp
18 libdispatch.dylib        __dispatch_lane_invoke$VARIANT$mp
19 libdispatch.dylib        __dispatch_workloop_worker_thread
20 libsystem_pthread.dylib  __pthread_wqthread

Please provide any other relevant information.

We were on AppsFlyer 6.4.0, it worked fine. We have updated AppsFlyer to 6.4.2 and this crash has occurred. It only appears on iOS 15.X. Occurred for 381 users out of 68,411 (total) with 464 events. This appears to be a race condition with "thermalState". I could not reproduce the bug.

Bugsnag is not involved in this crash (even though it is in the stack trace) because we just updated AppsFlyer.

There is a similar issue with the Data dog SDK.

jbelkins commented 2 years ago

+1 on this. I use Bugsnag and in my latest release, this constitutes half of my production crashes.

Additionally, AppsFlyer needs to explain why they are accessing thermal state at all. How is this possibly relevant to ad attribution?

guysarfatty-af commented 2 years ago

Hi @mmaheo and @jbelkins,

Thanks for reaching out and reporting this issue.

We are looking into this and we will issue a fix soon. The usage of Thermal State is part of our effort to detect fraudulent activity through our SDK.

I will report here once we have released a version that mitigates the issue.

akinoavx13 commented 2 years ago

Hi @guysarfatty-af, I've noticed that a new version has been released 6.4.3. Do you know if this version fix the bug above ? Thanks, Maxime

guysarfatty-af commented 2 years ago

Hi @mmaheo , Unfortunately not. The issue has been detected after 6.4.3 had been released. We are on the final stages of releasing 6.4.4 that handles the issue, and it is scheduled to be released early next week.

Thanks for your patience.

guysarfatty-af commented 2 years ago

@mmaheo , SDK v6.4.4 has been released, with a fix to the issue reported here.

Thanks again for bringing this up

akinoavx13 commented 2 years ago

Thanks you so much ! I'm going to create a new release with this version and close the issues if it's solved.

akinoavx13 commented 2 years ago

Hi @guysarfatty-af, Unfortunately, we have updated to version 6.4.4 but the bug is still present ...

AngeloStavrow commented 2 years ago

Hi @guysarfatty-af, thanks for your efforts to fix this. We're seeing these crashes in a recent release using SDK v6.4.1, and have not yet tried a hotfix using v6.4.4; given @mmaheo's reports that it's still crashing, is rolling back to v6.4.0 a reasonable workaround?

Also, is there a radar/FB # I can duplicate?

akinoavx13 commented 2 years ago

@AngeloStavrow You can safely downgrade to 6.4.0, this version doesn't crash.

AngeloStavrow commented 2 years ago

Thanks @mmaheo!

jbelkins commented 2 years ago

I still see this crash too, although only one occurrence of it so far.

The stack trace is still a little different, but generally the same thing is happening... AF triggers a thermalStateDidChange notification by querying thermal state, Bugsnag receives the notification, and a queue gets locked up.

jbelkins commented 2 years ago

For reference, here is my stack trace:

Thread 0 - (TH_STATE_WAITING)
0  libsystem_platform.dylib __os_unfair_lock_recursive_abort
1  libsystem_platform.dylib __os_unfair_lock_lock_slow
2  Foundation               -[NSProcessInfo(NSProcessInfoHardwareState) thermalState]
3  Trala                    -[BugsnagClient thermalStateDidChange:] (BugsnagClient.m:507:51)
4  CoreFoundation           ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
5  CoreFoundation           ____CFXRegistrationPost_block_invoke
6  CoreFoundation           __CFXRegistrationPost
7  CoreFoundation           __CFXNotificationPost
8  Foundation               -[NSNotificationCenter postNotificationName:object:userInfo:]
9  Foundation               _NSProcessInfoNotifyThermalState
10 Foundation               -[NSProcessInfo(NSProcessInfoHardwareState) thermalState]
11 Trala                    +[AFSDKDevice thermalState] (Trala)
12 Trala                    __71-[AppsFlyerLib callServerWithEventName:eventValues:options:completion:]_block_invoke_2.1025 (Trala)
13 libdispatch.dylib        __dispatch_call_block_and_release
14 libdispatch.dylib        __dispatch_client_callout
15 libdispatch.dylib        __dispatch_main_queue_callback_4CF$VARIANT$mp
16 CoreFoundation           ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
17 CoreFoundation           ___CFRunLoopRun
18 CoreFoundation           _CFRunLoopRunSpecific
19 GraphicsServices         _GSEventRunModal
20 UIKitCore                -[UIApplication _run]
21 UIKitCore                _UIApplicationMain
22 Trala                    main (main.swift:29:1)
23 dyld                     start
akinoavx13 commented 2 years ago

@jbelkins , @AngeloStavrow have you tested with version 6.5.0? @guysarfatty-af Do you know if this should be fixed in this version ?

jbelkins commented 2 years ago

@mmaheo I'm still on 6.4.0, and I plan to stay here until AF says they've fixed the issue (again).

guysarfatty-af commented 2 years ago

Hi @mmaheo @jbelkins , We have just released version 6.5.1 that resolves the issue (this time it's final).

In version 6.4.4 we tried to mitigate the issue by applying a similar solution as provided in the the DataDog SDK example.

When you reported that the issue still persists, we have decided to remove the code completely from the SDK, and version 6.5.1 does not query the Thermal State any longer.

Thank you for your patience, and I hope you will find version 6.5.1 suitable for you.

akinoavx13 commented 2 years ago

Thanks you! I'm going to create a new release with this version and close the issues if it's solved.