[Oxyd] desync/crash with mod gui and Enter to leave vehicle

This subforum contains all the issues which we already resolved.
Post Reply
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

[Oxyd] desync/crash with mod gui and Enter to leave vehicle

Post by Choumiko »

It seems like using Enter to leave a vehicle can cause issues when that vehicle has a mod gui and a gui element (checkbox in that case) was used before. Causing (my guess) Factorio trying to toggle that element when it has already been destroyed and leading to a desync/crash. The user that reported the error couldn't reproduce it in SP.

The relevant parts of the mod:

Code: Select all

  local function onTick(event)
    if global.destroyNextTick[event.tick] then
      local pis = global.destroyNextTick[event.tick]
      for _, pi in pairs(pis) do
        GUI.destroyGui(game.players[pi])
      end
      global.destroyNextTick[event.tick] = nil
    end
    for i, farl in pairs(global.farl) do
      farl:update(event)
      if farl.driver and farl.driver.name ~= "farl_player" then
        GUI.updateGui(farl)
      end
    end
  end
--snip
  function onPlayerDrivingChangedState(event)
    local player = game.players[event.player_index]
    if (player.vehicle ~= nil and player.vehicle.name == "farl") then
      if player.gui.left.farl == nil then
        FARL.onPlayerEnter(player)
        GUI.createGui(player)
      end
    end
    if player.vehicle == nil and player.gui.left.farl ~= nil then
      FARL.onPlayerLeave(player)
      local tick = event.tick + 1
      if not global.destroyNextTick[tick] then
        global.destroyNextTick[tick] = {}
      end
      table.insert(global.destroyNextTick[tick], event.player_index) 
    end
  end
--snip
  game.on_event(defines.events.on_tick, onTick)
  game.on_event(defines.events.on_player_driving_changed_state, onPlayerDrivingChangedState)
It simply destroys the mod gui for the vehicle 1 tick after the player exited it. The crash also happened when GUI.destroy was called in the same tick.
mod: https://github.com/Choumiko/FARL/releas ... _0.3.3.zip
Error log attached
Attachments
log.txt
(8.87 KiB) Downloaded 180 times

ralle030583
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu Jan 29, 2015 11:32 am
Contact:

Re: [0.12.3]desync/crash with mod gui and Enter to leave vehicle

Post by ralle030583 »

another workaround is to just click outside the gui to "unbind" the enter key from the checkbox before exiting the vehicle,
crash only happens when the last click was inside the gui

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: [Oxyd] desync/crash with mod gui and Enter to leave vehicle

Post by Oxyd »

Yep. Pressing enter would simultaneously generate the “leave vehicle” and “checkbox toggled” input actions. The leave vehicle one would be processed before the checkbox toggle one and Factorio would then crash.

We talked with kovarex about it and agreed that there can be other situations where an input action for a GUI element is processed after that GUI is destroyed. So these input actions will now be ignored if the GUI doesn't exist anymore.

Thus: Fixed in 0.12.7.

Post Reply

Return to “Resolved Problems and Bugs”