novalabio/react-native-maps-super-cluster

App crashes after a bunch of zooming and switching app to background

JayHuang opened this issue · 1 comments

Our app has a view consisting of a map and a bunch of pins that are clustered depending on the zoom level.

If the user zooms in and out a couple times, causing the pins to be clustered and de-clustered, then switches to a different app (sending current app to background), the app will crash.

We have been trying to track this down for a while now, and it's been particularly hard to track down, but after a lot of testing using TooLargeTool, it seems that the problem is that the repeated zooming (clustering/declustering of pins) causes a constant increase in the amount of data in the Activity, which is never cleaned up. Once the user switches app and the app calls onSaveInstanceState to save state to return to later, the amount of data approaches ~1MB (see: https://stackoverflow.com/questions/39098590/android-os-transactiontoolargeexception-on-nougat), and causes the app to crash.

We've also tested with clustering disabled, or trying it with react-native-maps only, and it seems neither exhibits this behaviour, only with clustering on.

here is some cleaned up output from TooLargeTool

    * android:viewHierarchyState = 118.4 KB
    * android:lastAutofillId = 0.1 KB
    * android:fragments = 0.4 KB

Number of views inside viewHierarchyState: 1556

-----------------------------------------------

    * android:viewHierarchyState = 179.9 KB
    * android:lastAutofillId = 0.1 KB
    * android:fragments = 0.4 KB

Number of views inside viewHierarchyState: 2365

-----------------------------------------------

    * android:viewHierarchyState = 214.7 KB
    * android:lastAutofillId = 0.1 KB
    * android:fragments = 0.4 KB

Number of views inside viewHierarchyState: 2824

-----------------------------------------------

    * android:viewHierarchyState = 316.2 KB
    * android:lastAutofillId = 0.1 KB
    * android:fragments = 0.4 KB

Number of views inside viewHierarchyState: 4159

this is how the viewHierarchyState for the map looks

android:viewHierarchyState => Bundle[{android:views={1=android.view.AbsSavedState$1@ec820ea, 2=android.view.AbsSavedState$1@ec820ea, 3=android.view.AbsSavedState$1@ec820ea,....}}]

with more and more of these views (android.view.AbsSavedState$1@ec820ea) being added over and over until the crash occurs.

Please provide some code, it is impossible to debug otherwise. Moreover, this is the first time we hear this kind of misbehavior, so posting your code will help figure out if this is actually a library issue.