summaryrefslogtreecommitdiff
path: root/core/java/android/view/HardwareRenderer.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-04-23 18:22:09 -0700
committerRomain Guy <romainguy@google.com>2012-04-23 20:29:31 -0700
commitba6be8a62dcdb3ffd210cd36b9af4e3a658eac47 (patch)
tree04f9b4d5589333970c91e51af6280a5859b78460 /core/java/android/view/HardwareRenderer.java
parent88fffb7a34313d5e94b3974d444d07bd6a4879a4 (diff)
Prevent WebView from crashing when detached from the window
Bug #6365056 WebView enqueues a functor in the hardware renderer to handle animations and this functor is called at a later time by the hardware renderer. However, the functor was not removed from the queue when WebView was removed from the window. This could cause the hardware renderer to attempt to execute an invalid functor and lead to a crash. Change-Id: I9d38e80f3fdc5e29d4d0cdfa1e893c251a954508
Diffstat (limited to 'core/java/android/view/HardwareRenderer.java')
-rw-r--r--core/java/android/view/HardwareRenderer.java45
1 files changed, 43 insertions, 2 deletions
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 1ec754a1dde1..b9295c368493 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -437,6 +437,27 @@ public abstract class HardwareRenderer {
abstract void setSurfaceTexture(HardwareLayer layer, SurfaceTexture surfaceTexture);
/**
+ * Detaches the specified functor from the current functor execution queue.
+ *
+ * @param functor The native functor to remove from the execution queue.
+ *
+ * @see HardwareCanvas#callDrawGLFunction(int)
+ * @see #attachFunctor(android.view.View.AttachInfo, int)
+ */
+ abstract void detachFunctor(int functor);
+
+ /**
+ * Schedules the specified functor in the functors execution queue.
+ *
+ * @param attachInfo AttachInfo tied to this renderer.
+ * @param functor The native functor to insert in the execution queue.
+ *
+ * @see HardwareCanvas#callDrawGLFunction(int)
+ * @see #detachFunctor(int)
+ */
+ abstract void attachFunctor(View.AttachInfo attachInfo, int functor);
+
+ /**
* Initializes the hardware renderer for the specified surface and setup the
* renderer for drawing, if needed. This is invoked when the ViewAncestor has
* potentially lost the hardware renderer. The hardware renderer should be
@@ -1202,13 +1223,33 @@ public abstract class HardwareRenderer {
}
if ((status & DisplayList.STATUS_INVOKE) != 0) {
- attachInfo.mHandler.removeCallbacks(mFunctorsRunnable);
- mFunctorsRunnable.attachInfo = attachInfo;
+ scheduleFunctors(attachInfo);
+ }
+ }
+
+ private void scheduleFunctors(View.AttachInfo attachInfo) {
+ mFunctorsRunnable.attachInfo = attachInfo;
+ if (!attachInfo.mHandler.hasCallbacks(mFunctorsRunnable)) {
// delay the functor callback by a few ms so it isn't polled constantly
attachInfo.mHandler.postDelayed(mFunctorsRunnable, FUNCTOR_PROCESS_DELAY);
}
}
+ @Override
+ void detachFunctor(int functor) {
+ if (mCanvas != null) {
+ mCanvas.detachFunctor(functor);
+ }
+ }
+
+ @Override
+ void attachFunctor(View.AttachInfo attachInfo, int functor) {
+ if (mCanvas != null) {
+ mCanvas.attachFunctor(functor);
+ scheduleFunctors(attachInfo);
+ }
+ }
+
/**
* Ensures the current EGL context is the one we expect.
*