Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#import <UIKit/UIKit.h>

#if OPENSWIFTUI_LINK_BACKLIGHTSERVICES
#include <BacklightServices/BLSBacklightFBSSceneEnvironment.h>

Check warning on line 17 in Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.h

View workflow job for this annotation

GitHub Actions / Execute compatibility tests for iOS (macos-15, 16.4, 2024, 18.5)

missing submodule 'BacklightServices.BLSBacklightFBSSceneEnvironment' [-Wincomplete-umbrella]

Check warning on line 17 in Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.h

View workflow job for this annotation

GitHub Actions / Execute compatibility tests for iOS (macos-15, 16.4, 2024, 18.5)

missing submodule 'BacklightServices.BLSBacklightFBSSceneEnvironment' [-Wincomplete-umbrella]

Check warning on line 17 in Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.h

View workflow job for this annotation

GitHub Actions / Execute compatibility tests for iOS (macos-15, 16.4, 2024, 18.5)

missing submodule 'BacklightServices.BLSBacklightFBSSceneEnvironment' [-Wincomplete-umbrella]

Check warning on line 17 in Sources/COpenSwiftUI/Shims/UIKit/UIKit_Private.h

View workflow job for this annotation

GitHub Actions / Execute tests on iOS (macos-15, 16.4, 2024, 18.5)

missing submodule 'BacklightServices.BLSBacklightFBSSceneEnvironment' [-Wincomplete-umbrella]
#endif

OPENSWIFTUI_ASSUME_NONNULL_BEGIN
Expand All @@ -36,6 +36,9 @@

@interface UIView (OpenSwiftUI_SPI)
- (instancetype)_initWithLayer:(CALayer *)layer;
- (void)_geometryChanged:(const void *)geometry forAncestor:(nullable UIView *)ancestor;
- (void)_registerForGeometryChanges;
- (void)_unregisterForGeometryChanges;
- (BOOL)_shouldAnimatePropertyWithKey_openswiftui_safe_wrapper:(NSString *)key OPENSWIFTUI_SWIFT_NAME(_shouldAnimateProperty(withKey:));
- (void)_setFocusInteractionEnabled_openswiftui_safe_wrapper:(BOOL)enabled OPENSWIFTUI_SWIFT_NAME(_setFocusInteractionEnabled(_:));
@property(nonatomic, readonly, nullable) UIViewController *_viewControllerForAncestor_openswiftui_safe_wrapper OPENSWIFTUI_SWIFT_NAME(_viewControllerForAncestor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,18 @@ extension _UIHostingView: ViewRendererHost {
}

package func updateTransform() {
base.updateTransform()

// TODO: Notify UIKit related bridges
_openSwiftUIUnimplementedWarning()

if !safeAreaRegions.contains(.container) {
invalidateProperties(.safeArea, mayDeferUpdate: false)
}
}

package func updateTransformWithoutGeometryObservation() {
base.updateTransformWithoutGeometryObservation()
}

package func updateSize() {
Expand Down Expand Up @@ -356,6 +367,11 @@ extension _UIHostingView {

extension _UIHostingView: RootTransformProvider {
package func rootTransform() -> ViewTransform {
if !_base.registeredForGeometryChanges {
_base.registeredForGeometryChanges = true
_registerForGeometryChanges()
}
// TODO
_openSwiftUIUnimplementedWarning()
return .init()
}
Expand Down Expand Up @@ -392,4 +408,3 @@ public func _makeUIHostingView<Content>(_ view: Content) -> NSObject where Conte
}

#endif

Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ open class _UIHostingView<Content>: UIView, XcodeViewDebugDataProvider where Con
base.layoutSubviews()
}

override dynamic open func _geometryChanged(
_ geometry: UnsafeRawPointer,
forAncestor ancestor: UIView?
) {
base._geometryChanged(geometry, forAncestor: ancestor)
}

@augmentcode augmentcode Bot May 28, 2026

Copy link
Copy Markdown

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.


override dynamic open var frame: CGRect {
get {
super.frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,30 @@ package class UIHostingViewBase {
}
}

@inline(__always)
func updateTransform() {
guard let uiView else {
return
}
if !viewGraph.invalidateTransform(), registeredForGeometryChanges {
uiView._unregisterForGeometryChanges()
registeredForGeometryChanges = false
}
}

package func updateTransformWithoutGeometryObservation() {
_openSwiftUIUnimplementedFailure()
guard let uiView else {
return
}
let wasRegisteredForGeometryChanges = registeredForGeometryChanges
if !viewGraph.invalidateTransform(), registeredForGeometryChanges {
uiView._unregisterForGeometryChanges()
registeredForGeometryChanges = false
}
if !wasRegisteredForGeometryChanges, registeredForGeometryChanges {

@augmentcode augmentcode Bot May 28, 2026

Copy link
Copy Markdown

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.

uiView._unregisterForGeometryChanges()
registeredForGeometryChanges = false
}
}

@inline(__always)
Expand Down Expand Up @@ -510,7 +532,14 @@ package class UIHostingViewBase {
}

package func _geometryChanged(_: UnsafeRawPointer, forAncestor: UIView?) {
_openSwiftUIUnimplementedFailure()
guard let host else {
return
}
if registeredForGeometryChanges {
host.invalidateProperties(.transform, mayDeferUpdate: false)
} else if !options.contains(.registeredForGeometryChanges) {
Log.internalError("Received _geometryChanged with no registration for \(self).")
}
}

package func layoutSubviews() {
Expand Down
8 changes: 7 additions & 1 deletion Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,13 @@ extension ViewGraph {

@discardableResult
package func invalidateTransform() -> Bool {
_openSwiftUIUnimplementedFailure()
let rootTransform = $rootTransform
guard !rootTransform.valueState.contains(.dirty) else {
return false
}
rootTransform.invalidateValue()
delegate?.graphDidChange()
return true
}
}

Expand Down
Loading