Skip to content

Commit 09f2c18

Browse files
committed
Fix division by zero error
1 parent 6c3bec1 commit 09f2c18

4 files changed

Lines changed: 5 additions & 2 deletions

File tree

webgpu/font.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def set_font_size(self, font_size: int):
126126
self.update()
127127

128128
def update(self):
129-
self.uniforms.width_normalized = 2.0 * self.uniforms.width / self.canvas.width
130-
self.uniforms.height_normalized = 2.0 * self.uniforms.height / self.canvas.height
129+
self.uniforms.width_normalized = 2.0 * self.uniforms.width / max(self.canvas.width, 1)
130+
self.uniforms.height_normalized = 2.0 * self.uniforms.height / max(self.canvas.height, 1)
131131
self.uniforms.update_buffer()
132132

133133

webgpu/input_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .utils import to_js
55
import threading
66

7+
78
class InputHandler:
89
def __init__(self, html_canvas):
910
self._mutex = threading.Lock()

webgpu/link/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ async def _on_message_async(self, message: str):
262262
except Exception as e:
263263
import traceback
264264
import sys
265+
265266
print("error in on_message", data, type(e), str(e), file=sys.stderr)
266267
if not isinstance(e, str):
267268
traceback.print_exception(*sys.exc_info(), file=sys.stderr)

webgpu/scene.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454

5555
id = str(uuid.uuid4())
5656
import threading
57+
5758
self.redraw_mutex = threading.Lock()
5859

5960
self._id = id

0 commit comments

Comments
 (0)