Skip to content

macOS 26: AppKit button metrics crash with the AttributeGraph backend #1

Closed
OpenSwiftUIProject/OpenSwiftUI
#1201

Description

@Kyle-Ye

Description

Game2048 aborts during button layout on macOS 26 when OpenSwiftUI uses Apple's AttributeGraph backend. AppKit's button metrics implementation reads a system SwiftUI environment while an OpenSwiftUI graph rule is active.

AttributeGraph precondition failure: accessing attribute in a different namespace: 59456

Reproduction

Example: OpenSwiftUIProject/Game2048, revision 046aecb.

git clone https://github.com/OpenSwiftUIProject/Game2048.git
cd Game2048
export MISE_ENV=osui-source,ag
make apple_setup
make macOS_run

If the initial generation reports unresolved remote SDK stubs, run make apple_setup again after package resolution. The crash also reproduces with MISE_ENV=osui-source,local,ag and local OpenSwiftUI dependencies.

  • Host: macOS 26.6.2 (25G83), Apple silicon
  • Xcode: 26.6
  • OpenSwiftUI source baseline used for the investigation: da91cd90
  • Backend: AttributeGraph

Expected: The app opens and lays out its buttons.

Actual: The main thread aborts with EXC_CRASH / SIGABRT during NSButton.metrics.

Relevant stack

AG::precondition_failure
AG::Graph::input_value_ref_slow
AGGraphGetValue
SwiftUI.ViewGraphHost.environment.getter
AppKit ...
-[NSButton(NSButtonAmberSupport) _getIntrinsicArtworkSize:alignmentRectInsets:idealContentInsets:maxContentInsets:]
closure #1 in NSButton.metrics.getter
Update.syncMain
NSButton.metrics.getter
closure #1 in ButtonLayoutComputer.Engine.sizeThatFits

Cause and compatibility fix

The system SwiftUI and OpenSwiftUI implementations both call _getIntrinsicArtworkSize inside Update.syncMain. The difference is the active AttributeGraph namespace:

SwiftUI rule     -> AppKit -> SwiftUI environment: same namespace
OpenSwiftUI rule -> AppKit -> SwiftUI environment: different namespaces

Runtime breakpoints on AGGraphCreateShared confirmed that OpenSwiftUI and system SwiftUI use separate GraphHost.sharedGraph instances. When AppKit's Amber support reads the system SwiftUI environment, AttributeGraph tries to register an input dependency across those namespaces and aborts.

The same app artifact did not crash in a macOS 15.7.3 VM during the observed startup and button metrics calls.

A local compatibility change wraps only _getIntrinsicArtworkSize in Graph.withoutUpdate, guarded by #if OPENSWIFTUI_ATTRIBUTEGRAPH and if #available(macOS 26.0, *). This suspends dependency tracking at the AppKit call boundary and restores it afterward. The earlier unguarded form passed a short launch check on the affected host; the final guarded change has passed syntax checks but has not yet been rebuilt and run. Other backends have not been validated for this issue.

Attachments

The ZIP contains the complete, unchanged Game2048App-2026-10-21-015023.ips report.

Crash stack in Console

Download the complete IPS report (ZIP)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions