Closed MarilynKeller closed 1 year ago
Hi, thanks for reporting this issue! We added the clearing of the shader cache when the viewer is closed as you suggested.
We also noticed some problems with running the viewer multiple times from the same script, they seem to be related to the moderngl-window
implementation of the pyqt5
window. In our tests switching to the pyglet
window seems to fix the problem, but we prefer to keep the pyqt5
window as default since it has shown to be more reliable in other aspects and has better performance. You can switch to the pyglet
window by changing the window_type = "pyqt5"
to window_type = "pyglet"
in the Viewer class definition, we will also add a more convenient way to set the window type from the configuration file in the next release (this change is already up in the latest dev
branch). Let us know if we can be of any further help!
With the current code, the following crashes on the last line:
With the error:
The problem is in
aitviewer/enderables/meshes.py : make_renderable : l.351
, the shader program is not reloaded with the new context. The old shader program instance is used and it has the context of the first viewer, hence the mismatch.I see that the shader program is not reloaded everytime l.351 is executed thanks to a cache @functools.lru_cache() in
aitviewer/shaders.py
. I guess this cache should be cleared in between two viewers creation.This is the hack I have so far that fixes it: