AppsFlyerSDK / AppsFlyerFramework

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

Crash [__NSArrayM getObjects:range:]: range {0, 3} extends beyond bounds [0 .. 1] #59

Closed ghost closed 6 years ago

ghost commented 6 years ago

after installing AppsFlyerFramework we received Crash on our Fabrics.Crash details as follow.

0 CoreFoundation __exceptionPreprocess
1 libobjc.A.dylib objc_exception_throw
2 CoreFoundation _CFArgv
3 CoreFoundation -[__NSArrayM getObjects:range:]
4 CoreFoundation -[NSArray initWithArray:range:copyItems:]
5 UIKit +[_UICanvas canvases]
6 UIKit +[_UIApplicationCanvas canvases]
7 UIKit +[_UIApplicationCanvas mostActiveCanvas]
8 UIKit -[UIApplication isSuspendedEventsOnly]
9 UIKit UpdateSystemSoundActiveStatus
10 UIKit IsSystemSoundEnabled
11 UIKit UpdateSystemSoundActiveStatus
12 UIKit -[UIDevice _updateSystemSoundActiveStatus:]
13 CoreFoundation CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER
14 CoreFoundation _CFXRegistrationPost
15 CoreFoundation ___CFXNotificationPost_block_invoke
16 CoreFoundation -[_CFXNotificationRegistrar find:object:observer:enumerator:]
17 CoreFoundation _CFXNotificationPost
18 Foundation -[NSNotificationCenter postNotificationName:object:userInfo:]
19 iFax iOS -[AppsFlyerTracker getCounter:]
20 iFax iOS -[AppsFlyerTracker getEventParameters:]
21 iFax iOS -[AppsFlyerTracker callServerWithEventName:value:withDictionary:isEvent:isIAd:]
22 iFax iOS -[AppsFlyerTracker callServerWithEventName:value:isInAppEvent:isIAd:]
23 libdispatch.dylib _dispatch_client_callout
24 libdispatch.dylib _dispatch_continuation_pop$VARIANT$armv81
25 libdispatch.dylib _dispatch_source_invoke$VARIANT$armv81
26 libdispatch.dylib _dispatch_queue_serial_drain$VARIANT$armv81
27 libdispatch.dylib _dispatch_queue_invoke$VARIANT$armv81
28 libdispatch.dylib _dispatch_root_queue_drain_deferred_wlh$VARIANT$armv81
29 libdispatch.dylib _dispatch_workloop_worker_thread$VARIANT$armv81
30 libsystem_pthread.dylib _pthread_wqthread
31 libsystem_pthread.dylib start_wqthread
andr-ggn commented 6 years ago

Hello, @moontecholabs

ghost commented 6 years ago

@andr-ggn thanks For your help

  1. no we are not listening NSUserDefaults changes using NSNotificationCenter
  2. OK. we will contact if any new problem occur in future
ghost commented 6 years ago

@andr-ggn any update on above crash.

andr-ggn commented 6 years ago

Hello, @moontecholabs again!

We are checking the best way to fix it on SDK side but in the meanwhile, I prepared a small workaround for you.

Please, let us know if it works for you.

//
//  AppsFlyer+Workaround.m
//
//  Created by AndreyG-AF on 10/02/17.
//

#import <objc/runtime.h>
#import <Foundation/Foundation.h>

@implementation NSUserDefaults (AppsFlyer)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class class = [self class];

        method_exchangeImplementations(class_getInstanceMethod(class, @selector(setObject:forKey:)),
                                       class_getInstanceMethod(class, @selector(af_setObject:forKey:)));

        method_exchangeImplementations(class_getInstanceMethod(class, @selector(removeObject:)),
                                       class_getInstanceMethod(class, @selector(af_removeObject:)));
    });
}

- (void)af_setObject:(NSString *)string forKey:(NSString *)key {
    dispatch_async(dispatch_get_main_queue(), ^{
        [self af_setObject:string forKey:key];
    });
}

- (void)af_removeObject:(NSString *)key {
    dispatch_async(dispatch_get_main_queue(), ^{
        [self af_removeObject:key];
    });
}

@end
ghost commented 6 years ago

@andr-ggn thanks for your help.We will check and update if it working.

andr-ggn commented 6 years ago

@moontecholabs any updates?

ghost commented 6 years ago

We have updated latest pod version, so now not facing.