android: recreate Vulkan surface after app resume#19216
Conversation
There was a problem hiding this comment.
You should probably change the parts of these comments that say "Currently only for OpenGL" now that these fields are used for Android Vulkan as well:
Lines 587 to 595 in 9877cfd
Also change this comment to mention Vulkan as well, if applicable:
RetroArch/input/drivers/android_input.c
Lines 1885 to 1895 in 9877cfd
|
Also, did you make sure this works for cores that actually use Vulkan for hardware-accelerated rendering via the |
Wait for an Android window before scheduling Vulkan surface recreation, and drain threaded video before destroying a surface. Surface destruction runs outside the Android mutex so the video worker can finish safely. Reset the current swapchain image index when replacing a swapchain so an index from a larger old swapchain cannot survive into a smaller new one.
|
@white-axe Great callouts. I updated the comments to describe surface-only recreation rather than marking them as OpenGL-only. I also tested this with a Vulkan hardware-rendered core, Dolphin. The logs confirm For completeness, RetroArch disables threaded video for Vulkan hardware-render cores, so I tested both relevant paths:
All passed repeated resume testing. Also this actually led to a more robust fix here. I updated the PR description. @hizzlekizzle @LibretroAdmin This should be good to go. |
white-axe
left a comment
There was a problem hiding this comment.
Looks good to me! I tried it with PPSSPP with its Vulkan renderer selected as well and it works nicely.
|
This looks great. Thanks for the testing and iteration! We have another guy who's been focused on getting the Play Store version updated, and that's been taking most of his time, we're hoping he can get eyes on this soon. |
Problem
On Android, RetroArch could resume Vulkan rendering after the Android window lifecycle had invalidated the presentation surface or swapchain.
Android may retain the same
ANativeWindowwhile the app is backgrounded, so waiting only for a later window teardown could leave Vulkan presentation resources alive too long. This could stall the presentation queue or lead to a resume crash or freeze. User may notice a black flash before game resumes.Fix
Handle Android Vulkan surface loss independently of the Vulkan device:
VkSurfaceKHRwhen the app stops.If surface recreation fails, the existing full-context recovery path remains available.
Validation
Tested on Android with Vulkan:
No resume crash or permanent presentation stall was observed in the tested paths. Eliminates black flash before game resumes after backgrounding.