Avoid saving result from WeakHashMap.size()
This value is only valid until the next call on the hash map because it can garbage collect before anything that resizes or accesses the backing table Bug: 266978825 Change-Id: I8c8e2df8c205130da0d3831b88450cc2534f97bb
This commit is contained in:
@@ -62,7 +62,6 @@ public class SurfaceControlRegistry {
|
||||
private static class DefaultReporter implements Reporter {
|
||||
public void onMaxLayersExceeded(WeakHashMap<SurfaceControl, Long> surfaceControls,
|
||||
int limit, PrintWriter pw) {
|
||||
final int size = Math.min(surfaceControls.size(), limit);
|
||||
final long now = SystemClock.elapsedRealtime();
|
||||
final ArrayList<Map.Entry<SurfaceControl, Long>> entries = new ArrayList<>();
|
||||
for (Map.Entry<SurfaceControl, Long> entry : surfaceControls.entrySet()) {
|
||||
@@ -71,6 +70,7 @@ public class SurfaceControlRegistry {
|
||||
// Sort entries by time registered when dumping
|
||||
// TODO: Or should it sort by name?
|
||||
entries.sort((o1, o2) -> (int) (o1.getValue() - o2.getValue()));
|
||||
final int size = Math.min(entries.size(), limit);
|
||||
|
||||
pw.println("SurfaceControlRegistry");
|
||||
pw.println("----------------------");
|
||||
|
||||
Reference in New Issue
Block a user