Avoid trying to disconnect twice with ANGLE
The Vulkan runtime makes all the native_window_* calls
when running with ANGLE.
Noticed while debugging b/184280023.
Bug: b/154237217
Test: MixedDeviceOwnerTest on Cuttlefish w/ SwANGLE
Change-Id: Ie7c5ebcedf6eb0c23fdd1223c0ef866d4a2d9944
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index 847b351..efbe613 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -82,9 +82,13 @@
void egl_surface_t::disconnect() {
if (win != nullptr && connected) {
- native_window_set_buffers_format(win, 0);
- if (native_window_api_disconnect(win, NATIVE_WINDOW_API_EGL)) {
- ALOGW("EGLNativeWindowType %p disconnect failed", win);
+ // NOTE: When using Vulkan backend, the Vulkan runtime makes all the
+ // native_window_* calls, so don't do them here.
+ if (!cnx->useAngle) {
+ native_window_set_buffers_format(win, 0);
+ if (native_window_api_disconnect(win, NATIVE_WINDOW_API_EGL)) {
+ ALOGW("EGLNativeWindowType %p disconnect failed", win);
+ }
}
connected = false;
}