When updating state from a nested closure of a GeometryReader the PerceptionRegistrarperceptionCheck incorrectly labels it as isGeometryTrailingClosure.
This was originally observed as I had a gestureonChanged inside of a GeometryProxy.
Checklist
[X] I have determined that this bug is not reproducible using Swift's observation tools. If the bug is reproducible using the @Observable macro or another tool from the Observation framework, please file it directly with Apple.
[x] If possible, I've reproduced the issue using the main branch of this package.
Perceptible state was accessed but is not being tracked. Track changes to state by wrapping your view in a 'WithPerceptionTracking' view.
Steps to reproduce
Failing Test
@MainActor
func testGeometryReader_GeometryProxyNestedClosure_ImproperPerceptionTracking() async throws {
struct FeatureView: View {
let model = Model()
var body: some View {
WithPerceptionTracking {
content
}
}
var content: some View {
GeometryReader { _ in
WithPerceptionTracking {
ZStack {}
.task { @MainActor in _ = model.count }
}
}
}
}
self.render(FeatureView())
try await Task.sleep(for: .milliseconds(100))
}
Output of demangled symbol
"(1) suspend resume partial function for closure #2 @Swift.MainActor @Sendable () async -> () in closure #1 () -> <<opaque return type of (extension in SwiftUI):SwiftUI.View.task(priority: Swift.TaskPriority, _: @Sendable () async -> ()) -> some>>.0 in closure #1 (SwiftUI.GeometryProxy) -> Perception.WithPerceptionTracking<<<opaque return type of (extension in SwiftUI):SwiftUI.View.task(priority: Swift.TaskPriority, _: @Sendable () async -> ()) -> some>>.0> in content.getter : some in FeatureView #1 in PerceptionTests.RuntimeWarningTests.testGeometryReader_GestureChanged_ImproperPerceptionTracking() async throws -> ()"
Perception version information
1.2.4
Destination operating system
iOS 17
Xcode version information
Xcode 15.1
Swift Compiler version information
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
Description
When updating state from a nested closure of a
GeometryReader
thePerceptionRegistrar
perceptionCheck
incorrectly labels it asisGeometryTrailingClosure
.This was originally observed as I had a
gesture
onChanged
inside of aGeometryProxy
.Checklist
@Observable
macro or another tool from theObservation
framework, please file it directly with Apple.main
branch of this package.Expected behavior
No runtime warning
Actual behavior
Runtime warning
Steps to reproduce
Failing Test
Output of demangled symbol
Perception version information
1.2.4
Destination operating system
iOS 17
Xcode version information
Xcode 15.1
Swift Compiler version information