tangram-es: Rarely MapController.getCameraPosition().longitude returns NaN
TO REPRODUCE THE ISSUE, FOLLOW THESE STEPS:
Call MapController.getCameraPosition().longitude. Very rarely, it returns NaN.
Reproduction is unknown, I got a few crash reports because the app expects valid lat/lon pairs.
It happened once roughly when the map was displayed near latitude 48.864143, longitude 16.469961, quite an innocent position.
ENVIRONMENT:
at least Android 10, tangram-es 0.12.0
OTHER:
I am in contact with the person for which this happened several times. Should I ask him anything specific?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (21 by maintainers)
Finally, there seems to be a surefire way to reproduce this!
See https://github.com/streetcomplete/StreetComplete/issues/2601
Quoting @mkotzjan
Several users could confirm that they could reproduce this.
That’s a really good tip, I was able to finally reproduce this crash! In the exception I saw, both longitude and latitude were NaN. Have to do a bit more diagnosis, but I bet there’s a line that’s dividing by a zero delta time or taking the log of a zero delta zoom.
Since tangram 0.14.1, it seems as if the issue happens more often now (~4 times as often).
I also fail early and throw an exception if the latitude and longitude is invalid whenever I push a position to Tangram-ES. That exception is not thrown however, so it doesn’t look like my app is supplying tangram-es with invalid latitude/longitude.
Hm, I checked. The validity is checked. I can be sure of it because
MapController::updateCameraPositionis called is from theCameraManagerclass which on its interface only accepts theLatLoninterface for position.LatLonis then translated to tangram’sLngLatinternally in that class.LatLonthat is used in the app is the classOsmLatLonwhich does theLatLons.checkValiditycheck in its constructor. So, it is not possible to pass an invalid position to theCameraManagerOne uncertainty that is missing is that it may be possible that the Android animation system fucks up and somehow reaches
NaNfor latitude during animation 🤷 . So what I’ll do is to fail early and throw an Exception when trying to callMapController::updateCameraPositionwith aNaN. Then, I’ll notify you what crash reports I get in the future.