[AC-6501] App Crashes when requesting location
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Closed |
| Resolution | Invalid |
| Resolution Date | 2020-03-09T15:25:09.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Titanium SDK & CLI |
| Labels | n/a |
| Reporter | Peter Ladis |
| Assignee | Motiur Rahman |
| Created | 2020-03-06T19:10:23.000+0000 |
| Updated | 2020-03-09T15:25:09.000+0000 |
Description
Appcelerator Command-Line Interface, version 7.1.1
Operating System
Name = Mac OS X
Version = 10.14.6
Architecture = 64bit
# CPUs = 12
Memory = 17179869184
Node.js
Node.js Version = 10.15.3
npm Version = 6.4.1
Titanium CLI
CLI Version = 5.2.1
Titanium SDK
SDK Version = 8.3.1.GA
Repro Steps:
1. Open up the application
2. Make a call to location services, app will crash with this error
Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient) || _CFMZEnabled()
This crash will go away if I add location to the BackgroundMode...however apple fails my app from review with this setting on
Any ideas?
Here is what apple is saying ( if I remove the location setting in pList, appcelerator crashes when asking for current location) Your app declares support for location in the UIBackgroundModes key in your Info.plist file but still does not have any features that require persistent location. Apps that declare support for location in the UIBackgroundModes key in your Info.plist file must have features that require persistent location. Next Steps To resolve this issue, please revise your app to include features that require the persistent use of real-time location updates while the app is in the background. If your app does not require persistent real-time location updates, please remove the "location" setting from the UIBackgroundModes key. You may wish to use the significant-change location service or the region monitoring location service if persistent real-time location updates are not required for your app features. Resources For more information, please review the Starting the Significant-Change Location Service and Monitoring Geographical Regions.
[~peterladis], please provide some sample code (including necessary additions to tiapp) that reproduces this issue. We need this to make sure that we are reviewing the same code you are using.
Do you have the keys for location permission strings in your tiapp? If you don't provide those the app will crash as well when you request. These are
If you only request "when in use" you need to provide the first 2 strings in tiapp. If you request always you need to provide all 4 (especially for compatibilty to older iOS versions)@rene. Those are all set in my app Here is the error that pops
[INFO] *** Assertion failure in -[CLLocationManager setAllowsBackgroundLocationUpdates:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreLocationFramework_Sim/CoreLocation-2389.0.8/Framework/CoreLocation/CLLocationManager.m:748 [ERROR] Script Error { [ERROR] column = 46; [ERROR] line = 668; [ERROR] message = "Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient) || _CFMZEnabled()"; [ERROR] nativeStack = ( [ERROR] 0 CoreFoundation 0x00007fff23c7127e __exceptionPreprocess + 350 [ERROR] 1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48 [ERROR] 2 CoreFoundation 0x00007fff23c70ff8 +[NSException raise:format:arguments:] + 88 [ERROR] 3 Foundation 0x00007fff256e9b51 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191 [ERROR] 4 CoreLocation 0x00007fff248587de CLClientStopVehicleHeadingUpdates + 27163 [ERROR] 5 LilyPad 0x000000010f1f6447 -[GeolocationModule locationManager] + 1111 [ERROR] 6 LilyPad 0x000000010f1f68d8 -[GeolocationModule startStopLocationManagerIfNeeded] + 312 [ERROR] 7 LilyPad 0x000000010f1f76d2 -[GeolocationModule getCurrentPosition:] + 754 [ERROR] 8 CoreFoundation 0x00007fff23c7820c __invoking___ + 140 [ERROR] 9 CoreFoundation 0x00007fff23c753af -[NSInvocation invoke] + 319 [ERROR] 10 JavaScriptCore 0x00007fff26a73abb _ZN3JSC24ObjCCallbackFunctionImpl4callEP9JSContextP13OpaqueJSValuemPKPKS3_PS6_ + 411 [ERROR] 11 JavaScriptCore 0x00007fff26a73504 _ZN3JSCL34objCCallbackFunctionCallAsFunctionEPK15OpaqueJSContextP13OpaqueJSValueS4_mPKPKS3_PS6_ + 244 [ERROR] 12 JavaScriptCore 0x00007fff26a72e2f _ZN3JSC19APICallbackFunction4callINS_20ObjCCallbackFunctionEEExPNS_9ExecStateE + 511 [ERROR] 13 ??? 0x000036dd32e01027 0x0 + 60323669217319 [ERROR] 14 JavaScriptCore 0x00007fff26a490a3 llint_entry + 93226 [ERROR] 15 JavaScriptCore 0x00007fff26a322cf vmEntryToJavaScript + 200 [ERROR] 16 JavaScriptCore 0x00007fff26e49260 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 416 [ERROR] 17 JavaScriptCore 0x00007fff27096844 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 196 [ERROR] 18 JavaScriptCore 0x00007fff26a8f928 JSObjectCallAsFunction + 488 [ERROR] 19 TitaniumKit 0x000000010fa1dc2b TiBindingEventProcess + 667 [ERROR] 20 TitaniumKit 0x000000010fa3e47c -[KrollContext invoke:] + 109 [ERROR] 21 TitaniumKit 0x000000010fa3e4ef -[KrollContext enqueue:] + 93 [ERROR] 22 TitaniumKit 0x000000010fa45a8e TiBindingRunLoopEnqueue + 77 [ERROR] 23 TitaniumKit 0x000000010fa1dd02 TiBindingEventProcess + 882 [ERROR] 24 TitaniumKit 0x000000010fa3e47c -[KrollContext invoke:] + 109 [ERROR] 25 TitaniumKit 0x000000010fa3e4ef -[KrollContext enqueue:] + 93 [ERROR] 26 TitaniumKit 0x000000010fa45a8e TiBindingRunLoopEnqueue + 77 [ERROR] 27 TitaniumKit 0x000000010fa442e4 -[TiProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 164 [ERROR] 28 TitaniumKit 0x000000010fa25cec -[TiViewProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 224 [ERROR] 29 TitaniumKit 0x000000010fa440f1 -[TiProxy fireEvent:withObject:propagate:] + 76 [ERROR] 30 TitaniumKit 0x000000010fa16a2f -[TiUIView touchesEnded:withEvent:] + 110 [ERROR] 31 UIKitCore 0x00007fff480cebbf -[UIWindow _sendTouchesForEvent:] + 2604 [ERROR] 32 UIKitCore 0x00007fff480d04c6 -[UIWindow sendEvent:] + 4596 [ERROR] 33 UIKitCore 0x00007fff480ab53b -[UIApplication sendEvent:] + 356 [ERROR] 34 LilyPad 0x000000010f0afdac -[TiUIApplication sendEvent:] + 572 [ERROR] 35 UIKitCore 0x00007fff4812c71a __dispatchPreprocessedEventFromEventQueue + 6847 [ERROR] 36 UIKitCore 0x00007fff4812f1e0 __handleEventQueueInternal + 5980 [ERROR] 37 CoreFoundation 0x00007fff23bd4471 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 [ERROR] 38 CoreFoundation 0x00007fff23bd439c __CFRunLoopDoSource0 + 76 [ERROR] 39 CoreFoundation 0x00007fff23bd3b74 __CFRunLoopDoSources0 + 180 [ERROR] 40 CoreFoundation 0x00007fff23bce87f __CFRunLoopRun + 1263@Ewan...I am doing nothing special to make this happen....if I remove the LOCATION from the setting for background mode and make this SDK call
It crashes 100 percent of the time. If I put the background mode back in ( app rejects me )...but the app works as designed....Titanium.Geolocation.getCurrentPosition(function(loc){ });How are you requesting permission? And are you verifying location permission has been given?
@rene....The code is pretty simple and has been like this for years..I have a function that does this. The code is literally cut and paste from the SDK docs. Functioally it all works IF the tiapp. has background location mode enabled(Which apple review team doesn't like)
function getLocation(){ Titanium.Geolocation.getCurrentPosition(function(loc){}); } if (Ti.Geolocation.hasLocationPermissions()) { getLocation(); } else { Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) { if (e.success) { getLocation(); } else { //alert('could not obtain location permissions'); } }); }@rene. What are you asking me for?
[~peterladis] So I tried the following Added the following to the plist section of my tiapp
Added the following code in app.jsThis prints the following warning, but still worksconst win = Ti.UI.createWindow(); const btn = Ti.UI.createButton({ title: 'get location', top: 50 }); btn.addEventListener('click', ()=> { function getLocation(){ Titanium.Geolocation.getCurrentPosition(function(loc){ console.log(loc); }); } if (Ti.Geolocation.hasLocationPermissions()) { console.log('has'); getLocation(); } else { Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) { if (e.success) { getLocation(); } else { console.log(e); alert('could not obtain location permissions'); } }); } }); win.add(btn); win.open();So I updated the[WARN] Trying to use location services without requesting location permissions. Use either: [WARN] Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) { [WARN] // Handle authorization via e.success [WARN] }) [WARN] or [WARN] Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) { [WARN] // Handle authorization via e.success [WARN] }) [WARN] Picking the hightest permission by default. [INFO] { [INFO] success: true, [INFO] code: 0, [INFO] source: {}, [INFO] type: 'location', [INFO] coords: { [INFO] timestamp: 1583763807621, [INFO] speed: -1, [INFO] longitude: -6.27044677734375, [INFO] floor: { level: 0 }, [INFO] latitude: 53.339996337890625, [INFO] accuracy: 149000, [INFO] heading: -1, [INFO] altitude: 0, [INFO] altitudeAccuracy: -1 [INFO] } [INFO] }hasLocationPermissionscall like below, this still returns the location and no longer logs the warning. I suspect that maybe there might be something extra in your app that is causing this?const win = Ti.UI.createWindow(); const btn = Ti.UI.createButton({ title: 'get location', top: 50 }); btn.addEventListener('click', ()=> { function getLocation(){ Titanium.Geolocation.getCurrentPosition(function(loc){ console.log(loc); }); } if (Ti.Geolocation.hasLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS)) { console.log('has'); getLocation(); } else { Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) { if (e.success) { getLocation(); } else { console.log(e); alert('could not obtain location permissions'); } }); } }); win.add(btn); win.open();@Ewan I think I found it there was a meeting like this Ti.Geolocation.setAllowsBackgroundLocationUpdates(true); I took the tout..and seems to work now --Peter
Glad it worked out!