-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistent loop of Matplotlib figure animation results in flickering output when run in a thread #1341
Comments
I solved the problem for my use case by using |
Hi, thanks for opening the issue, and you are right #431 is probably related. Not that this is not a Voila issue specifically, but an ipywidget problem. The long term solution is jupyter-widgets/ipywidgets#3759 I think. In solara (when using solara-server) this will already be used (see widgetti/solara#68 ) Regards, Maarten |
Thank you for the pointer to Solara! It's great that it is built on top if ipywidgets, and the demo looks slick. |
Context for this issue: projectmesa/mesa#1622. |
See also jupyter-widgets/ipywidgets#2358 (comment) which means that with ipykernel 6.29.0 this mighe work (please let us know here to confirm) |
Tested on ipykernel==6.29.0 and mesa==2.1.5: the flickering is still there, except that it happens much less often, in about every ~15 s or 30 s or so. Whereas on ipykernel==6.26.0 it won't even play the animation. |
Description
The Mesa agent-based modeling library is looking to replace its self-hosted Tornado-based visualization server with Voilà. I have made a prototype in https://github.com/rht/mesa-examples/tree/voila. However, I encountered the flickering issue reported in #431. To summarize, it is like running the Game of Life simulation with play and stop buttons. The play and stop work, except that the display flickers.
The long-running loop: https://github.com/rht/mesa-examples/blob/99a68386226f3fe5be3953d25a84bd92f8b7065c/examples/boltzmann_wealth_model/run_voila.py#L161-L170. If I run the loop without threading or multiprocessing, it runs just fine. Each loop lasts for about 300 ms. My hypothesis is that the solutions in #431 does not apply because there is only 1 plot being constantly re-rendered, whereas in my case, I have 3 objects being constantly rerendered:
widgets.Output
https://github.com/rht/mesa-examples/blob/99a68386226f3fe5be3953d25a84bd92f8b7065c/examples/boltzmann_wealth_model/run_voila.py#L154-L159
I have tried the
plt.draw()
as recommended in #431 (comment), but it didn't work out. I have also tried addingclear_output(wait=True)
, and it didn't work out.I haven't tried on JupyterLab yet, and have been focusing to make it work with
voila --no-browser --debug
. I apologize in advance if this issue is not concise nor self-contained.Context
The text was updated successfully, but these errors were encountered: