From 1c3d775d9062f4bf204286bd1b19762bec0ad86e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 26 Feb 2023 17:44:45 -0800 Subject: [PATCH] apprt/embedded: ignore size callbacks that change nothing --- src/apprt/embedded.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 8db67b0a1..0a21504e7 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -206,6 +206,12 @@ pub const Surface = struct { } pub fn updateSize(self: *Surface, width: u32, height: u32) void { + // Runtimes sometimes generate superflous resize events even + // if the size did not actually change (SwiftUI). We check + // that the size actually changed from what we last recorded + // since resizes are expensive. + if (self.size.width == width and self.size.height == height) return; + self.size = .{ .width = width, .height = height,