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

Commit e95c62d7 authored by John Reck's avatar John Reck
Browse files

Fix crash regression when calling setSurface(null)

Test: HardwareRendererTests#testSetNullSurface
Fixes: 165335939
Change-Id: I8f93a0b6a115088af634e21e91b95b4f6a521f12
parent 408f136b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -184,8 +184,10 @@ static void android_view_ThreadedRenderer_setSurface(JNIEnv* env, jobject clazz,
        proxy->setSwapBehavior(SwapBehavior::kSwap_discardBuffer);
    }
    proxy->setSurface(window, enableTimeout);
    if (window) {
        ANativeWindow_release(window);
    }
}

static jboolean android_view_ThreadedRenderer_pause(JNIEnv* env, jobject clazz,
        jlong proxyPtr) {
+2 −2
Original line number Diff line number Diff line
@@ -77,10 +77,10 @@ void RenderProxy::setName(const char* name) {
}

void RenderProxy::setSurface(ANativeWindow* window, bool enableTimeout) {
    ANativeWindow_acquire(window);
    if (window) { ANativeWindow_acquire(window); }
    mRenderThread.queue().post([this, win = window, enableTimeout]() mutable {
        mContext->setSurface(win, enableTimeout);
        ANativeWindow_release(win);
        if (win) { ANativeWindow_release(win); }
    });
}