Fixes a lua state null return related to the print wrapper, improves the lua editor ui formatting, and implements a stopgap lua lag fix (#68816)

This PR fixes this issue by making sure every proc called in the stack of /proc/wrap_lua_print which could sleep is called using INVOKE_ASYNC, and to prevent such problems in the future, marks all the wrappers as SHOULD_NOT_SLEEP(TRUE). I also figured out how to fix the dumb overflowing problem of the lua editor ui.

Due to lag concerns regarding lua states with a large number of global variables (including fields within global tables), I have made it so the global table and state log are hidden by default - they can be shown using a toggle button in the editor ui.
This commit is contained in:
Y0SH1M4S73R
2022-07-31 03:09:01 -04:00
committed by GitHub
parent 18ce9e2460
commit e72ec7445a
6 changed files with 90 additions and 45 deletions
+15 -4
View File
@@ -58,6 +58,7 @@ GLOBAL_PROTECT(lua_usr)
break
if(append_to_log)
log += list(weakrefify_list(result))
INVOKE_ASYNC(src, .proc/update_editors)
/datum/lua_state/proc/load_script(script)
GLOB.IsLuaCall = TRUE
@@ -68,6 +69,8 @@ GLOBAL_PROTECT(lua_usr)
GLOB.lua_usr = tmp_usr
// Internal errors unrelated to the code being executed are returned as text rather than lists
if(isnull(result))
result = list("status" = "errored", "param" = "__lua_load returned null (it may have runtimed - check the runtime logs)", "name" = "input")
if(istext(result))
result = list("status" = "errored", "param" = result, "name" = "input")
result["chunk"] = script
@@ -90,13 +93,11 @@ GLOBAL_PROTECT(lua_usr)
GLOB.IsLuaCall = FALSE
GLOB.lua_usr = tmp_usr
if(isnull(result))
result = list("status" = "errored", "param" = "__lua_call returned null (it may have runtimed - check the runtime logs)", "name" = "input")
if(istext(result))
result = list("status" = "errored", "param" = result, "name" = islist(function) ? jointext(function, ".") : function)
check_if_slept(result)
var/list/editor_list = LAZYACCESS(SSlua.editors, "\ref[src]")
if(editor_list)
for(var/datum/lua_editor/editor in editor_list)
SStgui.update_uis(editor)
return result
/datum/lua_state/proc/call_function_return_first(function, ...)
@@ -111,6 +112,8 @@ GLOBAL_PROTECT(lua_usr)
var/result = __lua_awaken(internal_id)
GLOB.IsLuaCall = FALSE
if(isnull(result))
result = list("status" = "errored", "param" = "__lua_awaken returned null (it may have runtimed - check the runtime logs)", "name" = "input")
if(istext(result))
result = list("status" = "errored", "param" = result, "name" = "An attempted awaken")
check_if_slept(result)
@@ -126,6 +129,8 @@ GLOBAL_PROTECT(lua_usr)
var/result = __lua_resume(internal_id, index, call_args)
GLOB.IsLuaCall = FALSE
if(isnull(result))
result = list("status" = "errored", "param" = "__lua_resume returned null (it may have runtimed - check the runtime logs)", "name" = "input")
if(istext(result))
result = list("status" = "errored", "param" = result, "name" = "An attempted resume")
check_if_slept(result)
@@ -140,4 +145,10 @@ GLOBAL_PROTECT(lua_usr)
/datum/lua_state/proc/kill_task(task_info)
__lua_kill_task(internal_id, task_info)
/datum/lua_state/proc/update_editors()
var/list/editor_list = LAZYACCESS(SSlua.editors, "\ref[src]")
if(editor_list)
for(var/datum/lua_editor/editor as anything in editor_list)
SStgui.update_uis(editor)
#undef MAX_LOG_REPEAT_LOOKBACK