{ "id": "166794", "key": "TIMOB-24535", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "17608", "name": "Release 6.1.0", "archived": false, "released": true, "releaseDate": "2017-05-26" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-05-07T13:32:37.000+0000", "created": "2017-03-26T15:49:07.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2017-05-09T17:40:42.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "When listening for the location event for iOS, the speed returned is very often -1 and sometimes an incorrect value. It's very inconsistent. This was working before with our previous app release with SDK 5.5.0.GA but it no longer does with the newest SDK 6.0.2. I also tried rolling back to 5.5.0.GA but this doesn't seem to fix the issue either. \r\n\r\n\r\n\r\nindex.js:\r\n{code:js}\r\nvar numOfCalls = 0;\r\nvar locationCallback = function(e) {\r\n\t$.numOfLocationCalls.text = \"Num of calls: \" + numOfCalls;\r\n\tnumOfCalls++;\r\n\tif (!e.success || e.error) {\r\n\t\t$.labelSpeed.text = \"Error:\" + JSON.stringify(e);\r\n } else {\r\n \tvar mph = e.coords.speed * 2.23694;\r\n \t$.label.text = \"Speed: \" + mph;\r\n \tvar overSpeed = (e.coords.speed > 5) ? true : false;\r\n \t$.labelSpeed.text = \"Over speed: \" + overSpeed;\r\n }\r\n};\r\n\r\nTi.Geolocation.addEventListener('location', locationCallback);\r\nTi.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_GPS;\r\nTi.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;\r\nTi.Geolocation.distanceFilter = 5;\r\n\r\n$.index.open();\r\n{code}\r\n\r\nindex.xml:\r\n{code:xml}\r\n\r\n\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nin tiapp.xml, I have these permissions:\r\n{code:xml}\r\nNSLocationWhenInUseUsageDescription\r\nYour location will only be used when the app is running.\r\n{code}\r\n\r\nNOTE: I tried adding this to the axway support portal as I am a enterprise developer, but I can't seem to login at the moment. Will likely be adding this there once I get that sorted out.", "attachment": [], "flagged": false, "summary": "iOS: Ti.Geolocation Speed returning incorrect number or -1 for speed, requires docs-clarification", "creator": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "iOS, SDK 6.0.2.GA", "closedSprints": [ { "id": 883, "state": "closed", "name": "2017 Sprint 09 SDK", "startDate": "2017-04-23T21:46:54.309Z", "endDate": "2017-05-07T21:46:00.000Z", "completeDate": "2017-05-08T00:25:44.276Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "415842", "author": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I forgot to mention - this seems to work perfectly in the simulator when changing the location type in the debug menu. The issue occurs when driving and using an actual device.\r\nThere is also a stackoverflow question on this here: http://stackoverflow.com/questions/42615548/appcelerator-geolocation-never-returns-a-speed-on-ios ", "updateAuthor": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-26T15:57:31.000+0000", "updated": "2017-03-26T15:57:31.000+0000" }, { "id": "415847", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey Amanda! Maybe it is an iOS issue? Especially if it worked with 5.5.0 but does not when using 5.5.0 now. We did not change Geolocation-related API's between those versions. We will take a look", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-03-26T20:21:44.000+0000", "updated": "2017-03-26T20:21:44.000+0000" }, { "id": "415868", "author": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I forgot to remove the onClick event for the label in index.xml, sorry about that.\r\n\r\nIt might be that iOS did change something in relation to this. Testing with hyper loop, it seems that for the core location accuracy ( CLLocationAccuracy ) , the most consistent value has been k​CLLocation​Accuracy​Best​For​Navigation. And we've been using Ti.Geolocation.ACCURACY_BEST, I'm guessing maps to k​CLLocation​Accuracy​Best. We ended up testing it again with Ti.Geolocation.ACCURACY_BEST_FOR_NAVIGATION accuracy, and it finally seems to be working again as expected. Can this be updated in the documentation somewhere?", "updateAuthor": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-03-27T14:24:26.000+0000", "updated": "2017-03-27T14:24:26.000+0000" }, { "id": "418261", "author": { "name": "combyses", "key": "combyses", "displayName": "Kam Rezvani", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Ti.Geolocation.ACCURACY_BEST does not work any more. It is used to as it is indicated here but it no longer is. Please address this issue. We are substituting ACCURACY_BEST_FOR_NAVIGATION as a workaround. ", "updateAuthor": { "name": "combyses", "key": "combyses", "displayName": "Kam Rezvani", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-04-28T17:45:25.000+0000", "updated": "2017-04-28T17:45:25.000+0000" }, { "id": "418598", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Checking this issue.\r\n", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-05-02T16:42:55.000+0000", "updated": "2017-05-02T16:42:55.000+0000" }, { "id": "418659", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "subtle changes to the sample code:\r\nadd {{$.index.open}} to index.js\r\nremove {{onClick=\"doClick\"}} from index.xml", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-05-02T18:10:53.000+0000", "updated": "2017-05-02T18:10:53.000+0000" }, { "id": "418867", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "I see the same issue when using Ti.Geolocation.ACCURACY_BEST, using:\r\nMacOS 10.12 (16A323)\r\nStudio 4.8.1.201612050850\r\nTi SDK 6.0.4.GA\r\nAppc NPM 4.2.9\r\nAppc CLI 6.2.0\r\nAlloy 1.9.11\r\nXcode 8.3.2 (8E2002)\r\n\r\nI will get a -1 for the coords.speed value. In the couple hours I was testing it, I did not see the negative value while driving, but I would see it when I stopped (not consistently though). After changing the accuracy to Ti.Geolocation.ACCURACY_BEST_FOR_NAVIGATION, I did not see a negative value for speed. Again this was only within a couple hours of testing, so the negative could be so intermittent that it did not show in that time.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-05-02T21:40:45.000+0000", "updated": "2017-05-02T21:40:45.000+0000" }, { "id": "419022", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Edited the code in the description to include the changes needed for it to run.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-05-03T16:04:39.000+0000", "updated": "2017-05-03T16:04:39.000+0000" }, { "id": "419023", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Looks like native behavior:\r\n- http://stackoverflow.com/a/4956243/5537752\r\n- http://stackoverflow.com/questions/30098202/cllocationmanager-always-returning-speed-1\r\n\r\nStill can check it though, but I am also pretty sure this cannot be an iOS issue, since all we do to return the speed is [this line|https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/GeolocationModule.m#L971] to bridge the native type to the JavaScript type.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-05-03T16:11:30.000+0000", "updated": "2017-05-03T16:11:30.000+0000" }, { "id": "419025", "author": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It's very possible it's native behavior. If that is the case, the documentation for appcelerator needs to be updated to reflect if we are needing speed, then the navigation setting needs to be used.", "updateAuthor": { "name": "amandavines", "key": "amandavines", "displayName": "Amanda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-05-03T16:15:43.000+0000", "updated": "2017-05-03T16:15:43.000+0000" }, { "id": "419026", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~amandavines] You are very correct! Here are my test-results (wrapping the test-case into a single file):\r\n{code:js}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: '#fff'\r\n});\r\n\r\nvar numOfCalls = 0;\r\n\r\nvar label = Ti.UI.createLabel({\r\n text: 'Speed: (Not set)',\r\n top: 100\r\n});\r\n\r\nvar labelSpeed = Ti.UI.createLabel({\r\n text: 'Error: (None)',\r\n top: 200,\r\n color: 'red' \r\n});\r\n\r\nvar numOfLocationCalls = Ti.UI.createLabel({\r\n text: '# Location Calls: ' + numOfCalls,\r\n top: 300\r\n});\r\n\r\nvar locationCallback = function(e) {\r\n\tnumOfLocationCalls.text = \" Location Calls: \" + numOfCalls;\r\n\tnumOfCalls++;\r\n\t\r\n if (!e.success || e.error) {\r\n\t\tlabelSpeed.text = \"Error: \" + JSON.stringify(e);\r\n } else {\r\n \tvar mph = e.coords.speed * 2.23694;\r\n \tlabel.text = \"Speed: \" + mph;\r\n \tvar overSpeed = (e.coords.speed > 5) ? true : false;\r\n \tlabelSpeed.text = \"Over speed: \" + overSpeed;\r\n }\r\n};\r\n \r\nTi.Geolocation.addEventListener('location', locationCallback);\r\nTi.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_GPS;\r\nTi.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;\r\nTi.Geolocation.distanceFilter = 5;\r\n\r\nwin.add([label, labelSpeed, numOfLocationCalls]);\r\nwin.open();\r\n{code}\r\nI was driving around the Apple campus (virtually, using the iOS Simulator) and I've got correct values. Anyway, when you do not have a clear GPS signal, it will have value anomalies around the speed like stated in the above links. Do you have a proper wording for a note we could add? I feel like I am not into it enough so far to word it properly. Maybe this?\r\n{quote}\r\nDue to the Apple Geolocation API, set the {{Ti.Geolocation.accuracy}}\r\n to {{Ti.Geolocation.ACCURACY_BEST_FOR_NAVIGATION}} in order to properly measure speed changes and prevent the application from returning {{-1}} values inside the {{location}} event.\r\n{quote}\r\nI would add this paragraph to the {{location}} event docs (see exact wording in the PR below). Finally, I am still wondering why it would be different between 5.5.x and 6.x, there has been no change between those versions. If you can, please check that one again.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-05-03T16:21:20.000+0000", "updated": "2017-05-03T16:34:08.000+0000" }, { "id": "419029", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/9010\r\n\r\nNo backport required since docs are always pushed from master.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-05-03T16:31:28.000+0000", "updated": "2017-05-04T10:48:25.000+0000" }, { "id": "419377", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Text/wording changes are good and describe the issue/solution.", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-05-09T17:40:42.000+0000", "updated": "2017-05-09T17:40:42.000+0000" } ], "maxResults": 13, "total": 13, "startAt": 0 } } }