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)

Most upvoted comments

Finally, there seems to be a surefire way to reproduce this!

See https://github.com/streetcomplete/StreetComplete/issues/2601

Quoting @mkotzjan

I’m able to crash the app by zooming in and out quickly using only one finger. I know that this is rather unusual behavior, i just discovered this by accident. See also the attached video

How to Reproduce

  • Open StreetComplete
  • Double tap the map and hold on the second tap
  • move finger up or down for zooming in or out with just one finger
  • move finger quickly up and down to crash app

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.

One uncertainty that is missing is that it may be possible that the Android animation system fucks up and somehow reaches NaN for latitude during animation 🤷 . So what I’ll do is to fail early and throw an Exception when trying to call MapController::updateCameraPosition with a NaN. Then, I’ll notify you what crash reports I get in the future.

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

  1. the only point from where MapController::updateCameraPosition is called is from the CameraManager class which on its interface only accepts the LatLon interface for position. LatLon is then translated to tangram’s LngLat internally in that class.
  2. The only implementation of LatLon that is used in the app is the class OsmLatLon which does the LatLons.checkValidity check in its constructor. So, it is not possible to pass an invalid position to the CameraManager

One uncertainty that is missing is that it may be possible that the Android animation system fucks up and somehow reaches NaN for latitude during animation 🤷 . So what I’ll do is to fail early and throw an Exception when trying to call MapController::updateCameraPosition with a NaN. Then, I’ll notify you what crash reports I get in the future.