From 0235a650676e354a3ded950d43e28eaf6fb52958 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 21 Oct 2026 02:51:05 +0800 Subject: [PATCH] fix: prevent AppKit button metrics crash on macOS 26 --- .../View/Control/Button/AppKitButton.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sources/OpenSwiftUI/View/Control/Button/AppKitButton.swift b/Sources/OpenSwiftUI/View/Control/Button/AppKitButton.swift index 6e6ba936d..98b7a2987 100644 --- a/Sources/OpenSwiftUI/View/Control/Button/AppKitButton.swift +++ b/Sources/OpenSwiftUI/View/Control/Button/AppKitButton.swift @@ -458,10 +458,29 @@ extension NSButton { var content = NSEdgeInsetsZero Update.syncMain { if isBordered { + #if OPENSWIFTUI_ATTRIBUTEGRAPH + if #available(macOS 26.0, *) { + // AppKit's Amber support reads system SwiftUI attributes on macOS 26+. + // OpenSwiftUI uses a separate AG namespace, so suspend dependency + // tracking during this call to avoid a cross-namespace input. + Graph.withoutUpdate { + _ = _getIntrinsicArtworkSize( + &size, alignmentRectInsets: &alignment, + idealContentInsets: &content, maxContentInsets: nil + ) + } + } else { + _ = _getIntrinsicArtworkSize( + &size, alignmentRectInsets: &alignment, + idealContentInsets: &content, maxContentInsets: nil + ) + } + #else _ = _getIntrinsicArtworkSize( &size, alignmentRectInsets: &alignment, idealContentInsets: &content, maxContentInsets: nil ) + #endif } } let alignmentInsets = EdgeInsets(top: alignment.top, leading: alignment.left, bottom: alignment.bottom, trailing: alignment.right)