When creating a new PFObject and using saveInBackgroundWithBlock(), the app crashes (only on device, not while attached to debugger).
Help is greatly appreciated.
Parse Version: 1.8.5 & 1.9.0
Here is the exception in the log:
[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]
Here is the stack trace for the crashing thread:
Hardware Model: iPhone7,2
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
OS Version: iOS 9.0.2 (13A452)
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Filtered syslog:
None found
Last Exception Backtrace:
0 CoreFoundation 0x184434f5c __exceptionPreprocess + 124
1 libobjc.A.dylib 0x19902bf80 objc_exception_throw + 56
2 CoreFoundation 0x18431e30c -[__NSPlaceholderArray initWithObjects:count:] + 300
3 CoreFoundation 0x184329db4 +[NSArray arrayWithObjects:count:] + 52
4 Parse 0x100548220 -[PFTaskQueue enqueue:] (PFTaskQueue.m:44)
5 Parse 0x1004d4fe8 -[PFObject saveInBackground] (PFObject.m:1989)
6 Parse 0x1004d53b4 -[PFObject saveInBackgroundWithBlock:] (PFObject.m:2001)
7 Dojo 0x100057110 0x100030000 + 160016
8 Dojo 0x100043344 0x100030000 + 78660
9 Dojo 0x100038744 0x100030000 + 34628
10 Dojo 0x1000556ec 0x100030000 + 153324
11 Dojo 0x1000557b0 0x100030000 + 153520
12 Dojo 0x10005551c 0x100030000 + 152860
13 Dojo 0x100055564 0x100030000 + 152932
14 Dojo 0x10009da60 0x100030000 + 449120
15 libdispatch.dylib 0x1998257b0 _dispatch_call_block_and_release + 24
16 libdispatch.dylib 0x199825770 _dispatch_client_callout + 16
17 libdispatch.dylib 0x19982ae20 _dispatch_main_queue_callback_4CF + 1844
18 CoreFoundation 0x1843ec258 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
19 CoreFoundation 0x1843ea0c0 __CFRunLoopRun + 1628
20 CoreFoundation 0x184318dc0 CFRunLoopRunSpecific + 384
21 GraphicsServices 0x18f46c088 GSEventRunModal + 180
22 UIKit 0x1899f2f44 UIApplicationMain + 204
23 Dojo 0x100042030 0x100030000 + 73776
24 libdyld.dylib 0x1998568b8 start + 4
Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.
Please try the latest SDK. Our release notes have details about what issues were fixed in each release.
In addition, you might find the following resources helpful:
It would appear from your stack trace that one of our internal tasks is nil, and from what I can tell, it seems loosely related to our PFCurrentUserController being nil.
If this crash is consistent, would you mind supplying us with some example code that reproduces the issue?
I believe that the code isn't very helpful, since it's just instantiating a PFObject via subclass, then calling saveInBackgroundWithBlock() on it.
Implementation:
let newMyObj= MyObj()
newMyObj.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
if let error = error {
log.error(error.localizedDescription)
}
if success {
log.debug("MyObj created")
}
}
MyObj.swift
import Parse
class MyObj : PFObject, PFSubclassing {
@NSManaged var key: UInt
override class func initialize() {
struct Static {
static var onceToken : dispatch_once_t = 0;
}
dispatch_once(&Static.onceToken) {
self.registerSubclass()
}
}
static func parseClassName() -> String {
return "MyObj"
}
}
@dtrenz Any chance this is happening before you initialized Parse?
Before you call into saving - could you print to console your app id and/or client key from Parse.getApplicationId(). Just trying to make sure that it's initialized.
Ah ha! Thanks for pointing me in the right direction, @nlutsenko!
It appears that if I;
application:didFinishLaunchingWithOptions,...the initialized Parse SDK is no longer initialized.
Is this a bug, or should I move the Parse initialization to something like application:didBecomeActive in this scenario?
Super strange. It should definitely be in application:didFinishLaunchingWithOptions:.
The only suggestions:
application:didFinishLaunchingWithOptions:init() of your AppDelegateInitializing the SDK multiple times is undefined. :grin:
OK, that was a red herring.
I was using scheme env vars (NSProcessInfo.processInfo().environment) to set/read the Parse ID & key. But I didn't realize that they are only available when running the app attached to the debugger.
This was a painful lesson.
Thanks for helping to point me in the right direction.
Glad you got it solved!
Me, too.
If there is a take-away for the Parse SDK, maybe there should be an error when a PFObject is saved before the Parse SDK has been initialized?
I'm having a similar issue @dtrenz. I'm not quite sure how you solved it?
I initialize Parse in application:didFinishLaunchingWithOptions with this:
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {}];
My app pops into another app, and when it returns to my app, it crashes on the splash screen with the following error logs. Have any recommendations?
0 CoreFoundation 0x187a821c0 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x1864bc55c objc_exception_throw + 55
2 CoreFoundation 0x187961600 -[__NSPlaceholderArray initWithObjects:count:] + 311
3 CoreFoundation 0x18796d38c +[NSArray arrayWithObjects:count:] + 51
4 Parse 0x10071823c 0x100690000 + 557628
5 AppName 0x100149ae4 0x1000d4000 + 482020
6 AppName 0x100148e64 0x1000d4000 + 478820
7 AppName 0x10014827c 0x1000d4000 + 475772
8 AppName 0x1001ab4fc 0x1000d4000 + 881916
9 UIKit 0x18db663a4 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 751
10 UIKit 0x18db65e30 -[UIApplication _applicationOpenURL:payload:] + 655
Most helpful comment
Super strange. It should definitely be in
application:didFinishLaunchingWithOptions:.The only suggestions:
application:didFinishLaunchingWithOptions:init()of your AppDelegateInitializing the SDK multiple times is
undefined. :grin: