Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e080128 authored by Chris Craik's avatar Chris Craik
Browse files

Avoid crash if onDetachedFromWindow called after destroy

This also removes the temporary logging from commit
f8dafa14.

bug:6535911
Change-Id: Icf1d0438b349a0e92e7d9cefed57a252eed2b9b0
parent f8dafa14
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -2069,11 +2069,20 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc
    }

    private void destroyImpl() {
        int drawGLFunction = nativeGetDrawGLFunction(mNativeClass);
        ViewRootImpl viewRoot = mWebView.getViewRootImpl();
        Log.d(LOGTAG, String.format("destroyImpl, functor %x, viewroot == null %b, isHWAccel %b",
                                    drawGLFunction, (viewRoot == null),
                                    mWebView.isHardwareAccelerated()));
        if (viewRoot != null) {
            Log.e(LOGTAG, "Error: WebView.destroy() called while still attached!");
        }

        if (mWebView.isHardwareAccelerated()) {
            int drawGLFunction = nativeGetDrawGLFunction(mNativeClass);
            if (drawGLFunction != 0 && viewRoot != null) {
                // functor should have been detached in onDetachedFromWindow, do
                // additionally here for safety
                viewRoot.detachFunctor(drawGLFunction);
            }
        }

        mCallbackProxy.blockMessages();
        clearHelpers();
        if (mListBoxDialog != null) {
@@ -5301,12 +5310,9 @@ public final class WebViewClassic implements WebViewProvider, WebViewProvider.Sc

        updateHwAccelerated();

        if (mWebView.isHardwareAccelerated()) {
            int drawGLFunction = nativeGetDrawGLFunction(mNativeClass);
            ViewRootImpl viewRoot = mWebView.getViewRootImpl();
        Log.d(LOGTAG, String.format("destroyImpl, functor %x, viewroot == null %b, isHWAccel %b",
                                    drawGLFunction, (viewRoot == null),
                                    mWebView.isHardwareAccelerated()));
        if (mWebView.isHardwareAccelerated()) {
            if (drawGLFunction != 0 && viewRoot != null) {
                viewRoot.detachFunctor(drawGLFunction);
            }
+1 −2
Original line number Diff line number Diff line
@@ -250,7 +250,6 @@ void OpenGLRenderer::resume() {
}

void OpenGLRenderer::detachFunctor(Functor* functor) {
    ALOGD("opengl renderer %p detaching functor %p", this, functor);
    mFunctors.remove(functor);
}

@@ -303,7 +302,7 @@ status_t OpenGLRenderer::invokeFunctors(Rect& dirty) {

status_t OpenGLRenderer::callDrawGLFunction(Functor* functor, Rect& dirty) {
    interrupt();
    mFunctors.remove(functor);
    detachFunctor(functor);

    if (mDirtyClip) {
        setScissorFromClip();