projectmesa/mesa

jupyterviz agent space and measures flash on mesa 2.1.4

rlskoeser opened this issue · 2 comments

Describe the bug
When I run my simulations on the latest release (v2.1.4), my agent space and charts flicker.

Expected behavior
In mesa 2.1.2 these render smoothly and update without any flickering.

To Reproduce
My code base is here if you want to try running solara apps yourself: https://github.com/Princeton-CDH/simulating-risk
If you check it out and install dependencies, you can run one of the models like this:

solara run --host localhost simulatingrisk/hawkdovevar/app.py

I'm going to pin mesa to version 2.1.2 for now, but I like the new layout and would like to update once this is resolved.

Additional context
I looked at the release notes and some of the PRs; I tried changing the play_interval in my code when I initialize JupyterViz for my model, but it didn't have any effect.

I'm using altair instead of matplotlib, in case that's relevant.

I made a couple of screen recordings so you can see what I'm describing.

Nice smooth updating on mesa 2.1.2:
https://github.com/projectmesa/mesa/assets/691231/22b676b9-d83c-4658-a93f-46ab343a8f9d

Jerky, flashing updating on mesa 2.1.4:
https://github.com/projectmesa/mesa/assets/691231/06adccee-8823-44c1-b029-ce3660256034

rht commented

Upon investigating, it is due to the fact that the plot objects seem to be recreated from scratch for each step. This affects both the Matplotlib render as well. Removing

@solara.component
fixes the issue. A proper solution would be to ensure the ColorCard and subcomponent of ColorCard are rerendered only when necessary.

thanks for investigating and resolving so quickly!