PFAddUniqueOperation - 部分用户的系统性崩溃
PFAddUniqueOperation - Systematic crash for a subset of users
我发布了我的 iOS 应用程序的更新,据我所知,它不会改变我们处理推送通知的方式。
但是,我们的一部分用户报告在启动时系统崩溃。
Fabric 告诉我应用程序崩溃是由于:
Fatal Exception: NSInternalInconsistencyException
Operation is invalid after previous operation.
并显示当我在方法 updateAgenciesChannels 中将用户订阅到默认推送频道时会发生这种情况:
NSArray *agencies = [NSArray arrayWithObjects:@"channelA",@"channelB", nil];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
for(NSString *agency in agencies)
{
NSString *agencyString = [@"a-" stringByAppendingString:agency];
BOOL agencyState = [defaults boolForKey:agencyString];
if(agencyState)
[currentInstallation addUniqueObject:agencyString
forKey:@"channels"];
else
[currentInstallation removeObject:agencyString
forKey:@"channels"];
[currentInstallation saveInBackground];
}
好像和iOS版本没有关系(都是9.1.3崩溃的,但是很多9.1.3的用户完全没问题),也不是好像跟设备类型有关
对于这部分用户,崩溃是系统性的,在所有启动时,甚至在 deleting/installing 再次应用程序之后也是如此
这是完整的崩溃日志之一:
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x180ffee38 __exceptionPreprocess
1 libobjc.A.dylib 0x180663f80 objc_exception_throw
2 CoreFoundation 0x180ffed80 -[NSException initWithCoder:]
3 NextRide 0x1001c012c -[PFAddUniqueOperation mergeWithPrevious:] (PFFieldOperation.m:277)
4 NextRide 0x1001e1240 -[PFObject(Private) performOperation:forKey:] (PFObject.m:1172)
5 NextRide 0x1001e83dc -[PFObject addUniqueObjectsFromArray:forKey:] (PFObject.m:2170)
6 NextRide 0x1001e8318 -[PFObject addUniqueObject:forKey:] (PFObject.m:2166)
7 NextRide 0x1000ac4c8 +[NRNPush updateAgenciesChannels] (NRNPush.m:54)
8 NextRide 0x1000ac2dc +[NRNPush updateDefaultChannels] (NRNPush.m:35)
9 NextRide 0x100083b10 -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:86)
10 UIKit 0x1861be8a8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
11 UIKit 0x1863ee094 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:]
12 UIKit 0x1863f2500 -[UIApplication _runWithMainScene:transitionContext:completion:]
13 UIKit 0x1863ef674 -[UIApplication workspaceDidEndTransaction:]
14 FrontBoardServices 0x18299f7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
15 FrontBoardServices 0x18299f618 -[FBSSerialQueue _performNext]
16 FrontBoardServices 0x18299f9c8 -[FBSSerialQueue _performNextFromRunLoopSource]
17 CoreFoundation 0x180fb5124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
18 CoreFoundation 0x180fb4bb8 __CFRunLoopDoSources0
19 CoreFoundation 0x180fb28b8 __CFRunLoopRun
20 CoreFoundation 0x180edcd10 CFRunLoopRunSpecific
21 UIKit 0x1861b7834 -[UIApplication _run]
22 UIKit 0x1861b1f70 UIApplicationMain
23 NextRide 0x1000d054c main (main.m:28)
24 libdispatch.dylib 0x180a7a8b8 (Missing)
事实证明,当多次调用此方法时,如果用户已经订阅("unique object" 已经在数组中),我可能会尝试将用户订阅到频道,并尝试取消订阅用户如果他还没有被订阅到一个频道(删除不在数组中的对象)
我发布了我的 iOS 应用程序的更新,据我所知,它不会改变我们处理推送通知的方式。
但是,我们的一部分用户报告在启动时系统崩溃。 Fabric 告诉我应用程序崩溃是由于:
Fatal Exception: NSInternalInconsistencyException
Operation is invalid after previous operation.
并显示当我在方法 updateAgenciesChannels 中将用户订阅到默认推送频道时会发生这种情况:
NSArray *agencies = [NSArray arrayWithObjects:@"channelA",@"channelB", nil];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
for(NSString *agency in agencies)
{
NSString *agencyString = [@"a-" stringByAppendingString:agency];
BOOL agencyState = [defaults boolForKey:agencyString];
if(agencyState)
[currentInstallation addUniqueObject:agencyString
forKey:@"channels"];
else
[currentInstallation removeObject:agencyString
forKey:@"channels"];
[currentInstallation saveInBackground];
}
好像和iOS版本没有关系(都是9.1.3崩溃的,但是很多9.1.3的用户完全没问题),也不是好像跟设备类型有关
对于这部分用户,崩溃是系统性的,在所有启动时,甚至在 deleting/installing 再次应用程序之后也是如此
这是完整的崩溃日志之一:
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x180ffee38 __exceptionPreprocess
1 libobjc.A.dylib 0x180663f80 objc_exception_throw
2 CoreFoundation 0x180ffed80 -[NSException initWithCoder:]
3 NextRide 0x1001c012c -[PFAddUniqueOperation mergeWithPrevious:] (PFFieldOperation.m:277)
4 NextRide 0x1001e1240 -[PFObject(Private) performOperation:forKey:] (PFObject.m:1172)
5 NextRide 0x1001e83dc -[PFObject addUniqueObjectsFromArray:forKey:] (PFObject.m:2170)
6 NextRide 0x1001e8318 -[PFObject addUniqueObject:forKey:] (PFObject.m:2166)
7 NextRide 0x1000ac4c8 +[NRNPush updateAgenciesChannels] (NRNPush.m:54)
8 NextRide 0x1000ac2dc +[NRNPush updateDefaultChannels] (NRNPush.m:35)
9 NextRide 0x100083b10 -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:86)
10 UIKit 0x1861be8a8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
11 UIKit 0x1863ee094 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:]
12 UIKit 0x1863f2500 -[UIApplication _runWithMainScene:transitionContext:completion:]
13 UIKit 0x1863ef674 -[UIApplication workspaceDidEndTransaction:]
14 FrontBoardServices 0x18299f7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
15 FrontBoardServices 0x18299f618 -[FBSSerialQueue _performNext]
16 FrontBoardServices 0x18299f9c8 -[FBSSerialQueue _performNextFromRunLoopSource]
17 CoreFoundation 0x180fb5124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
18 CoreFoundation 0x180fb4bb8 __CFRunLoopDoSources0
19 CoreFoundation 0x180fb28b8 __CFRunLoopRun
20 CoreFoundation 0x180edcd10 CFRunLoopRunSpecific
21 UIKit 0x1861b7834 -[UIApplication _run]
22 UIKit 0x1861b1f70 UIApplicationMain
23 NextRide 0x1000d054c main (main.m:28)
24 libdispatch.dylib 0x180a7a8b8 (Missing)
事实证明,当多次调用此方法时,如果用户已经订阅("unique object" 已经在数组中),我可能会尝试将用户订阅到频道,并尝试取消订阅用户如果他还没有被订阅到一个频道(删除不在数组中的对象)