You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix Vulkan surface teardown loop causing 9-screen tiling and bad FPS on Android
The DecorView.Post lambda was calling holder.SetFormat(Rgba8888) unconditionally
every startup, even when the surface was already born with the correct format via
Window.SetFormat(Rgba8888) before base.OnCreate(). On Samsung/Qualcomm devices,
any SurfaceHolder.setFormat() call — even a no-op — triggers SurfaceDestroyed+
SurfaceCreated. During the draw-thread stall Veldrid called
vkGetPhysicalDeviceSurfaceCapabilitiesKHR on a mid-transition ANativeWindow that
reported dp-scaled dimensions (1029x480) instead of physical pixels (3088x1440),
permanently baking a 1/9-scale swapchain: 9-screen tiling, blurry text, animated
UI flashes, and bad FPS throughout the session.
Additionally, AddCallback(this) was called AFTER SetFormat, so the synchronous
SurfaceChanged fired with the pre-change format, triggering the reactive RGB565
guard to call SetFormat a second time — chaining two back-to-back teardowns.
Fix:
- Move holder.AddCallback(this) BEFORE the SetFormat decision so SurfaceChanged
fires synchronously and populates lastSurfaceFormat first
- Add lastSurfaceFormat (volatile int): tracks format from last SurfaceChanged
- Add setFormatPending (volatile bool): debounce flag preventing chained SetFormats
- SurfaceCreated: reset both flags for new surface lifecycle
- SurfaceChanged: record lastSurfaceFormat; gate RGB565 guard on !setFormatPending
- DecorView.Post: only call SetFormat when lastSurfaceFormat is non-zero and
non-Rgba8888 and !setFormatPending — skipping the no-op call entirely when
Window.SetFormat already gave us the correct surface format
Normal path (Window.SetFormat worked): zero teardowns, correct swapchain from frame 1
Fallback path (surface born RGB565): one teardown via reactive guard, no chaining
Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/5c98b728-804c-45e7-b271-05e8ea071ff3
Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
0 commit comments