Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35fbe2a5 authored by Adam Cohen's avatar Adam Cohen
Browse files

Fix ANR which could occur for collection widgets with very large items

-> We cache RemoteViews which populate the AdapterViews, but only
   up to a total memory amount of 2MB. The remainder of the cache
   is pruned out. If _every_ item is greater than 2MB, we were failing
   to prune the last item, leaving the framework in a loop on a bg
   thread, but holding a lock required by the main thread.

Change-Id: I0574a25a59ebec6586ae223fff6605c0fee953c3
parent 9c06ac09
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -614,7 +614,7 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback
                    maxDistIndexNonRequested = i;
                    maxDistIndexNonRequested = i;
                    maxDistNonRequested = dist;
                    maxDistNonRequested = dist;
                }
                }
                if (dist > maxDist) {
                if (dist >= maxDist) {
                    // maxDist/maxDistIndex will store the index of the farthest position
                    // maxDist/maxDistIndex will store the index of the farthest position
                    // regardless of whether it was directly requested or not
                    // regardless of whether it was directly requested or not
                    maxDistIndex = i;
                    maxDistIndex = i;