-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime warnings #49
Comments
@arnauddorgans I can't seem to reproduce this on 1.1.3 / |
Ah never mind, I couldn't reproduce it in our unit test suite but I was able to reproduce it in an app. Very strange! Will look into it! |
Any update? Same problem. |
Hi @m430, no update on our end. If someone has time to look into the issue we would happily accept a PR! |
@m430 I used a workaround by using a SwiftUI State @State private var searchText: String
var body: some View {
WithPerceptionTracking {
TextField("", text: $searchText)
.bind($store.searchText, to: $searchText)
}
} |
Just encountered this issue as well. The interaction between I examined the This issue is likely due to the way SwiftUI and the Perception library manage state updates and how views re-render. The It seems like the safest course is to re-establish tracking whenever using GeometryReader { proxy in
WithPerceptionTracking {
//
}
} |
This isn't related to this specific issue. What you are referring to is true of any escaping closure, and is mentioned in the docs:
|
Hey @mbrandonw , I recently ran into this "issue" myself while using |
This is an interesting project but this caveat is bit concerning. Is there a chance this could be addressed in some future version with patching the view context hierarchy? Or is this hitting a more fundamental SwifUI design limitation/issue? |
@janczawadzki Can you explain why the caveat is concerning in particular? We don't think there's a fundamental issue with the library, and we think the library solves a real world problem for folks that want to adopt the Observation machinery of Swift in <iOS 17. The issue raised here is one that I hope folks see as understandable:
Note that the runtime warnings provided by the library are completely additive for debugging purposes, and don't exist in release, and the main issue is that it's difficult to suppress warnings for every situation: it requires demangling stack symbols and detecting very specific action closures and otherwise. An alternative would have been for us to not emit warnings at all and just let folks know they need to test their views thoroughly, but we thought that's solving things in the wrong direction, and not providing the baseline of tools for folks to investigate potential problems and missing |
It absolutely addresses a real problem, and my question wasn't at all around messages - those are necessary! Challenge in adopting this in a non-trivial project is just knowing where modifications are needed, since this can't be identified (AFAIK?) via static analysis. How big of a change is this for me. Hence my question - library would be super useful, but I don't understand the internals of the state stack well enough to know if this issue could be overcome or not. Best case scenario would obviously be "it just works", next best would be "here are the places you need to inject WithExceptionTracking." (... and I'm not sure how that would work exactly, to be clear!) |
Description
This code snippet produces 3 runtime warnings on appear about
Perceptible state was accessed but is not being tracked. Track changes to state by wrapping your view in a 'WithPerceptionTracking' view.
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
Full app code
Perception version information
1.1.2
Destination operating system
iOS 14.0
Xcode version information
Xcode 15.3
Swift Compiler version information
The text was updated successfully, but these errors were encountered: