From c24a0e51750570f271f860bbffbe082aab4ea72f Mon Sep 17 00:00:00 2001 From: freiling Date: Thu, 13 Apr 2017 16:50:21 -0700 Subject: [PATCH] [Issue #9357] Fix crash in software fallback path (#3591) Keep the VulkanProcTable around long enough to use it from the destructor of the VulkanApplication --- content_handler/vulkan_rasterizer.cc | 14 +++++++------- content_handler/vulkan_rasterizer.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/content_handler/vulkan_rasterizer.cc b/content_handler/vulkan_rasterizer.cc index 5f3aa1c9e39..fb5a7e1a9ef 100644 --- a/content_handler/vulkan_rasterizer.cc +++ b/content_handler/vulkan_rasterizer.cc @@ -302,13 +302,13 @@ void VulkanRasterizer::VulkanSurfaceProducer::OnHandleReady( } bool VulkanRasterizer::VulkanSurfaceProducer::Initialize() { - auto vk = ftl::MakeRefCounted(); + vk_ = ftl::MakeRefCounted(); std::vector extensions = {VK_KHR_SURFACE_EXTENSION_NAME}; application_ = std::make_unique( - *vk, "Flutter", std::move(extensions)); + *vk_, "Flutter", std::move(extensions)); - if (!application_->IsValid() || !vk->AreInstanceProcsSetup()) { + if (!application_->IsValid() || !vk_->AreInstanceProcsSetup()) { // Make certain the application instance was created and it setup the // instance proc table entries. FTL_LOG(ERROR) << "Instance proc addresses have not been setup."; @@ -320,24 +320,24 @@ bool VulkanRasterizer::VulkanSurfaceProducer::Initialize() { logical_device_ = application_->AcquireFirstCompatibleLogicalDevice(); if (logical_device_ == nullptr || !logical_device_->IsValid() || - !vk->AreDeviceProcsSetup()) { + !vk_->AreDeviceProcsSetup()) { // Make certain the device was created and it setup the device proc table // entries. FTL_LOG(ERROR) << "Device proc addresses have not been setup."; return false; } - if (!vk->HasAcquiredMandatoryProcAddresses()) { + if (!vk_->HasAcquiredMandatoryProcAddresses()) { FTL_LOG(ERROR) << "Failed to acquire mandatory proc addresses"; return false; } - if (!vk->IsValid()) { + if (!vk_->IsValid()) { FTL_LOG(ERROR) << "VulkanProcTable invalid"; return false; } - auto interface = vk->CreateSkiaInterface(); + auto interface = vk_->CreateSkiaInterface(); if (interface == nullptr || !interface->validate(0)) { FTL_LOG(ERROR) << "interface invalid"; diff --git a/content_handler/vulkan_rasterizer.h b/content_handler/vulkan_rasterizer.h index 4f16adeffa9..3981b3c5ed7 100644 --- a/content_handler/vulkan_rasterizer.h +++ b/content_handler/vulkan_rasterizer.h @@ -96,6 +96,8 @@ class VulkanRasterizer : public Rasterizer { static_cast(height); } + ftl::RefPtr vk_; + // These three containers hold surfaces in various stages of recycling // Buffers exist in available_surfaces_ when they are ready to be recycled