Hi! Reporting a reproducible multiplayer desync caused by the glyph visual system.
ENVIRONMENT
- Factorio 2.1.25 (headless server + Windows clients)
- alchemy-khemia 0.3.8 and 0.3.9
- ~95 mods, but the issue is isolated to Khemia (see below)
REPRO
1. Multiplayer server with 2+ players.
2. Remove/deconstruct any glyph (pipe).
3. Desync within seconds — every time, 100% reproducible.
EVIDENCE
- "Multiplayer desynchronisation: crc test (heuristic) failed", tick 39414881.
- No Lua errors in the log.
- Comparing server-level.zip and client-level.zip from the desync report: map data differs only in chunks 168–182 (the Khemia area) and level-heuristic-39424392.
- Desync report (456 MB) available on request.
BISECTION RESULT (the important part)
Commenting out the visual subsystem completely eliminates the desync:
- createFluidVisuals() (rendering.draw_sprite / draw_animation + surface.create_entity{name="glyph-lamp"}), and
- the per-tick ManageGlyphs() colour update.
Glyph pipe logic itself is fine — the problem is only in the visuals.
WORKAROUND THAT WAS TESTED AND WORKS
Keeping rendering.draw_sprite/draw_animation but NOT creating the "glyph-lamp" entities:
- visuals are back (glow/colour works),
- desync is gone,
- no other changes needed.
So the prime suspect is creation/removal of glyph-lamp entities (created per glyph and per overlay) and their ordering vs. on_object_destroyed.
OTHER POSSIBLE CONTRIBUTORS (in the same area)
- storage.fluidVisuals cleanup via table.remove() while iterating with: for i = inital, #storage.fluidVisuals, glyphStep
- re-entrant destruction inside the on_object_destroyed loop (k.overlayEntity.destroy() while storage.overlays is being rebuilt)
SUGGESTION
- Drop glyph-lamp entities entirely and drive the glow with rendering only (e.g. rendering.draw_light / tinted sprites), or
- defer all entity creation/destruction out of the iteration (collect first, mutate after), and avoid table.remove during index loops.
I can share the exact diff of my local workaround and the desync report — just tell me where to send them.
Thanks for the mod, it's great apart from this!