raiguard / TaskList

A simple and unobtrusive todo list for Factorio.
https://mods.factorio.com/mod/TaskList
MIT License
12 stars 9 forks source link

"Error while running event TaskList::on_gui_checked_state_changed (ID 3)" in multiplayer #41

Closed martinvonwittich closed 1 year ago

martinvonwittich commented 1 year ago

Description

I'm playing in multiplayer with a friend (I was hosting, and he had joined my game), and we had a strange TaskList issue today concerning the entry "[Mall] Big Electric Miner" in our task list:

1979.050 Error MainLoop.cpp:1382: Exception at tick 42243974: The mod Task List (0.4.6) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event TaskList::on_gui_checked_state_changed (ID 3)
Gui element with name 69 already present in the parent element.
stack traceback:
    [C]: in function 'add'
    __flib__/gui.lua:85: in function 'recursive_build'
    __flib__/gui.lua:163: in function 'add'
    __TaskList__/scripts/gui/tasks/index.lua:134: in function 'add_task'
    __TaskList__/scripts/task.lua:61: in function 'callback'
    __TaskList__/scripts/task.lua:104: in function 'update_guis'
    __TaskList__/scripts/task.lua:59: in function 'toggle_completed'
    __TaskList__/scripts/gui/tasks/actions.lua:79: in function 'handler'
    __TaskList__/scripts/gui/tasks/index.lua:95: in function 'dispatch'
    __TaskList__/control.lua:109: in function <__TaskList__/control.lua:104>

Now in single player, I'm unfortunately unable to crash the game in this way, but the task is still peculiar, maybe this can help figuring out the issue?

The save game: https://clip.iserv.eu/t/ELI3Wj9NiWgakVPiiD4EDdizWjaqVuWn9h3fDi9R2lM/tasklist%20bug.zip (beware, the link is only valid for 30 days)

factorio-previous.log

Reproduction

I cannot reproduce the crash on my own, but in theory, it might be reproducible in a multiplayer game as follows:

  1. Host a multiplayer game with the save.
  2. Have another player join the game.
  3. Have the other player attempt to mark "[Mall] Big Electric Miner" as (un)completed.
  4. This has crashed the game for us.

Without multiplayer, at least the peculiar behavior of the task is reproducible:

  1. Load the save.
  2. Attempt to edit the task "[Mall] Big Electric Miner".
  3. Note how the task isn't really editable - it's in the list, but attempt to edit it gives the "new task" UI. Marking the task as uncompleted won't actually move it to the top to the other uncompleted tasks.
martinvonwittich commented 1 year ago

Up to a minute ago I believed that this might be some kind of a strange desync bug - as if the task list on his side had a different state from the task list on my side. I assumed that my game had a task list in a consistent state (where the entry was marked as completed and still fine), and that he had a corrupted task list (where the entry wasn't marked as completed). I thought the crash occurred when he attempted to mark the entry as completed because then this conflict might trigger the crash.

To verify my assumption, I located my last save game right before the crash, and attempted to mark the entry as uncompleted. Turns out, my task list is apparently not in a consistent state, because the attempt crashed my game immediately, even in singleplayer :)

I've uploaded this savegame too: https://clip.iserv.eu/t/OiMld8oXVLy0dqz24jGgSzp7TfrNB4fPmsN6l-Di7fA/tasklist%20bug%20reproducible.zip

The issue is reproducible with this save game like follows:

  1. Load the save game.
  2. Open the task list.
  3. Show completed tasks.
  4. Attempt to uncheck "[Mall] Big Electric Miner" -> crash
raiguard commented 1 year ago

Unfortunately, I am unable to reproduce the crash. This is the second issue to come up with regard to the GUI becoming desynced from the task state, and unfortunately, without a reproduction to get it into that state, there isn't much I can do to fix it.

This mod is a dumpster fire code-wise and I have little motivation to rewrite it.

Edit: I managed to reproduce it!

raiguard commented 1 year ago

I am no closer to figuring out how the issue occurs in the first place, but I have applied a band-aid that should prevent this crash in the future.