Carto MapView re-use causes crash

55 views Asked by At

While using the Carto Mobile map SDK, the app experiences a crash soon after the main activity is replaced with another full screen view, and tried to return to it.

I have tried to remove the map render and map render listener in the onPause for the main activity as the map screen is replaced.

I have inspected demo apps available, but they do not seem to exhibit the same behaviour. I fetch the latest version as a Gradle dependancy.

I have added these lines to the end of the onPause call:

mapView.getMapRenderer().setMapRendererListener(null);
mapView.getMapRenderer().delete();

I expect the app to behave as expected, but this message is logged out:

abort_message: assertion "terminating with uncaught exception of type carto::InvalidArgumentException: Layer already attached to a different renderer" failed

and then the app crashes.

I did not originally create this app, I am a contractor hired to repair this app which has not been worked on for a few years, some of the files date back to 2013.

Please help if you can.

1

There are 1 answers

0
Grant Davis On

I believe I have the fix for this problem. Above the first line above, I have removed all the layers from the map using:

mapView.getLayers().clear();

Hope that helps someone else with the same problem.