Skip to content

Make loader crafting GUI persistent to avoid multiplayer latency delay#1574

Merged
grilledham merged 1 commit into
Refactorio:developfrom
lex:loader-gui-latency
Jul 11, 2026
Merged

Make loader crafting GUI persistent to avoid multiplayer latency delay#1574
grilledham merged 1 commit into
Refactorio:developfrom
lex:loader-gui-latency

Conversation

@lex

@lex lex commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Backstory

Playing on a slow and unreliable internet connection, we noticed the loader panel next to the crafting menu took seconds to appear, shifting the crafting menu over whenever it finally loaded.

Root cause

The vanilla crafting menu is latency-hidden, so the client renders it immediately. The loader frame however was created inside on_gui_opened and destroyed in on_gui_closed — and script events only run once the open action has made the round trip through the server. On a bad connection that round trip is seconds, so the frame popped in late and re-laid-out the crafting menu when it arrived.

Fix

  • The controller-anchored frame is now created once per player (on create, join, force change and research finished) and left in place. Anchored relative frames show and hide with their target GUI, so it now appears in the same frame as the crafting menu with no server round trip. The on_gui_opened redraw is kept as a self-healing refresh.
  • The per-entity assembling machine frame keeps its create/destroy cycle and gets its own element name so the two variants no longer collide on lookup.
  • New on_register/on_unregister hooks in the QOL feature framework so runtime toggling via set_loaders draws and removes the persistent frames instead of leaking them; on_configuration_changed cleanup covers both frames.
  • Fixed a pre-existing nil dereference in draw_loader_frame (player.force was read before the nil check) and nil-guarded the recipe lookups in the click handlers.

Tests

Adds features/redmew_qol_tests.lua for the in-game test runner: frame drawn/removed on feature toggle, frame persists after the crafting menu closes, frame removed when no loader recipe is enabled, one button per enabled recipe, and the machine frame staying separate and destroyed on close. All five pass in-game. Note: run the suite with the redmew-data mod disabled — the loaders feature intentionally goes inert when that mod provides its own loaders.

🤖 Generated with Claude Code

The loader frame anchored to the controller GUI was created in
on_gui_opened and destroyed in on_gui_closed. Script events only run
once the input action has made the round trip through the server, while
the vanilla crafting menu is latency-hidden and opens instantly, so on
slow connections the frame appeared seconds after the menu.

The controller frame is now created once per player (on create, join,
force change and research finished) and left in place; anchored
relative frames show and hide with their target GUI, so it now appears
instantly with the crafting menu. The per-entity assembling machine
frame keeps the create/destroy cycle and gets its own element name so
the two no longer collide.

Also adds on_register/on_unregister hooks to the QOL feature framework
so runtime toggling via set_loaders draws and removes the persistent
frames, and adds tests for the loader GUI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lex lex force-pushed the loader-gui-latency branch from 221e79c to 88990a1 Compare July 10, 2026 19:42

@grilledham grilledham left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Decent minor qol improvement.

@grilledham grilledham merged commit c659cf6 into Refactorio:develop Jul 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants