mirror of
https://github.com/ARMSX2/ARMSX3.git
synced 2026-08-24 16:58:52 -07:00
Opening a game the instant the app started left a black game area forever, while rotating the device "fixed" it. SurfaceHolder.Callback::surfaceChanged is a one-shot -- Android delivers it when the surface is created or resized and never repeats -- and getNativeWindow() blocks until that single delivery arrives, in a 100 ms sleep loop with no timeout. One missed delivery therefore parks the RSX thread for the rest of the session. A rotation only helped because a configuration change forces a fresh surfaceChanged. EmulationSurface now re-delivers holder.surface on attach and on window visibility changes. It is idempotent: the native side compares the incoming ANativeWindow against the one it holds and no-ops on a match, so this costs nothing when the first delivery already arrived. It has to be post()ed, since onAttachedToWindow runs before layout and a 0x0 report is explicitly ignored. The wait loop also logs now, every three seconds, because the failure was otherwise completely silent: the emulator log stopped dead just after Vulkan device creation, the perf sensor read 0.0% CPU, and nothing said why. Diagnosis took a screenshot and dumpsys SurfaceFlinger to establish the surface existed. Adds GSFrameBase::display_epoch, bumped when the native window is replaced. The swapchain is rebuilt on a size mismatch and nothing else, so a replacement window at identical dimensions was invisible; platforms that cannot swap a window under a live swapchain keep the default and are unaffected.