Skip to content

Commit a6f00db

Browse files
committed
Fix race condition (again)
1 parent 13c73a3 commit a6f00db

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

webgpu/canvas.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class Canvas:
7878

7979
def __init__(self, device, canvas, multisample_count=4):
8080
self._update_mutex = threading.Lock()
81+
self.target_texture = None
8182

8283
self._on_resize_callbacks = []
8384
self._on_update_html_canvas = []
@@ -181,6 +182,9 @@ def on_update_html_canvas(self, func: Callable):
181182

182183
def save_screenshot(self, filename: str):
183184
with self._update_mutex:
185+
if self.target_texture is None:
186+
self.resize._original(self)
187+
184188
path = pathlib.Path(filename)
185189
format = path.suffix[1:]
186190
data = read_texture(self.target_texture)

0 commit comments

Comments
 (0)