Skip to content

Commit 35fbe2a

Browse files
author
Adam Cohen
committed
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
1 parent 9c06ac0 commit 35fbe2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/java/android/widget/RemoteViewsAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ private int getFarthestPositionFrom(int pos) {
614614
maxDistIndexNonRequested = i;
615615
maxDistNonRequested = dist;
616616
}
617-
if (dist > maxDist) {
617+
if (dist >= maxDist) {
618618
// maxDist/maxDistIndex will store the index of the farthest position
619619
// regardless of whether it was directly requested or not
620620
maxDistIndex = i;

0 commit comments

Comments
 (0)