Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling clear() make the application crash on ios #59

Open
ydeshayes opened this issue Jan 10, 2017 · 9 comments
Open

Calling clear() make the application crash on ios #59

ydeshayes opened this issue Jan 10, 2017 · 9 comments

Comments

@ydeshayes
Copy link
Contributor

ydeshayes commented Jan 10, 2017

Hello,

My app crash when I call clear().

Iphone SE simulator, ios 10.2, cordova 6.4.0

My JS code:

export function clear(callback = () => {}) {
  return new Promise(
    (resolve, reject) =>
      NativeStorage.clear(() => {
        resolve();
        callback();
      }, (err) => {
        reject(err);
        callback(err);
      })
  );
}

The stack:

Jan 10 09:21:55 MBP-de-Yann Stryng[5966]: [User Defaults] Attempt to set a non-property-list object <null> as an NSUserDefaults/CFPreferences value for key token
Jan 10 09:21:55 MBP-de-Yann Stryng[5966]: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object null for key token'
	*** First throw call stack:
	(
		0   CoreFoundation                      0x0000000100e7fd4b __exceptionPreprocess + 171
		1   libobjc.A.dylib                     0x00000001008b821e objc_exception_throw + 48
		2   CoreFoundation                      0x0000000100ee92b5 +[NSException raise:format:] + 197
		3   CoreFoundation                      0x0000000100dcff3b _CFPrefsValidateValueForKey + 267
		4   CoreFoundation                      0x0000000100eea843 -[CFPrefsPlistSource alreadylocked_setValues:forKeys:count:] + 259
		5   CoreFoundation                      0x0000000100ea7648 -[CFPrefsSource setValues:forKeys:count:removeValuesForKeys:count:] + 264
		6   CoreFoundation                      0x0000000100dcfe20 -[CFPrefsSource setValues:forKeys:count:] + 32
		7   CoreFoundation                      0x0000000100ee17c9 -[CFPrefsSearchListSource alreadylocked_setValues:forKeys:count:] + 473
		8   CoreFoundation                      0x0000000100ea7648 -[CFPrefsSource setValues:forKeys:count:removeValuesForKeys:count:] + 264
		9   CoreFoundation                      0x0000000100dcfe20 -[CFPrefsSource setValues:forKeys:count:] + 32
		10  CoreFoundation                      0x0000000100e1499a -[CFPrefsSource setValue:forKey:] + 58
		11  CoreFoundation                      0x0000000100ee3702 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 322
		12  CoreFoundation                      0x0000000100ee2f09 normalizeQuintuplet + 329
		13  CoreFoundation                      0x0000000100ee35b8 -[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 104
		14  CoreFoundation                      0x0000000100ecdc95 -[_CFXPreferences setValue:forKey:appIdentifier:container:configurationURL:] + 261
		15  CoreFoundation                      0x0000000100e148e4 _CFPreferencesSetAppValueWithContainer + 68
		16  Foundation                          0x00000001003afc96 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 55
		17  Stryng                              0x00000001002b3122 __25-[NativeStorage setItem:]_block_invoke + 290
		18  libdispatch.dylib                   0x0000000104411808 _dispatch_call_block_and_release + 12
		19  libdispatch.dylib                   0x000000010443312e _dispatch_client_callout + 8
		20  libdispatch.dylib                   0x00000001044191f8 _dispatch_queue_override_invoke + 809
		21  libdispatch.dylib                   0x000000010441a9dc _dispatch_root_queue_drain + 506
		22  libdispatch.dylib                   0x000000010441a782 _dispatch_worker_thread3 + 113
		23  libsystem_pthread.dylib             0x00000001047d8746 _pthread_wqthread + 1299
		24  libsystem_pthread.dylib             0x00000001047d8221 start_wqthread + 13
	)
Jan 10 09:21:55 MBP-de-Yann SpringBoard[88084]: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focus
Jan 10 09:21:55 MBP-de-Yann com.apple.CoreSimulator.SimDevice.6477C956-D87C-41C9-9FD0-1FB502D13465.launchd_sim[88068] (UIKitApplication:com.app.stryng[0x4978][5966]): Service exited due to Abort trap: 6
Jan 10 09:21:55 MBP-de-Yann backboardd[88086]: [Common] Unable to get short BSD proc info for 5966: No such process
Jan 10 09:21:55 MBP-de-Yann backboardd[88086]: [Common] Unable to get proc info for 5966: No such process
Jan 10 09:21:56 MBP-de-Yann assertiond[88089]: notify_suspend_pid() failed with error 7
Jan 10 09:21:56 MBP-de-Yann watchlistd[88161]: Now playing app did change to '(null)' (playing: 0) from '(null)'
Jan 10 09:21:56 MBP-de-Yann watchlistd[88161]: WLKPlaybackSummary - Parameter failed validation bundleID. It is nil

Thanks for your help

@GillesC
Copy link
Collaborator

GillesC commented Jan 17, 2017

  • Are your sure the error is related to the clear method?
  • And maybe test your application on a real device?

@doxavore
Copy link

doxavore commented Jan 17, 2017

I'm not getting a crash, but I'm catching this JS error when I call NativeStorage.clear() with [email protected], [email protected], and [email protected] and 2.1.0. Reproduces for me on the device and simulator at iOS 10.2.

Error: The old format of this exec call has been removed (deprecated since 2.1). Change to: cordova.exec(null, null, 'Service', 'action', [ arg1, arg2 ]);
iOSExec@file:///var/containers/Bundle/Application/MYAPP/www/cordova.js:928:24
execProxy@file:///var/containers/Bundle/Application/MYAPP/www/cordova.js:1072:24
clear@file:///var/containers/Bundle/Application/MYAPP/www/plugins/cordova-plugin-nativestorage/www/mainHandle.js:122:32

It's not clear to me how what this plugin is doing today doesn't match the format it's suggesting, though.

Edit: apologies if these are unrelated, I can open a separate ticket as well, but I only see this error message when calling clear().

@GillesC
Copy link
Collaborator

GillesC commented Feb 2, 2017

Thank you for the log information, I will take a look at it.

@GillesC
Copy link
Collaborator

GillesC commented Feb 2, 2017

@doxavore can you post a snipset of your code where the error is thrown?
Please be certain to use function in a correct manner:

NativeStorage.clear(function(result) {
    console.log(result);
   },
  function(e) {
    fail("Error when clearing native storage");
});

@alokrajiv
Copy link
Collaborator

@doxavore Can you please post the exact usage of .clear() function from your codebase.
The Error: The old format of this exec call message is dumped to log usually when we call the exec function with wrong parameter depth.

@ghost
Copy link

ghost commented Apr 26, 2017

I am also getting __25-[NativeStorage+setItem:]_block_invoke in my iOS crashes and it definitely is not from clear method.
I guess this happens when you try to use setItem method when DeviceReady has not fired yet.
This is only happening on iOS and not android.

@alokrajiv
Copy link
Collaborator

@Maziar-Fotouhi I am assuming your comment is related to Issue #88.

@GillesC we might need to see how to trace this bug : 🤔

@ghost
Copy link

ghost commented Oct 11, 2017

@alokrajiv Yes. I created that issue.
I have also confirmed that the crashes are not due to anything that I have guessed so far. So, I'm completely out of ideas now!

@MoemenMostafa
Copy link

MoemenMostafa commented Oct 17, 2017

Also I have same crash reports:

Last Exception Backtrace:
0   CoreFoundation                	0x1847bbd38 __exceptionPreprocess + 124 (NSException.m:166)
1   libobjc.A.dylib               	0x183cd0528 objc_exception_throw + 56 (objc-exception.mm:521)
2   CoreFoundation                	0x1847bbc80 +[NSException raise:format:] + 116 (NSException.m:141)
3   CoreFoundation                	0x1847f3d54 _CFPrefsValidateValueForKey + 252 (CFPrefsSource.m:646)
4   CoreFoundation                	0x184726a88 -[CFPrefsPlistSource alreadylocked_setValues:forKeys:count:from:] + 1088 (CFPrefsPlistSource.m:298)
5   CoreFoundation                	0x1847f40e0 -[CFPrefsSource setValues:forKeys:count:removeValuesForKeys:count:from:] + 220 (CFPrefsSource.m:702)
6   CoreFoundation                	0x1847571c0 -[CFPrefsSearchListSource alreadylocked_setValues:forKeys:count:from:] + 584 (CFPrefsSearchListSource.m:657)
7   CoreFoundation                	0x1847f40e0 -[CFPrefsSource setValues:forKeys:count:removeValuesForKeys:count:from:] + 220 (CFPrefsSource.m:702)
8   CoreFoundation                	0x1847f44a0 -[CFPrefsSource setValue:forKey:from:] + 64 (CFPrefsSource.m:726)
9   CoreFoundation                	0x18475a014 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 260 (CFPrefsSearchListSource.m:1483)
10  CoreFoundation                	0x184759838 normalizeQuintuplet + 356 (CFPrefsSearchListSource.m:63)
11  CoreFoundation                	0x184759f04 -[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 108 (CFPrefsSearchListSource.m:1364)
12  CoreFoundation                	0x1847fe0b0 -[_CFXPreferences setValue:forKey:appIdentifier:container:configurationURL:] + 92 (CFXPreferences.m:706)
13  CoreFoundation                	0x184801730 _CFPreferencesSetAppValueWithContainer + 128 (CFXPreferences.m:1720)
14  Foundation                    	0x1850b8f80 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 68 (NSUserDefaults.m:228)
15  SmartPass                     	0x100e5b938 __25-[NativeStorage setItem:]_block_invoke + 208 (NativeStorage.m:217)
16  libdispatch.dylib             	0x184141088 _dispatch_call_block_and_release + 24 (init.c:994)
17  libdispatch.dylib             	0x184141048 _dispatch_client_callout + 16 (object.m:502)
18  libdispatch.dylib             	0x184148090 _dispatch_queue_override_invoke$VARIANT$mp + 716 (inline_internal.h:2500)
19  libdispatch.dylib             	0x18414e1c8 _dispatch_root_queue_drain + 596 (inline_internal.h:2539)
20  libdispatch.dylib             	0x18414df10 _dispatch_worker_thread3 + 120 (queue.c:6104)
21  libsystem_pthread.dylib       	0x1843e7130 _pthread_wqthread + 1268 (pthread.c:2286)
22  libsystem_pthread.dylib       	0x1843e6c30 start_wqthread + 4

Please note that I am using NativeStorage.setItem 3 times in parallel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants