Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Map goes blank when animating dezoom #8300

Closed

Description

@mrlem

Platform: Android
Mapbox SDK version: 4.2.2

Steps to trigger behavior

  1. Create a minimal app (largely inspired by the sample app):
public class MainActivity extends Activity {

    MapView mapView;
    MapboxMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MapboxAccountManager.start(getApplicationContext(), "mapbox token goes here");

        setContentView(R.layout.activity_main);

        mapView = (MapView) findViewById(R.id.mapview);
        mapView.onCreate(savedInstanceState);
        mapView.getMapAsync(new OnMapReadyCallback() {
            @Override
            public void onMapReady(MapboxMap map) {
                MainActivity.this.map = map;

                double distance = 0.001;
                LatLngBounds bounds = new LatLngBounds.Builder()
                    .include(new LatLng(48.866800199999986 - distance, 2.3536729199999993 - distance))
                    .include(new LatLng(48.866800199999986 + distance, 2.3536729199999993 + distance))
                    .build();
                map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10));
                map.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
                    @Override
                    public void onMapClick(@NonNull LatLng point) {
                        // works:
                        // MainActivity.this.map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.866800199999986, 2.3536729199999993), 0));

                        // doesn't work:
                        // (coordinates could be something else)
                        MainActivity.this.map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.866800199999986, 2.3536729199999993), 0), 100);
                    }
                });
            }
        });
    }

    // Add the mapView lifecycle to the activity's lifecycle methods
    @Override
    public void onResume() {
        super.onResume();
        mapView.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
        mapView.onPause();
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        mapView.onLowMemory();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }
}
  1. Tap the map

Expected behavior

Tapping the map should make us dezoom to the earth view

Actual behavior

Tapping the map causes the map to disappear

Notes

Upon investigation:

  • debugging shows that camera position target LatLng has NaN longitude
  • using moveCamera instead of animateCamera works

Based on these observations, my guess would be that something goes wrong near https://github.com/mapbox/mapbox-gl-native/blob/master/src/mbgl/map/transform.cpp#L169

Thank's in advance for your help!

Activity

  1. plailleur commented on Mar 7, 2017

    @plailleur

    +1

  2. jeankruger commented on Mar 7, 2017

    @jeankruger

    +1

  3. added
    Android
    on Mar 7, 2017
  4. tobrun commented on Mar 7, 2017

    @tobrun
    Member

    Thank you for reaching out, the many up votes and providing the code to reproduce.

  5. added
    Core
    and removed
    Android
    on Mar 7, 2017
  6. tobrun commented on Mar 7, 2017

    @tobrun
    Member

    I have been log-debugging the C++ code, it seems that the calculated start point and end point are the same when we are attempting startTransition in Transform::flyTo. This is because the target LatLng is rounded in the process. Since there isn't a change of the camera position target LatLng, I'm going to add an if check to validate for same position and execute an easeTo instead.

    Update: above observation is false, I was mislead by the logger as it rounds values.

  7. tobrun commented on Mar 7, 2017

    @tobrun
    Member

    Linking #8097 as this is exactly the same issue though I'm getting values for u1 : 1.962334 while that PR would only fix it for u1 < 0.5.

  8. tobrun commented on Mar 7, 2017

    @tobrun
    Member

    Was able to pinpoint the source of the NaN LatLngs, it seems that the Zoom-out factor during ascent = infinite.

  9. mrlem commented on Mar 7, 2017

    @mrlem
    Author

    Thanks for the feedback! (and this great project, by the way)
    Indeed, the distance between start and end position seems to play a role, I used a test code with the same value, but moving a target with some significant distance seems to be a problem too.

    e.g. map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.766800199999986, 2.3536729199999993), 0), 100);
    ... triggers the problem
    map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(47.766800199999986, 2.3536729199999993), 0), 100);
    ... doesn't

    So there's definitely a threshold at play.

  10. self-assigned this
    on Mar 7, 2017
  11. added this to the android-v5.0.0 milestone on Mar 8, 2017
  12. tobrun commented on Mar 13, 2017

    @tobrun
    Member

    @1ec5

    In case you want to try reproducing this one iOS:

    The initial camera values are:

    LatLng [latitude=48.866803480081785, longitude=2.3536813028885035, altitude=0.0], Zoom:16.83813356001133, Bearing:0.0, Tilt:0.0
    

    The flyTo camera values are:

    LatLng [latitude=48.866800199999986, longitude=2.3536729199999993, altitude=0.0], Zoom:0.0, Bearing:-1.0, Tilt:-1.0
    
  13. modified the milestones: , android-v5.0.0 on Mar 17, 2017
  14. added a commit that references this issue on Jun 6, 2017
    84ddf73
  15. added a commit that references this issue on Jun 6, 2017
    facc3d5
  16. added a commit that references this issue on Jun 15, 2017
    28b6bbb
  17. added a commit that references this issue on Jul 5, 2017
    20a5ef6
  18. removed this from the milestone on Sep 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Core

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions