From 9704426d14a69b1ffda278b9b5f65f7f41136347 Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Wed, 11 Oct 2017 12:53:54 -0700 Subject: [PATCH] Don't recycle replaced nodes in a11y cache This is a patch for another bug. When the cache refreshes nodes, it marks the transaction to bypass the cache. We still, however, replace the cached node. If we recycle the node as well, we end up refreshing it after it's been recycled and end up with a sealed node in the cache. That node can then be obtained and then throw an exception when a setter is called. These exceptions are almost impossible to debug. I'm going to leave the bug open to roll this CL back and fix the cache's behavior, but this fix seems safer this late. Bug: 35626351 Test: Ran a11y CTS and unit tests. Verified on instrumented master build that the error indeed goes away. Removing one line from unit tests that requires recycling. Change-Id: Icc9a43ee49cf7c6bfa996839b35954faaf31621c --- core/java/android/view/accessibility/AccessibilityCache.java | 2 -- .../android/server/accessibility/AccessibilityCacheTest.java | 1 - 2 files changed, 3 deletions(-) diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java index 0f21c5c85f4b4..d7851171cd67a 100644 --- a/core/java/android/view/accessibility/AccessibilityCache.java +++ b/core/java/android/view/accessibility/AccessibilityCache.java @@ -329,8 +329,6 @@ public final class AccessibilityCache { final long oldParentId = oldInfo.getParentNodeId(); if (info.getParentNodeId() != oldParentId) { clearSubTreeLocked(windowId, oldParentId); - } else { - oldInfo.recycle(); } } diff --git a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityCacheTest.java b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityCacheTest.java index 02f645a07a5f0..c8dc9ff51a1b3 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityCacheTest.java +++ b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityCacheTest.java @@ -77,7 +77,6 @@ public class AccessibilityCacheTest { mAccessibilityCache.clear(); AccessibilityInteractionClient.getInstance().clearCache(); assertEquals(0, numA11yWinInfosInUse.get()); - assertEquals(0, numA11yNodeInfosInUse.get()); } @Test