Skip to content

Commit d6aabe4

Browse files
committed
Fix buggy backend fallbacks in Rasterizer causing deadlock.
1 parent eb785b3 commit d6aabe4

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

genesis/ext/pyrender/primitive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def _remove_from_context(self):
478478
glDeleteVertexArrays(1, [self._vaid])
479479
glDeleteBuffers(len(self._buffers), list(self._buffers.values()))
480480
self._vaid = None
481-
self._buffers = {}
481+
self._buffers.clear()
482482

483483
def _in_context(self):
484484
return self._vaid is not None

genesis/ext/pyrender/renderer.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,24 +609,26 @@ def _bind_and_draw_primitive(self, primitive, pose, program, flags, env_idx):
609609
###########################################################################
610610

611611
def _update_context(self, scene, flags):
612-
# Update meshes
613-
scene_meshes = scene.meshes
612+
# Get existing and new meshes
613+
scene_meshes_new = scene.meshes.copy()
614+
scene_meshes_old = self._meshes
615+
616+
# Update set of meshes right away, so that the context can be cleaned up correctly in case of failure
617+
self._meshes = scene_meshes_new
614618

615619
# Add new meshes to context
616-
for mesh in scene_meshes - self._meshes:
620+
for mesh in scene_meshes_new - scene_meshes_old:
617621
for p in mesh.primitives:
618622
p._add_to_context()
619623

620624
# Remove old meshes from context
621-
for mesh in self._meshes - scene_meshes:
625+
for mesh in scene_meshes_old - scene_meshes_new:
622626
for p in mesh.primitives:
623627
p.delete()
624628

625-
self._meshes = scene_meshes.copy()
626-
627629
# Update mesh textures
628630
mesh_textures = set()
629-
for m in scene_meshes:
631+
for m in scene_meshes_new:
630632
for p in m.primitives:
631633
mesh_textures |= p.material.textures
632634

genesis/ext/pyrender/viewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ def start(self, auto_refresh=True):
12371237
except OpenGL.error.Error:
12381238
# Invalid OpenGL context. Closing before raising.
12391239
self.close()
1240-
return
1240+
raise
12411241

12421242
# At this point, we are all set to display the graphical window, finally!
12431243
self.set_visible(True)

0 commit comments

Comments
 (0)