Repository navigation
fix(android): Fall back to OpenGL ES when Vulkan initialization fails - #23941
Merged
ramezgerges merged 1 commit intoAug 3, 2026
Merged
Conversation
Vulkan feature flags are static device configuration and can be declared even when the driver cannot render (common on emulators). Probe for a usable device + GRContext before committing to the Vulkan view, and swap in the OpenGL ES view if render-thread initialization still fails, instead of leaving a permanently black SurfaceView. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23941/wasm-skia-net9/index.html |
Contributor
|
The build 225321 found UI Test snapshots differences: Details
|
Contributor
|
|
ajpinedam
approved these changes
Aug 1, 2026
ramezgerges
enabled auto-merge
August 3, 2026 17:10
MartinZikmund
added a commit
to ramezgerges/uno
that referenced
this pull request
Sep 21, 2026
Master's unoplatform#23941 split VulkanContext into InitializeDevice (instance + device, window-independent) and InitializeSurface (swapchain), and called InitializeDevice from the view constructor so a driver that advertises Vulkan but can't render throws synchronously, letting ApplicationActivity fall back to the GLES view. The branch never received this split - UnoVulkanView deferred all Vulkan work to the render thread, where a failure only got logged and could no longer reach the caller's try/catch. Ported the split onto the branch's neutral VulkanContext (GRContext stays out of it - that's the Skia backend's concern - so InitializeDevice only creates instance+device). UnoVulkanView now owns a persistent VulkanContext, initializes the device eagerly in its constructor, and hands it to AndroidVulkanGraphicsContext (which now completes/tears down only the window-scoped swapchain via InitializeSurface/DisposeSurfaceResources, instead of owning a whole VulkanContext of its own). Win32 and X11's Vulkan contexts are untouched - they keep constructing and owning their own VulkanContext via the combined Initialize path. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: closes #23940
PR Type:
🐞 Bugfix
What changed? 🚀
On Android with the Skia renderer, any Vulkan initialization failure left a permanent black screen: the only fallback to OpenGL ES was a
try/catcharound theUnoSKVulkanViewconstructor, but the constructor did no Vulkan work — actual initialization happened later on the render thread, where failures were logged and swallowed. TheHasSystemFeature(FEATURE_VULKAN_HARDWARE_LEVEL)gate doesn't help because emulator images declare Vulkan feature flags as static configuration even when the driver can't render (see #23940 for the three reproduced failure flavors, including a stock API-33 emulator with-gpu swiftshader_indirect).This PR makes the Vulkan/GL decision sequential and synchronous by splitting
VulkanContextinitialization into a window-independent and a window-scoped phase:VulkanContext.InitializeDevice(factory)creates the instance, device, and SkiaSharpGRContext, and throws when the driver is unusable. It is called directly in theUnoSKVulkanViewconstructor, so the existingtry/catchinApplicationActivity.CreateRenderView()becomes a real fallback site: all three failure flavors from Android Skia: black screen instead of OpenGL ES fallback when Vulkan initialization fails #23940 now surface there and the app falls back toUnoSKCanvasView(OpenGL ES).VulkanContext.InitializeSurface(window, width, height)creates the swapchain and intermediate render image on the render thread once the surface exists, reusing the device created by the constructor (previously the context was fully re-initialized).SurfaceDestroyednow disposes only the window-scoped resources (DisposeSurfaceResources), keeping the instance/device/GRContextalive across surface destroy/recreate cycles (e.g. backgrounding).The pre-existing
VulkanContext.Initialize(...)single-shot path used by the Win32/X11 hosts is unchanged.Runtime-validated on Android emulators (API 33 x86_64,
-gpu swiftshader_indirect, whereGRContextcreation fails on the SwiftShader guest device): before — black screen with a dead render thread; after — logcat showsVulkan rendering not available: Unable to create SkiaSharp GRContext from Vulkan device. Falling back to OpenGL ES.and SamplesApp renders and responds to input. The API-28 path (image declares no Vulkan features → existing feature-flag fallback) still behaves as before.Known limitation (by design, to keep the fallback decision synchronous): a failure in the window-scoped phase on the render thread (
vkCreateAndroidSurfaceKHR/swapchain creation) is logged but does not fall back; no such failure was observed across the tested configurations, which all fail during device/GRContextcreation.PR Checklist ✅
UseVulkanOnSkiaAndroiddocumented fallback behavior actually work.Screenshots Compare Test Runresults.🤖 Generated with Claude Code