For me, any View that is an Attachment will rebuild at full frame rate even with nothing changing, indeed, even with no variables in the view. In addition to causing CPU usage that isn't needed, if there are @State
variables in the View they do not always update. I am updating the var on DispatchQueue.main.async and most of the time it works. On occasions it is updated instantly. On other occasions it might take 30 seconds or more before the var changes are visible. If I set a BP where the @State variables are changed I can see that the change... but the new value is not visible in the View (on VisionPro). I have also used print("title (\title)")
and I can see the correct version in the console but what you see in AVP in the View is not correct (though it will, eventually update). Important to note, 70% of the time the values are updated immediately.
I've tried @StateObject
with a class
with ObservableObject
and while that made it better, it doesn't fix the issue.
The App is in FullImmersion at the time. I have no way of knowing if the is related or not.
Below is the latest iteration of the variable.
@StateObject var alertState = AlertState()
class AlertState: ObservableObject {
@Published var description: String = ""
@Published var title: String = ""
}