Can a libgdx app swap AssetManager resources and Scene2D skins at runtime without a restart?
0 reputation · 15 Jun 2023, 08:32 UTC
I am planning a zero-downtime upgrade path for a small libgdx desktop application (currently on 1.11.x, considering 1.12.x). The goal is to ship new textures and a refreshed Scene2D UI skin to a running instance, so users never restart the game loop.
My understanding is that AssetManager supports asynchronous loading and reference-counted unloading, and that a Scene2D Skin can be reloaded while the stage keeps rendering. What is unclear to me is how to sequence the swap safely: when do old assets get disposed if actors still hold TextureRegion references from the previous atlas, and does Skin reload propagate to existing widgets or only to newly created ones?
There is also a threading concern: asset finishLoading callbacks and any UI rebuild would need to happen on the render thread, and I am unsure which parts of the API guarantee that.
Specifically:
- What is the correct ordering for loading the new atlas, re-skinning the stage, and disposing the old assets without a frame of missing textures?
- Do existing Scene2D actors pick up a reloaded Skin automatically, or must every widget be rebuilt?
- Are there AssetManager API differences between 1.11.x and 1.12.x that change this workflow?