mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-28 18:06:09 +02:00
Refactor session management and resource cleanup
- Replaced `teardownMountedSession` and `flushEditorPackageLoaded` with a unified `SessionLifecycle` approach for managing session transitions and resource cleanup. - Implemented `SessionLifecycle.endEditorSession` and `SessionLifecycle.endGameSession` to streamline the teardown process for editor and game sessions. - Introduced `Assets.releaseSession` to handle GPU resource release at session end, ensuring efficient memory management. - Updated `Game` and `Game2` reset methods to include world and canvas resource releases. - Enhanced `MapLoader` with a new `releaseAll` method for eager GPU cache cleanup. - Added tests to verify the new session lifecycle functionality and resource management. This commit improves the stability and performance of in-process transitions, particularly during editor and game session changes. further improves and addresses #1662 specifically around android gc pressure.
This commit is contained in:
@@ -182,11 +182,20 @@ check(checkSrc:match('cmd%.cmd == "quit"%s*then%s*\n%s*break') ~= nil,
|
||||
local mainSrc = source("main.lua")
|
||||
local quitHook = mainSrc:match("\nfunction love%.quit%(%).-\nend\n")
|
||||
check(quitHook ~= nil, "love.quit is still a single top-level function")
|
||||
quitHook = quitHook or ""
|
||||
check(quitHook:find('package.loaded["src.core.ChipAudio"].shutdown', 1, true) ~= nil,
|
||||
"love.quit shuts the chip worker down")
|
||||
check(quitHook:find('package.loaded["src.update.Check"].shutdown', 1, true) ~= nil,
|
||||
"love.quit shuts the update worker down")
|
||||
check(mainSrc:find("SessionLifecycle.endProcess()", 1, true) ~= nil,
|
||||
"love.quit shuts workers down via SessionLifecycle.endProcess")
|
||||
|
||||
local lifecycleSrc = source("src/core/SessionLifecycle.lua")
|
||||
check(lifecycleSrc:find("registerProcessShutdown", 1, true) ~= nil,
|
||||
"SessionLifecycle exposes registerProcessShutdown")
|
||||
check(lifecycleSrc:find("function SessionLifecycle.endProcess()", 1, true) ~= nil,
|
||||
"SessionLifecycle.endProcess fans out registered hooks")
|
||||
check(source("src/core/ChipAudio.lua"):find("registerProcessShutdown(ChipAudio.shutdown)", 1, true) ~= nil,
|
||||
"ChipAudio registers its shutdown hook at load")
|
||||
check(source("src/update/Check.lua"):find("registerProcessShutdown(Check.shutdown)", 1, true) ~= nil,
|
||||
"Check registers its shutdown hook at load")
|
||||
check(source("src/net/Fetch.lua"):find("registerProcessShutdown(Fetch.shutdown)", 1, true) ~= nil,
|
||||
"Fetch registers its shutdown hook at load")
|
||||
|
||||
-- The Android half: LOVE keeps the JVM process after the native main returns,
|
||||
-- so the quit event exits the process outright. It has to sit after the
|
||||
|
||||
Reference in New Issue
Block a user