mirror of
https://github.com/ARMSX2/ARMSX2.git
synced 2026-08-24 16:50:16 -07:00
A saver that dies natively made ARMSX2 unlaunchable. The choice is a persisted pref read on the library screen -- the first screen -- so the crash repeated on every launch and Settings was never reachable to turn it off. The only escape was clearing app data, which takes memory cards and save states with it. A user lost their saves that way. Cause: gl1's state is a file-scope global holding GL object names, and gl1_init() early-returns on g.ready. Skyrocket and Lattice defer initSaver() to port_resize, so a create-then-teardown with no surface size left g_started false and their port_free returned BEFORE gl1_shutdown(); flux, plasma and solarwinds leaked it the same way when initSaver() left readyToDraw clear, since returning 0 means port_free is never called. Either way g.ready stayed set with names from a destroyed EGL context, and the next saver -- new view, new context -- drew against them. Drivers answer that with anything from a black screen to a segfault. Each port now gives gl1 back on every path out, and nativeInit calls gl1_lost() as the invariant: a new context never inherits old GL names. Contained separately, because native GL can always find a new way to die: the setting arms itself with a synchronous commit() before the render thread starts and disarms when that thread exits in an orderly way. Still armed at startup means the last run died with a saver up, so the background switches off and the user is told which one. runCatching was never going to catch a SIGSEGV. Also guards Thread.start(): it asks for a 16MB stack (Skyrocket declares a 3MB starmap as a local) and an OutOfMemoryError there is an uncaught throw on the main thread -- the same lockout with no native crash involved.