mirror of
https://github.com/flame-engine/flame.git
synced 2026-03-31 07:48:19 +00:00
Fix priority rebalancing causing concurrent mutation of component ordered_set. This fixes https://github.com/flame-engine/flame/issues/3363 Basically priority changes and rebalancing was not using the component lifecycle event queue, which caused concurrent mutations and iterations of the component set, and due to race conditions, loss of components as they are removed and re-added for rebalancing. The issue is not with ordered_set itself, but rather how it is being used. It was never designed to support concurrent mutations. A few notes for the future: * I think we should consider changing the whole event (input) system so that every event is queued and only processed predictably within the game loop, avoiding a whole class of concurrent modification issues * we should consider more efficient ways of rebalancing than literally removing every single component + re-adding (which is also error prone if there is concurrent access). --------- Co-authored-by: Lukas Klingsbo <me@lukas.fyi>