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

Setting layer property inside OnCameraMoveListener causes infinite recursion #10687

Closed
themics opened this issue Dec 13, 2017 · 2 comments
Closed
Labels
Android Mapbox Maps SDK for Android

Comments

@themics
Copy link
Contributor

themics commented Dec 13, 2017

Platform: Android
Mapbox SDK version: 5.2.1

Steps to trigger behavior

  1. Change layer's fill color inside OnCameraMoveListener.
map.addOnCameraMoveListener(() -> {
    FillLayer layer = mapboxMap.getLayerAs("water");
    int color = layer.getFillColor().getColorInt() == Color.RED ? Color.BLUE : Color.RED;
    layer.setProperties(fillColor(color));
});

Expected behavior

  • Layer's fill color is changing frame by frame.

Actual behavior

  • App crashed by infinite recursion.
  • Even app does not fall to infinite recursion, OnCameraMoveListener called one more time.

Changing a layer's property triggers repaint, so MapObserver::onCameraIsChanging() / onCameraDidChange() is called on the same call stack.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Dec 13, 2017
@tobrun
Copy link
Member

tobrun commented Dec 13, 2017

Thank you for reaching out and reporting this. Was able to reproduce. For now you can work around this by posting your callback code to the end of the message queue using Handler#post(Runnable). I'm looking into fixing this up at the SDK side by introducing same setup there.

@tobrun tobrun added this to the android-v5.2.2 milestone Dec 13, 2017
@tobrun
Copy link
Member

tobrun commented Dec 14, 2017

Closed with #10690

@tobrun tobrun closed this as completed Dec 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

2 participants