Have GrContext hold a strong ref to VulkanManager
VulkanManager is already ref counted and can be reused
across GrContext's thanks to being shared with
HardwareBitmapUploader.
So take advantage of this + the newly added skia API
for GrContext being destroyed to have GrContext hold a
strong ref to VulkanManager which in turn keeps the
VkDevice alive. If somehow we never recover from this
we'll just keep using the initial device when creating
the next Grcontext which should be fine. Memory usage
will be sub-optimal but that's better than crashing
probably.
Bug: 266626090
Test: unable to repro bug issue, so speculative fix + it didn't get
worse at least?
Change-Id: I2038dacea679c29fd098462d4cf9d298e1215fb2
diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h
index c5196ee..00a40c0 100644
--- a/libs/hwui/renderthread/VulkanManager.h
+++ b/libs/hwui/renderthread/VulkanManager.h
@@ -66,6 +66,7 @@
class VulkanManager final : public RefBase {
public:
static sp<VulkanManager> getInstance();
+ static sp<VulkanManager> peekInstance();
// Sets up the vulkan context that is shared amonst all clients of the VulkanManager. This must
// be call once before use of the VulkanManager. Multiple calls after the first will simiply
@@ -109,7 +110,7 @@
};
// returns a Skia graphic context used to draw content on the specified thread
- sk_sp<GrDirectContext> createContext(const GrContextOptions& options,
+ sk_sp<GrDirectContext> createContext(GrContextOptions& options,
ContextType contextType = ContextType::kRenderThread);
uint32_t getDriverVersion() const { return mDriverVersion; }