Closed pmanuelli closed 3 years ago
Hello,
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"{SOME_KEY}" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
in your code?Firebase/Performance
in your project? And if yes - which versionThank you for your answer.
Yes, I'm sure. This is the content of our Podfile.lock:
- AppsFlyerFramework (6.1.2):
- AppsFlyerFramework/Main (= 6.1.2)
- AppsFlyerFramework/Main (6.1.2)
Yes, we have observations like that.
I'm using Firebase to track the crashes. It does not happen so often. To the users experiencing the crash, seems to happen only once. I can't reproduce the issue locally and can't understand under which circumstances does it happen.
We were testing some changes related to the iOS14 IDFA restriction. We enabled SDAdNetwork measurements. Now we turned it off to see if the crash stops.
Yes, we are on 6.34.0
.
we have the same crash, could you help to solve this?
We are also seeing a similar crash since update to AppsFlyer sdk v6.1.2. This is now by far our most significant crash in our app and I would like to resolve it asap. The stack trace is not quite the same but I think it could be related:
Crashed: com.appsflyer.serial
0 libsystem_kernel.dylib 0x1b2c4184c __pthread_kill + 8
1 libsystem_pthread.dylib 0x1ce19d9e8 pthread_kill + 212
2 libsystem_c.dylib 0x1907ad8f4 abort + 100
3 libsystem_malloc.dylib 0x19652d030 _malloc_put + 554
4 libsystem_malloc.dylib 0x19652d2a4 malloc_zone_error + 100
5 libsystem_malloc.dylib 0x196516a60 szone_free + 460
6 libswiftCore.dylib 0x18b7e0104 _swift_release_dealloc + 28
7 XXXXXXXXXXXXXXXXXXXXX 0x104a2a4a8 specialized AppController.updateAppsFlyerUserCustomerId(userDefaults:) + 4346078376 (<compiler-generated>:4346078376)
8 XXXXXXXXXXXXXXXXXXXXX 0x104a234d4 @objc AppController.defaultsChanged(notification:) + 4346049748 (<compiler-generated>:4346049748)
9 CoreFoundation 0x187a64360 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
10 CoreFoundation 0x187a64320 ___CFXRegistrationPost_block_invoke + 48
11 CoreFoundation 0x187a63918 _CFXRegistrationPost + 400
12 CoreFoundation 0x187a63310 _CFXNotificationPost + 696
13 Foundation 0x188c970a0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
14 XXXXXXXXXXXXXXXXXXXXX 0x104f05770 -[AFSDKUserDefaultsStorage setInteger:forKey:] + 4351170416
15 XXXXXXXXXXXXXXXXXXXXX 0x104f069ac -[AFSDKSKAdNetwork didReceiveConfiguration:] + 4351175084
16 XXXXXXXXXXXXXXXXXXXXX 0x104f14f20 __38-[AppsFlyerLib handleOneLinkResponse:]_block_invoke + 4351233824
17 libdispatch.dylib 0x187739298 _dispatch_call_block_and_release + 24
18 libdispatch.dylib 0x18773a280 _dispatch_client_callout + 16
19 libdispatch.dylib 0x1876e2dcc _dispatch_lane_serial_drain$VARIANT$mp + 612
20 libdispatch.dylib 0x1876e38a8 _dispatch_lane_invoke$VARIANT$mp + 424
21 libdispatch.dylib 0x1876ed338 _dispatch_workloop_worker_thread + 712
22 libsystem_pthread.dylib 0x1ce19e5a4 _pthread_wqthread + 272
23 libsystem_pthread.dylib 0x1ce1a1874 start_wqthread + 8
This is a known issue.
Why? It happens because of the internal Apple bug in KVO.
When?
The following code can be a cause (used by clients):
[[NSUserDefaults standardUserDefaults] addObserver:
self forKeyPath: @"{SOME_KEY}"
options: NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context: NULL];
Details:
The system starts to monitor NSUserDefaults changes and crashes in very rare cases. Before version 6.1.2, KVO was implemented inside the SDK, but due to the Apple bug, we decided to remove it. We use NSUserDefaults as storage for some values. And we try to write them down as early as possible.
The Possible Solution:
We can migrate from NSUserDefaults, which is a very laborious process. As a workaround, we strongly recommend excluding KVO for NSUserDefaults.
Similar problems occur with other SDKs like Firebase
@andr-ggn @af-fess Hi. We are still facing the same problem. Could you recommend us how to fix it? Will you fix this bug in future releases?
We don't use [[NSUserDefaults standardUserDefaults] addObserver:...
in our code.
@drumih Please, add symbolic breakpoint and check which framework adds this observer. Also which version of SDK do you use?
@andr-ggn we use 6.1.4. We'll check observers, thanks
We're seeing the same crash in Firebase Crashlytics. It doesn't appear to be catastrophic at the moment, but it is our highest-rated crash.
AppsFlyer SDK: 6.1.3 Firebase Performance: 6.33.0
As far as KVO observers are concerned, we are not explicitly using KVO but through symbolic breakpoints, we can see that upon app launch the Firebase SDK is definitely adding KVO observers for NSUserDefaults via GTMLogger (see attached screenshots). UIKit and WebKit are also registering observers as well.
Knowing that this issue spans across the latest versions (6.1.2 - 6.1.4) and we don't have access to make changes to 3rd party SDKs, do you plan to address this issue at all?
We're happy to work with you and provide any other additional information you might need.
Crashed: com.appsflyer.serial
0 libobjc.A.dylib 0x1baef4de0 objc_release + 16
1 Foundation 0x1a7dfe598 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 644
2 Foundation 0x1a7d43c64 -[NSObject(NSKeyValueObservingPrivate) _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 808
3 CoreFoundation 0x1a6a64df0 -[CFPrefsSource forEachObserver:] + 312
4 CoreFoundation 0x1a6a664f0 -[CFPrefsSource _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 84
5 CoreFoundation 0x1a6bca6bc ___CFPrefsDeliverPendingKVONotificationsGuts_block_invoke + 360
6 CoreFoundation 0x1a6ab9ec4 __CFDictionaryApplyFunction_block_invoke + 24
7 CoreFoundation 0x1a6b976f0 CFBasicHashApply + 136
8 CoreFoundation 0x1a6ab9e84 CFDictionaryApplyFunction + 192
9 CoreFoundation 0x1a6bc6754 _CFPrefsDeliverPendingKVONotificationsGuts + 288
10 CoreFoundation 0x1a6bc515c -[_CFXPreferences _deliverPendingKVONotifications] + 92
11 CoreFoundation 0x1a6b8b390 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 384
12 CoreFoundation 0x1a6b8aa60 normalizeQuintuplet + 348
13 CoreFoundation 0x1a6b8b1e8 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 124
14 CoreFoundation 0x1a6a5a5e8 -[_CFXPreferences setValue:forKey:appIdentifier:container:configurationURL:] + 100
15 CoreFoundation 0x1a6bc8ae4 _CFPreferencesSetAppValueWithContainerAndConfiguration + 132
16 Foundation 0x1a7d3ecc4 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 64
17 SwipeKit 0x1056ef5cc -[AFSDKUserDefaultsStorage setDouble:forKey:] + 96
18 SwipeKit 0x1057081c0 -[AppsFlyerLib getTimePassedSinceLastLaunch] + 212
19 SwipeKit 0x105704ee4 -[AppsFlyerLib getEventParameters:] + 2164
20 SwipeKit 0x105708804 -[AppsFlyerLib callServerWithEventName:eventValues:options:completion:] + 1556
21 SwipeKit 0x105702cf4 __45-[AppsFlyerLib __startWithCompletionHandler:]_block_invoke + 900
22 libdispatch.dylib 0x1a67a6298 _dispatch_call_block_and_release + 24
23 libdispatch.dylib 0x1a67a7280 _dispatch_client_callout + 16
24 libdispatch.dylib 0x1a67834f0 _dispatch_lane_serial_drain$VARIANT$armv81 + 568
25 libdispatch.dylib 0x1a6783fdc _dispatch_lane_invoke$VARIANT$armv81 + 404
26 libdispatch.dylib 0x1a678d800 _dispatch_workloop_worker_thread + 692
27 libsystem_pthread.dylib 0x1ef2a35a4 _pthread_wqthread + 272
28 libsystem_pthread.dylib 0x1ef2a6874 start_wqthread + 8
Hello! We updated our Firebase/Performance version to 7.4.0
and, along with AppsFlyer 6.1.4
, the crash seems to stop.
We'll definitely try this, @pmanuelli! Thanks for the update.
I believe this was caused by a bug in google-toolbox-for-mac
. The bug has now been fixed.
We will reopen the ticket, if the problem comes back
Report
SDK Version
6.1.2
What did you do?
Integrated latest SDK version (6.1.2) and run app in the production environment.
What did you expect to happen?
The app does not crash.
What happened instead?
The app crashes on [AFSDKUserDefaultsStorage setDouble:forKey:]
Stack trace:
Please provide any other relevant information.
The issue started on version 6.1.2. All occurrences happen in iOS14.