From 427d8ebf308c5461528ce2a999190f1eab91c2c8 Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Mon, 28 Sep 2020 15:04:18 -0400 Subject: [PATCH] Fix offscreen drawing when cleaning up vulkan viewer. When using offscreen draws, we save the "previous" frame in fLastImage in viewer. However this image holds a ref to the GrContext. When we were destroying the vulkan context we thought we were destroying the GrContext before the VkDevice but fLastImage was keeping it alive. This changes makes sure to reset fLastImage when we are done with it. Change-Id: Ib70e069a261f939217436a9f052d7565581cd230 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320263 Reviewed-by: Brian Osman Commit-Queue: Brian Osman Commit-Queue: Greg Daniel Auto-Submit: Greg Daniel --- tools/sk_app/VulkanWindowContext.cpp | 1 + tools/viewer/Viewer.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp index 764f19fec9..a3247275d5 100644 --- a/tools/sk_app/VulkanWindowContext.cpp +++ b/tools/sk_app/VulkanWindowContext.cpp @@ -433,6 +433,7 @@ void VulkanWindowContext::destroyContext() { } } + SkASSERT(fContext->unique()); fContext.reset(); fInterface.reset(); diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index e550059e60..daafba4d2a 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -1530,6 +1530,8 @@ void Viewer::onPaint(SkSurface* surface) { this->drawImGui(); + fLastImage.reset(); + if (auto direct = fWindow->directContext()) { // Clean out cache items that haven't been used in more than 10 seconds. direct->performDeferredCleanup(std::chrono::seconds(10));