Skip to content

libretro: don't rebuild the video driver for an unchanged mode - #160

Merged
LibretroAdmin merged 1 commit into
libretro:libretroizationfrom
WizzardSK:av-info-guard
Aug 28, 2026
Merged

libretro: don't rebuild the video driver for an unchanged mode#160
LibretroAdmin merged 1 commit into
libretro:libretroizationfrom
WizzardSK:av-info-guard

Conversation

@WizzardSK

Copy link
Copy Markdown
Contributor

Fixes the most likely cause of #159.

The reporter there ran the triage that would have implicated the recompilers — MTVU off, VU1 softfloat on, EE interpreter — and it still crashed, which pointed away from CPU emulation. Their log ends immediately after this:

SET_SYSTEM_AV_INFO: 640x448, Aspect: 1.3333, FPS: 59.9401, Sample rate: 48000
... video and audio drivers reinitialised ...
SET_SYSTEM_AV_INFO: 640x448, Aspect: 1.3333, FPS: 59.9401, Sample rate: 48000
... video and audio drivers reinitialised again ...

Two announcements carrying identical values, each making the frontend tear down and rebuild its entire video driver — on the HW-render path, context_destroy and a fresh negotiation.

update_av_info() sent the announcement unconditionally whenever pending_update_av_info was set: no comparison against what had last gone out, and no regard for what the GS thread was doing, so the rebuild could land on a thread still submitting to the shared Vulkan queue.

Both guards are the ones PCEE2 already carries for the same defect (adf456e28d):

  • Announce only on a real timing change. The fps compare needs a tolerance — NTSC reports 59.94005994 Hz against a 59.94 default, and that 0.00006 Hz difference must not rebuild anything. Geometry needs no announcement on the HW-render path: SET_GEOMETRY carries it without a reinit, which is already how the widescreen hint does it, so it is forwarded that way instead.
  • Drain the GS thread before an announcement that does go out, so queued work does not race the reinit. The CPU thread is already parked here — retro_run has not resumed it yet.

Software rendering keeps the old behaviour for a geometry change, matching PCEE2 rather than widening the change.

What this is not

A confirmed fix. Nothing in that log says what the crash was: the core has no crash reporter yet (#158), and the reporter cannot get logcat without root. What the log does show is the frontend rebuilding its video driver for no reason at the moment everything stopped, and that is a defect whether or not it is the one.

Compiles clean; I have no Android device to run it on.

libretro#159 reports God of War crashing shortly after boot on Android.
The reporter ran the triage that would have implicated the recompilers -
MTVU off, VU1 softfloat on, EE interpreter - and it still crashed, which is
what pointed away from CPU emulation entirely. Their log ends immediately
after this:

  SET_SYSTEM_AV_INFO: 640x448, Aspect: 1.3333, FPS: 59.9401, Sample rate: 48000
  ... video and audio drivers reinitialised ...
  SET_SYSTEM_AV_INFO: 640x448, Aspect: 1.3333, FPS: 59.9401, Sample rate: 48000
  ... video and audio drivers reinitialised again ...

Two announcements carrying identical values, each making the frontend tear
down and rebuild its whole video driver, which on the HW-render path means
context_destroy and a fresh negotiation.

update_av_info() sent the announcement unconditionally whenever
pending_update_av_info was set, without comparing against what had last gone
out, and without regard for what the GS thread was doing - so the rebuild
could land on top of a thread still submitting to the shared Vulkan queue.

Both guards are the ones pcee2 already carries for the same defect
(adf456e28d):

  - Announce only on a real timing change. The fps compare needs a
    tolerance, since NTSC reports 59.94005994 Hz against a 59.94 default and
    that 0.00006 Hz difference must not rebuild anything. Geometry needs no
    announcement on the HW-render path: SET_GEOMETRY carries it without a
    reinit, which is already how the widescreen hint does it, so it is
    forwarded that way instead.
  - Drain the GS thread before an announcement that does go out. The CPU
    thread is already parked at this point - retro_run has not resumed it.

Software rendering keeps the old behaviour for a geometry change, matching
pcee2 rather than widening the change.

This is a hypothesis the log supports rather than a confirmed fix: nothing
in that log says what the crash was, because the core has no crash reporter
yet (libretro#158), and the reporter cannot get logcat without root. What can be
said is that the frontend was rebuilding its video driver for no reason at
the moment everything stopped, and that this is a defect either way.
@LibretroAdmin
LibretroAdmin merged commit cd9e7c4 into libretro:libretroization Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants