OSDN Git Service

Revert "Destroy DisplayLists on time"
authorJohn Reck <jreck@google.com>
Tue, 24 Jan 2017 18:06:44 +0000 (18:06 +0000)
committerJohn Reck <jreck@google.com>
Tue, 24 Jan 2017 18:06:44 +0000 (18:06 +0000)
This reverts commit 2874daa4d38bddd3a5f0edb3774d5e5884dd9554.

It broke a bunch of stuff and occasionally blank webviews are preferable to native crashes

Bug: 34638191
Change-Id: I6c5849d4ef0db3ac7c9ed1b1a128f2272a5344c2

core/java/android/view/ThreadedRenderer.java
core/java/android/view/View.java
core/java/android/view/ViewGroup.java
core/jni/android_view_RenderNode.cpp

index b0826a8..f3ebcb4 100644 (file)
@@ -360,7 +360,6 @@ public final class ThreadedRenderer {
     void destroy() {
         mInitialized = false;
         updateEnabledState(null);
-        mRootNode.discardDisplayList();
         nDestroy(mNativeProxy, mRootNode.mNativeRenderNode);
     }
 
@@ -492,12 +491,20 @@ public final class ThreadedRenderer {
      */
     void destroyHardwareResources(View view) {
         destroyResources(view);
-        mRootNode.discardDisplayList();
         nDestroyHardwareResources(mNativeProxy);
     }
 
     private static void destroyResources(View view) {
         view.destroyHardwareResources();
+
+        if (view instanceof ViewGroup) {
+            ViewGroup group = (ViewGroup) view;
+
+            int count = group.getChildCount();
+            for (int i = 0; i < count; i++) {
+                destroyResources(group.getChildAt(i));
+            }
+        }
     }
 
     /**
index 623b9ce..9d1af50 100644 (file)
@@ -16642,12 +16642,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         // safe to free its copy of the display list as it knows that we will
         // push an updated DisplayList if we try to draw again
         resetDisplayList();
-        if (mOverlay != null) {
-            mOverlay.getOverlayView().destroyHardwareResources();
-        }
-        if (mGhostView != null) {
-            mGhostView.destroyHardwareResources();
-        }
     }
 
     /**
@@ -16818,9 +16812,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     }
 
     private void resetDisplayList() {
-        mRenderNode.discardDisplayList();
+        if (mRenderNode.isValid()) {
+            mRenderNode.discardDisplayList();
+        }
 
-        if (mBackgroundRenderNode != null) {
+        if (mBackgroundRenderNode != null && mBackgroundRenderNode.isValid()) {
             mBackgroundRenderNode.discardDisplayList();
         }
     }
index 269dd77..1b42a90 100644 (file)
@@ -3449,16 +3449,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
         super.dispatchDetachedFromWindow();
     }
 
-    /** @hide */
-    @Override
-    protected void destroyHardwareResources() {
-        super.destroyHardwareResources();
-        int count = getChildCount();
-        for (int i = 0; i < count; i++) {
-            getChildAt(i).destroyHardwareResources();
-        }
-    }
-
     /**
      * @hide
      */
index 3eccc42..d75d5c1 100644 (file)
@@ -88,7 +88,6 @@ void onRenderNodeRemoved(JNIEnv* env, RenderNode* node) {
         return;
     }
 
-    node->setStagingDisplayList(nullptr, nullptr);
     // Update the valid field, since native has already removed
     // the staging DisplayList
     env->SetBooleanField(jnode, gRenderNode_validFieldID, false);