Implement session teardown and resource management for in-process transitions

- Introduced `teardownMountedSession` to handle cleanup of mounted versions, generated data, and mod states during transitions between the editor and launcher.
- Added `flushEditorPackageLoaded` to evict save-editor modules from `package.loaded` dynamically, ensuring a clean state for subsequent sessions.
- Implemented `Game:reset` and `Game2:reset` methods to clear session-specific fields, allowing for a fresh start when returning to the launcher.
- Enhanced `Renderer` and `TileRenderer` to release GPU resources immediately, preventing memory leaks during rapid transitions.
- Updated `MagnetTrainRide` to support OAM priority overlays and manage background rendering with new shader functionality.

This commit improves the stability and performance of the application during in-process transitions, particularly on Android.

fixes Yellow color palette for title screen

fixes #1662 #1643 #1536 and finishes fixing #1597
This commit is contained in:
1jamie
2026-08-22 17:08:14 -05:00
parent d54f9a02e0
commit 16eefcde68
16 changed files with 1090 additions and 215 deletions
+22 -8
View File
@@ -614,14 +614,18 @@ function CacheFs.mountVersion(version)
return true
end
-- Undo mountVersion. A process normally mounts exactly one version and then
-- boots it, but the launcher can open the save editor on one game's save,
-- close it, and press Play on another: with the first version's subtree
-- still prepended, the other's require("data.generated.*") and generated
-- art would silently resolve to the first game's files. Callers must also
-- drop the generated modules from package.loaded
-- (src.core.Data:unloadGenerated) -- unmounting alone only fixes the read
-- path, not what require already cached.
-- Undo mountVersion in LIFO order relative to mountVersion: generated-tree
-- overlays first (assets, then data -- reverse of mountGeneratedTrees), then
-- the version folder. PHYSFS resolves by stack order; peeling the wrong
-- layer first can leave another version's generated files winning a name.
--
-- A process normally mounts exactly one version and then boots it, but the
-- launcher can open the save editor on one game's save, close it, and press
-- Play on another: with the first version's subtree still prepended, the
-- other's require("data.generated.*") and generated art would silently
-- resolve to the first game's files. Callers must also drop the generated
-- modules from package.loaded (src.core.Data:unloadGenerated) -- unmounting
-- alone only fixes the read path, not what require already cached.
--
-- Returns true when nothing was mounted or the unmount took.
function CacheFs.unmountVersion(version)
@@ -633,6 +637,16 @@ function CacheFs.unmountVersion(version)
base = love.filesystem.getSaveDirectory()
end
local done = false
-- LIFO vs mountGeneratedTrees: assets/generated, then data/generated.
if love.filesystem and love.filesystem.unmount then
local generated = {
prefix .. "assets/generated",
prefix .. "data/generated",
}
for _, src in ipairs(generated) do
done = love.filesystem.unmount(src) or done
end
end
local fn = resolveUnmount()
if fn and base then
done = fn(base .. SEP .. sub) or done