@@ -2069,11 +2069,20 @@ public void destroy() {
20692069 }
20702070
20712071 private void destroyImpl () {
2072- int drawGLFunction = nativeGetDrawGLFunction (mNativeClass );
20732072 ViewRootImpl viewRoot = mWebView .getViewRootImpl ();
2074- Log .d (LOGTAG , String .format ("destroyImpl, functor %x, viewroot == null %b, isHWAccel %b" ,
2075- drawGLFunction , (viewRoot == null ),
2076- mWebView .isHardwareAccelerated ()));
2073+ if (viewRoot != null ) {
2074+ Log .e (LOGTAG , "Error: WebView.destroy() called while still attached!" );
2075+ }
2076+
2077+ if (mWebView .isHardwareAccelerated ()) {
2078+ int drawGLFunction = nativeGetDrawGLFunction (mNativeClass );
2079+ if (drawGLFunction != 0 && viewRoot != null ) {
2080+ // functor should have been detached in onDetachedFromWindow, do
2081+ // additionally here for safety
2082+ viewRoot .detachFunctor (drawGLFunction );
2083+ }
2084+ }
2085+
20772086 mCallbackProxy .blockMessages ();
20782087 clearHelpers ();
20792088 if (mListBoxDialog != null ) {
@@ -5301,12 +5310,9 @@ public void onDetachedFromWindow() {
53015310
53025311 updateHwAccelerated ();
53035312
5304- int drawGLFunction = nativeGetDrawGLFunction (mNativeClass );
5305- ViewRootImpl viewRoot = mWebView .getViewRootImpl ();
5306- Log .d (LOGTAG , String .format ("destroyImpl, functor %x, viewroot == null %b, isHWAccel %b" ,
5307- drawGLFunction , (viewRoot == null ),
5308- mWebView .isHardwareAccelerated ()));
53095313 if (mWebView .isHardwareAccelerated ()) {
5314+ int drawGLFunction = nativeGetDrawGLFunction (mNativeClass );
5315+ ViewRootImpl viewRoot = mWebView .getViewRootImpl ();
53105316 if (drawGLFunction != 0 && viewRoot != null ) {
53115317 viewRoot .detachFunctor (drawGLFunction );
53125318 }
0 commit comments