From 6913c856a25c069c858c7354a5d1e16a4bc50799 Mon Sep 17 00:00:00 2001 From: Inkeliz Date: Mon, 27 Dec 2021 19:53:48 +0000 Subject: [PATCH] app: [android] fix vulkan crash when activity/surface is recreated On Android it's possible that the Activity/View must be restore. But, before that patch, an new VkSurfaceKHR is created but never used and that may lead to crash, in an attempt to destroy/use one invalid surface. Fixes: https://todo.sr.ht/~eliasnaur/gio/327 Signed-off-by: Inkeliz --- app/vulkan_android.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/vulkan_android.go b/app/vulkan_android.go index cdfbd958..3758d048 100644 --- a/app/vulkan_android.go +++ b/app/vulkan_android.go @@ -79,10 +79,12 @@ func (c *wlVkContext) Refresh() error { if c.surf != 0 { c.ctx.destroySwapchain() vk.DestroySurface(c.inst, c.surf) + c.surf = 0 } surf, err := vk.CreateAndroidSurface(c.inst, unsafe.Pointer(win)) if err != nil { return err } - return c.ctx.refresh(surf, w, h) + c.surf = surf + return c.ctx.refresh(c.surf, w, h) }