Ina project using Core Data where I pass multiple objects to the navigationDestination (see example below), I'm seeing a lot of "Update NavigationAuthority possible destinations tried to update multiple times per frame." when I navigate in the Stack. After few push and pop in the stack, the app freezes, the memory increases, the CPU runs at 100%, then the app crashes. I checked the logs from my device: the issues are different every time, but it seems to be linked to a UI update.
To identify if it's related to Core Data or not, I reproduced the same NavigationStack with plain Structs, or simple Class objects. I don't see the log message, even when I pass multiple objects to the navigationDestination. The app never freezes.
I'm seeing similarly on Beta 4, though I didn't seem to see this on the earlier betas. Same scenario as the folks above though with regard to using nested NavigationLinks within a NavigationStack and also Core Data. Seems to be doing what the warning says and calling that destination over and over, until the app freezes.
I'm also seeing this or something similar starting with beta 5. I have a NavigationLink/navigationDestination with a NSManagedObject item in one view and another NavigationLink/navigationDestination combo in the destination view using another NSManagedObject item. When the outer NavigationLink is tapped, it just sits there and hangs with 100% CPU and running up memory like crazy. Putting a breakpoint in the upper navigationDestination reveals it getting called over and over so it's probably some kind of recursion in the SwiftUI framework.
If I change the upper NavigationLink to the older-style without an item or navigationDestination modifier, it works. This however reveals another SwiftUI bug that I already wrote a feedback ticket for in an early beta (FB10260549) where mixing the old style NavigationLink at a higher level with the new style links with items at a lower level results in the lower links not working.
So I've been trying to isolate the problem in a simpler sample app to attach to a new feedback ticket but I can't seem to reproduce it in the sample app. It's driving me crazy. I hope someone else has better luck and submits a feedback ticket for this.
I have the same issue where appending to the path for a NavigationStack and seeing "Update NavigationRequestObserver tried to update multiple times per frame." I can't reproduce it in a simple app but in my real app I have this message and 100% CPU usage and freezing issues. If I can determine a cause I will update here.
add .id(UUID()) on the NavigationLink fixes it for me in some cases.I think it's a bug in swiftUI. and I'm sure that there are more appropriate ways of assigning the id, but if u ensure the id is unique then it will fix the freeze in some cases.
I was able to hack around it by elevating the .navigationDestination() calls closer to the NavigationStack they're in. This obviously isn't ideal and doesn't allow for as easily passing data nested in a view, but it's working for me for now.
Maybe it was just my misunderstanding of the API in the first place and the navigationDestinations aren't supposed to depend on any data in the view presenting them other than what's passed in explicitly in the call. Most of my calls were just passing in the data for the View plus a binding to the NavigationPath, so it wasn't a problem to elevate them.
Same issue here when I try to include a .navigationDestination() modifier in my view.What I found out is that if we don't pass any variable(including a let, var or those wrapped in @State,@AppStorage,etc or passed through .environmentObject(some variable) ) to the destination view, it's perfectly fine. For example:
I am also seeing the same message. In a mirror situation (almost identical code in a Row/Detail situation where rows navigate to editor details), everything works fine. But in the second situation, I get the message "Update NavigationRequestObserver tried to update multiple times per frame" and 100% CPU hang. I've ripped out everything, so there's barely anything going on, and the problem persists. The differentiator between hangs/doesn't hang seems to be whether a closure in the editor (and one that has not even been invoked) captures a state variable in that editor (View). This makes no sense to me. There must be some strange stuff going on behind the scenes.
I was able to remove the runtime warning using a button instead of a navigation link, similar to RandoCorleones' suggestion. I toggled an isPresented State variable within the button that triggered a navigationDestination.
I encountered this problem with my NavigationStack when using both NavigationLink with values and without. The navigationStack had to be all NavigationLinks with values or without, I could not mix the two.
According to Google Bard ? this can happen if you are using an ObservableObject @Published property as the path: Binding on a NavigationStack and you are changing the value of the property in the same frame.
3a8082e126