From bfb7199b594c705116571744c1504f29d5cfebef Mon Sep 17 00:00:00 2001 From: Ian Elliott Date: Wed, 24 Nov 2021 16:32:41 -0700 Subject: Vulkan: Work-around Android start-up race condition Work-around a race condition during Android start-up, while the `service.sf.present_timestamp` property is asynchronously working its way from HWC to other processes (especially render engine). This can cause the two successive calls to EnumerateDeviceExtensionProperties to have different numbers of extensions. That causes the second call to return VK_INCOMPLETE, which can cause vkCreateDevice() to fail. The work-around is to add 1 to the "count" returned by the first call. Test: Manual test with additional logging Bug: b/206733351 Change-Id: I7b29998d670196d2af772f19be30b2e9498acfe0 --- vulkan/libvulkan/api.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'vulkan/libvulkan/api.cpp') diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp index d1cd397da4..fa3b2601a4 100644 --- a/vulkan/libvulkan/api.cpp +++ b/vulkan/libvulkan/api.cpp @@ -965,6 +965,13 @@ VkResult LayerChain::ValidateExtensions(VkPhysicalDevice physical_dev, VkResult result = EnumerateDeviceExtensionProperties(physical_dev, nullptr, &count, nullptr); if (result == VK_SUCCESS && count) { + // Work-around a race condition during Android start-up, that can result + // in the second call to EnumerateDeviceExtensionProperties having + // another extension. That causes the second call to return + // VK_INCOMPLETE. A work-around is to add 1 to "count" and ask for one + // more extension property. See: http://anglebug.com/6715 and + // internal-to-Google b/206733351. + count++; driver_extensions_ = AllocateDriverExtensionArray(count); result = (driver_extensions_) ? EnumerateDeviceExtensionProperties( -- cgit v1.2.3-59-g8ed1b