mesa icon indicating copy to clipboard operation
mesa copied to clipboard

SpaceRenderer continues using the old space after the model's grid is replaced

Open sangitabera opened this issue 1 week ago • 3 comments

Describe the bug SpaceRenderer captures the model's space during initialization and retains that reference for subsequent rendering operations.

Currently, this behavior is not explicitly documented. Users might expect the renderer to automatically use a new space if model.grid or model.space is replaced after initialization.

Clarifying this behavior would help users understand the renderer's lifecycle and avoid unexpected results when replacing a model's space.

Expected behavior The documentation should explain that:

  • SpaceRenderer captures the model's space during initialization.
  • Replacing the model's grid or space afterward does not automatically update the renderer's internal reference.
  • A new SpaceRenderer instance should be created to render the replacement space.

To Reproduce Not applicable. This is a documentation clarification rather than a functional bug.

Additional context The clarification could be added to the SpaceRenderer class docstring and, if appropriate, the init documentation.

sangitabera avatar Nov 21 '26 04:11 sangitabera

Hi @quaquel, could you please take a look at this and share your feedback? All tests are passing, and I'm ready to open a PR once it looks good to you.

sangitabera avatar Nov 21 '26 05:11 sangitabera

This seems very contrived to me. I cannot imagine any real use case where one would swap the grid on a model. At best, we can document this better on the space renderer.

quaquel avatar Nov 21 '26 09:11 quaquel

@quaquel Thanks for the clarification. I agree that dynamically replacing the grid is not a typical use case. Rather than changing the renderer's behavior, I can propose a small documentation update explaining that SpaceRenderer retains the space reference captured during initialization and should be recreated if the model's space is replaced. Would that be a useful clarification?

sangitabera avatar Nov 21 '26 09:11 sangitabera