Skip to content

Add geometry change invalidation support#881

Merged
Kyle-Ye merged 1 commit into
mainfrom
feature/geometry_change
May 28, 2026
Merged

Add geometry change invalidation support#881
Kyle-Ye merged 1 commit into
mainfrom
feature/geometry_change

Conversation

@Kyle-Ye
Copy link
Copy Markdown
Member

@Kyle-Ye Kyle-Ye commented May 28, 2026

Agent Summary

This adds UIKit geometry-change registration hooks to hosting views so transform invalidation can respond when host geometry changes.

The update forwards _geometryChanged through _UIHostingView, lazily registers geometry observation when the root transform is requested, and unregisters when transform invalidation no longer needs observation. It also implements ViewGraph.invalidateTransform() so root transform state is invalidated and graph delegates are notified.

Validation:

  • git diff --check
  • swift build (passes with existing project warnings)

@github-actions github-actions Bot added area: graph ViewGraph, AttributeGraph, graph hosts, and graph internals. area: hosting-bridge SwiftUI bridge, UIHosting/NSHosting, representables, and platform host views. area: layout Layout, geometry, safe area, alignment, stacks, or sizing. platform: iOS iOS-specific behavior or support. type: feature New API, behavior, platform support, or user-facing capability. labels May 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.94%. Comparing base (bc26339) to head (cf2628d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #881      +/-   ##
==========================================
- Coverage   26.95%   26.94%   -0.01%     
==========================================
  Files         678      678              
  Lines       47139    47144       +5     
==========================================
- Hits        12705    12704       -1     
- Misses      34434    34440       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye Kyle-Ye marked this pull request as ready for review May 28, 2026 16:04
@Kyle-Ye Kyle-Ye merged commit aa8f2c0 into main May 28, 2026
7 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/geometry_change branch May 28, 2026 16:04
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 28, 2026

🤖 Augment PR Summary

Summary: Adds UIKit geometry-change hooks so hosting views can invalidate root transform state when host geometry changes.

Changes:

  • Expose UIKit SPI for geometry change callbacks/registration in the UIKit shim header
  • Forward `_geometryChanged(_:forAncestor:)` through _UIHostingView into UIHostingViewBase
  • Lazily register for geometry changes when rootTransform() is requested
  • Unregister geometry observation when transform invalidation no longer requires it
  • Implement ViewGraph.invalidateTransform() to invalidate root transform and notify the graph delegate

Technical Notes: Geometry callbacks now trigger .transform invalidation, and safe-area invalidation is also updated when the container region isn’t present.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

uiView._unregisterForGeometryChanges()
registeredForGeometryChanges = false
}
if !wasRegisteredForGeometryChanges, registeredForGeometryChanges {
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingViewBase.swift:253, if !wasRegisteredForGeometryChanges, registeredForGeometryChanges looks effectively unreachable because this method only ever sets registeredForGeometryChanges to false. Consider double-checking that this is actually protecting against the “incidental registration” case you’re trying to guard.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

forAncestor ancestor: UIView?
) {
base._geometryChanged(geometry, forAncestor: ancestor)
}
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift:251, overriding UIKit’s _geometryChanged(_:forAncestor:) without calling super may suppress UIKit’s internal geometry propagation. Consider confirming that skipping super._geometryChanged is safe across the UIKit versions you’re targeting.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

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

Labels

area: graph ViewGraph, AttributeGraph, graph hosts, and graph internals. area: hosting-bridge SwiftUI bridge, UIHosting/NSHosting, representables, and platform host views. area: layout Layout, geometry, safe area, alignment, stacks, or sizing. platform: iOS iOS-specific behavior or support. type: feature New API, behavior, platform support, or user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant