diff --git a/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift b/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift index 750af3b8d..0825e2657 100644 --- a/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift +++ b/Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView.swift @@ -238,6 +238,11 @@ open class _UIHostingView: UIView, XcodeViewDebugDataProvider where Con // TODO super.init(frame: .zero) // TODO + + if _UIUpdateAdaptiveRateNeeded() { + viewGraph.append(feature: EnableVFDFeature()) + } + initializeViewGraph() // RepresentableContextValues.current = @@ -320,7 +325,7 @@ open class _UIHostingView: UIView, XcodeViewDebugDataProvider where Con let interval = if let displayLink, displayLink.willRender { 0.0 } else { - renderInterval(timestamp: .systemUptime) / UIAnimationDragCoefficient() + renderInterval(timestamp: .systemUptime) / Double(UIAnimationDragCoefficient()) } render(interval: interval, targetTimestamp: nil) Update.unlock() @@ -445,6 +450,13 @@ open class _UIHostingView: UIView, XcodeViewDebugDataProvider where Con } static func defaultViewGraphOutputs() -> ViewGraph.Outputs { .defaults } + + // Audited for 6.5.4 + private struct EnableVFDFeature: ViewGraphFeature { + func modifyViewInputs(inputs: inout _ViewInputs, graph: ViewGraph) { + inputs.base.options.insert(.supportsVariableFrameDuration) + } + } } extension _UIHostingView { diff --git a/Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift b/Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift index cf420fbfb..87768bf42 100644 --- a/Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift +++ b/Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift @@ -205,9 +205,10 @@ package final class ViewGraph: GraphHost { package subscript(feature: T.Type) -> UnsafeMutablePointer? where T: ViewGraphFeature { features[feature] } - + override package func instantiateOutputs() { let outputs = globalSubgraph.apply { + // Audited for 6.5.4 var inputs = _ViewInputs( graphInputs, position: $position, @@ -225,12 +226,6 @@ package final class ViewGraph: GraphHost { preferenceBridge.wrapInputs(&inputs) } _ViewDebug.initialize(inputs: &inputs) - if _VariableFrameDurationIsSupported() { - inputs.base.options.formUnion(.supportsVariableFrameDuration) - } - if let delegate { - delegate.modifyViewInputs(&inputs) - } if inputs.needsGeometry { // inputs.makeRootMatchedGeometryScope() } diff --git a/Sources/OpenSwiftUI_SPI/Shims/UIKit/UIKit_Private.h b/Sources/OpenSwiftUI_SPI/Shims/UIKit/UIKit_Private.h index e96e2d929..d921c0ed2 100644 --- a/Sources/OpenSwiftUI_SPI/Shims/UIKit/UIKit_Private.h +++ b/Sources/OpenSwiftUI_SPI/Shims/UIKit/UIKit_Private.h @@ -47,7 +47,12 @@ OPENSWIFTUI_EXPORT bool UIViewIgnoresTouchEvents(UIView *view); OPENSWIFTUI_EXPORT -double UIAnimationDragCoefficient(void); +float UIAnimationDragCoefficient(void); + +// MARK: - UIUpdate related private API from UIKitCore + +OPENSWIFTUI_EXPORT +bool _UIUpdateAdaptiveRateNeeded(); OPENSWIFTUI_ASSUME_NONNULL_END