Use View.executeHardwareAction for onDetachedFromWindow

If AwContents has hardware resources to clean up in
onDetachedFromWindow (ie functor is not null), then use
View.executeHardwareAction to ensure that a context is current in
detach.

BUG: 10911502

Change-Id: I69392745cc375bc2f804fbc056d29d58ce06c000
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromium.java b/chromium/java/com/android/webview/chromium/WebViewChromium.java
index 46cfd66..3368d58 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromium.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromium.java
@@ -1623,7 +1623,18 @@
             });
             return;
         }
-        mAwContents.onDetachedFromWindow();
+
+        Runnable detachAwContents = new Runnable() {
+            @Override
+            public void run() {
+                mAwContents.onDetachedFromWindow();
+            }
+        };
+
+        if (mGLfunctor == null || !mWebView.executeHardwareAction(detachAwContents)) {
+            detachAwContents.run();
+        }
+
         if (mGLfunctor != null) {
             mGLfunctor.detach();
         }