Fix crash regression when calling setSurface(null)

Test: HardwareRendererTests#testSetNullSurface
Fixes: 165335939
Change-Id: I8f93a0b6a115088af634e21e91b95b4f6a521f12
This commit is contained in:
John Reck
2020-08-18 12:37:43 -07:00
parent 408f136b47
commit e95c62d74a
2 changed files with 5 additions and 3 deletions

View File

@@ -184,7 +184,9 @@ static void android_view_ThreadedRenderer_setSurface(JNIEnv* env, jobject clazz,
proxy->setSwapBehavior(SwapBehavior::kSwap_discardBuffer);
}
proxy->setSurface(window, enableTimeout);
ANativeWindow_release(window);
if (window) {
ANativeWindow_release(window);
}
}
static jboolean android_view_ThreadedRenderer_pause(JNIEnv* env, jobject clazz,

View File

@@ -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); }
});
}