Hash :
1328f2f3
Author :
Date :
2023-04-17T16:43:12
Vulkan: Destroy the surface without holding the EGL lock This change defers surface destruction to the end of the entry point that causes it so that it is done without holding the EGL lock. This works around a specific deadlock in Android. On this platform: - For EGL applications, parts of surface creation and destruction are handled by the platform, and parts of it are done by the native EGL driver. Namely, on surface destruction, native_window_api_disconnect is called outside the EGL driver. - For Vulkan applications, vkDestroySurfaceKHR takes full responsibility for destroying the surface, including calling native_window_api_disconnect. Unfortunately, native_window_api_disconnect may use EGL sync objects and can lead to calling into the EGL driver. For ANGLE, this is particularly problematic because it is simultaneously a Vulkan application and the EGL driver, causing `vkDestroySurfaceKHR` to call back into ANGLE and attempt to reacquire the EGL lock. Since there are no users of the surface when calling vkDestroySurfaceKHR, it is safe for ANGLE to destroy it without holding the EGL lock. Note that only eglDestroySurface and eglMakeCurrent may lead to the destruction of a window surface. Bug: b/275176234 Bug: angleproject:8127 Change-Id: I02dc52e53e150943457e3f503e7ef30469f96b05 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4428754 Reviewed-by: Charlie Lao <cclao@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
//
// Copyright 2023 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// UnlockedTailCall_unittest.cpp: Unit tests of the UnlockedTailCall class.
#include <gtest/gtest.h>
#include "libANGLE/angletypes.h"
namespace angle
{
void SetUpTailCall(UnlockedTailCall *unlockedTailCall, int *result)
{
unlockedTailCall->add([result]() { ++*result; });
}
// Test basic functionality
TEST(UnlockedTailCall, Basic)
{
int a = 10;
int b = 500;
UnlockedTailCall unlockedTailCall;
ASSERT_FALSE(unlockedTailCall.any());
SetUpTailCall(&unlockedTailCall, &a);
ASSERT_TRUE(unlockedTailCall.any());
SetUpTailCall(&unlockedTailCall, &b);
ASSERT_TRUE(unlockedTailCall.any());
unlockedTailCall.run();
ASSERT_EQ(a, 11);
ASSERT_EQ(b, 501);
}
} // namespace angle