Skip to content

Commit

Permalink
[Issue flutter#9357] Fix crash in software fallback path (flutter#3591)
Browse files Browse the repository at this point in the history
Keep the VulkanProcTable around long enough to use it from the destructor of the VulkanApplication
  • Loading branch information
freiling authored Apr 13, 2017
1 parent ee0e98c commit c24a0e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions content_handler/vulkan_rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@ void VulkanRasterizer::VulkanSurfaceProducer::OnHandleReady(
}

bool VulkanRasterizer::VulkanSurfaceProducer::Initialize() {
auto vk = ftl::MakeRefCounted<vulkan::VulkanProcTable>();
vk_ = ftl::MakeRefCounted<vulkan::VulkanProcTable>();

std::vector<std::string> extensions = {VK_KHR_SURFACE_EXTENSION_NAME};
application_ = std::make_unique<vulkan::VulkanApplication>(
*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.";
Expand All @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions content_handler/vulkan_rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class VulkanRasterizer : public Rasterizer {
static_cast<uint64_t>(height);
}

ftl::RefPtr<vulkan::VulkanProcTable> vk_;

// These three containers hold surfaces in various stages of recycling

// Buffers exist in available_surfaces_ when they are ready to be recycled
Expand Down

0 comments on commit c24a0e5

Please sign in to comment.