From 3364486c587f15984fe44de89eafdd59714afa54 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Sat, 7 Oct 2023 00:22:24 +0200 Subject: [PATCH] undo the undoing of an earlier change --- wgpu/gui/offscreen.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wgpu/gui/offscreen.py b/wgpu/gui/offscreen.py index a94afedb..79296f2f 100644 --- a/wgpu/gui/offscreen.py +++ b/wgpu/gui/offscreen.py @@ -76,6 +76,11 @@ def draw(self): def call_later(delay, callback, *args): loop = asyncio.get_event_loop_policy().get_event_loop() + # for the offscreen canvas, we prevent new frames and callbacks + # from being queued while the loop is running. this avoids + # callbacks from one visualization leaking into the next. + if loop.is_running(): + return loop.call_later(delay, callback, *args)