From 6d0134c0ae7488afae91b167289dd489c8d34c68 Mon Sep 17 00:00:00 2001 From: Kulratan Thapar Date: Fri, 6 Mar 2026 09:43:03 +0000 Subject: [PATCH 1/3] Fix --- .../src/messages/viewport/viewport_message_handler.rs | 4 +++- frontend/src/utility-functions/viewports.ts | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/editor/src/messages/viewport/viewport_message_handler.rs b/editor/src/messages/viewport/viewport_message_handler.rs index 8a3196119b..681c292d04 100644 --- a/editor/src/messages/viewport/viewport_message_handler.rs +++ b/editor/src/messages/viewport/viewport_message_handler.rs @@ -27,7 +27,9 @@ impl MessageHandler for ViewportMessageHandler { fn process_message(&mut self, message: ViewportMessage, responses: &mut VecDeque, _: ()) { match message { ViewportMessage::Update { x, y, width, height, scale } => { - assert!(scale > 0., "Viewport scale must be greater than zero"); + if scale == 0. { + return; + } self.scale = scale; self.bounds = Bounds { diff --git a/frontend/src/utility-functions/viewports.ts b/frontend/src/utility-functions/viewports.ts index 670f2b1bea..ce4571526f 100644 --- a/frontend/src/utility-functions/viewports.ts +++ b/frontend/src/utility-functions/viewports.ts @@ -41,13 +41,15 @@ export function setupViewportResizeObserver(editor: Editor) { const bounds = entry.target.getBoundingClientRect(); // TODO: Consider passing physical sizes as well to eliminate pixel inaccuracies since width and height could be rounded differently - const scale = physicalWidth / logicalWidth; + const scale = logicalWidth > 0 ? physicalWidth / logicalWidth : 1; if (!scale || scale <= 0) { - continue; + // @ts-ignore + editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, 1e-6); + } else { + // @ts-ignore + editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, scale); } - - editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, scale); } }); From f75a9c6eb2a8798fd3e10dd996af414b861120f0 Mon Sep 17 00:00:00 2001 From: Kulratan Thapar Date: Fri, 6 Mar 2026 09:51:56 +0000 Subject: [PATCH 2/3] Fix --- frontend/src/utility-functions/viewports.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/utility-functions/viewports.ts b/frontend/src/utility-functions/viewports.ts index ce4571526f..da607c5528 100644 --- a/frontend/src/utility-functions/viewports.ts +++ b/frontend/src/utility-functions/viewports.ts @@ -44,10 +44,8 @@ export function setupViewportResizeObserver(editor: Editor) { const scale = logicalWidth > 0 ? physicalWidth / logicalWidth : 1; if (!scale || scale <= 0) { - // @ts-ignore editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, 1e-6); } else { - // @ts-ignore editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, scale); } } From 3921f515b1a5442d7fef0973da06d8552f5b7db2 Mon Sep 17 00:00:00 2001 From: Timon Date: Tue, 10 Mar 2026 12:01:10 +0000 Subject: [PATCH 3/3] Simplify --- editor/src/messages/viewport/viewport_message_handler.rs | 4 +--- frontend/src/utility-functions/viewports.ts | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/editor/src/messages/viewport/viewport_message_handler.rs b/editor/src/messages/viewport/viewport_message_handler.rs index 681c292d04..8a3196119b 100644 --- a/editor/src/messages/viewport/viewport_message_handler.rs +++ b/editor/src/messages/viewport/viewport_message_handler.rs @@ -27,9 +27,7 @@ impl MessageHandler for ViewportMessageHandler { fn process_message(&mut self, message: ViewportMessage, responses: &mut VecDeque, _: ()) { match message { ViewportMessage::Update { x, y, width, height, scale } => { - if scale == 0. { - return; - } + assert!(scale > 0., "Viewport scale must be greater than zero"); self.scale = scale; self.bounds = Bounds { diff --git a/frontend/src/utility-functions/viewports.ts b/frontend/src/utility-functions/viewports.ts index da607c5528..989ea7dc40 100644 --- a/frontend/src/utility-functions/viewports.ts +++ b/frontend/src/utility-functions/viewports.ts @@ -41,13 +41,9 @@ export function setupViewportResizeObserver(editor: Editor) { const bounds = entry.target.getBoundingClientRect(); // TODO: Consider passing physical sizes as well to eliminate pixel inaccuracies since width and height could be rounded differently - const scale = logicalWidth > 0 ? physicalWidth / logicalWidth : 1; + const scale = logicalWidth > 0 && physicalWidth > 0 ? physicalWidth / logicalWidth : 1; - if (!scale || scale <= 0) { - editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, 1e-6); - } else { - editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, scale); - } + editor.handle.updateViewport(bounds.x, bounds.y, logicalWidth, logicalHeight, scale); } });