Delay rendering settings Lua UI until the user actually views that settings page
Related to #9221
All mods' settings pages are rendered immediately. This is inefficient and causes gameplay startup performance degradation for large settings pages. Primarily, because all of the widgets get their layout passes performed in that moment - which is very expensive. Scale this to hundreds of mods and we get delays in the 10 second to 60 second range for large settings pages.
In order to keep the API as unchanged as possible, I recommend the following:
- Update the code in
menu.luato something like this:
if (options.element) then
options.element.layout = layout
options.element:update()
else
options.layout = layout
end(This removes ui.create)
- Add something like
ensureScriptSettingsPage(index)to LuaUi on the C side
This has code like
if (!options["element"].is<std::shared_ptr<LuaUi::Element>>())
{
auto layout = options["layout"].as<sol::table>();
auto element = LuaUi::Element::make(layout, true, std::nullopt);
element->create();
options["element"] = element;
}This is a rough draft of thought and more change may be needed; but this idea prevents every settings page from being rendered before it's actually viewed by the user.
Edited by Cole Green