Merge "Fix crash regression when calling setSurface(null)"

This commit is contained in:
John Reck
2020-08-18 21:50:00 +00:00
committed by Android (Google) Code Review
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); }
});
}