Fix race around condition in space_renderer#3065
Closed
codebreaker32 wants to merge 3 commits intomesa:mainfrom
Closed
Fix race around condition in space_renderer#3065codebreaker32 wants to merge 3 commits intomesa:mainfrom
codebreaker32 wants to merge 3 commits intomesa:mainfrom
Conversation
|
Performance benchmarks:
|
Collaborator
Author
tpike3
approved these changes
Jan 9, 2026
Member
tpike3
left a comment
There was a problem hiding this comment.
This looks good to me...
I will give @Sahil-Chhoker, @EwoutH or @quaquel a few days to review if they want, but I am happy with this solution.
Collaborator
Member
|
Can you take a look at the conflicts in space renderer and ensure they are correctly resolved? Once that is done, I'll give a quick last look before merging it. |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
There is a race condition in
SpaceRenderer._map_coordinateswhen rendering NetworkGrid environments. Currently, the method usescontextlib.suppress(IndexError)to handle cases where an agent's node index exceeds the bounds of the cached layout positions (pos).The current logic is "all-or-nothing." If the simulation adds a new node/agent (e.g., node 100) before the visualization layout refreshes (which only knows nodes 0-99), the
IndexErrortriggers. The suppress block catches this error but aborts the entire coordinate mapping assignment.Bug / Issue
Fix #3064
Implementation
Testing
Benchmarking with 5,000 agents shows a negligible overhead of ~0.13ms per frame vs the old unsafe method.
If you're fixing the visualisation, add before/after screenshots.