SwiftUI Navigation - Top toolbar breaks and app is unusable

We've been trying to track down a non-reproducible issue for the past few months, and I'm wondering if anybody has encountered the same one.

Screenshots of the issue attached here. As you can see, the toolbar isn't respecting the safe area; there are many more issues that occur when this bug happens as well, such as the app being extremely laggy and sheets not opening.

Anecdotally, this seems to happen if the app is opened after not having been opened in a while (say, a day or so). It tends to happen first thing in the morning when I open the app, but as I mentioned, it's been very hard to reproduce.

I'm also wondering if it's a known SwiftUI navigation issue or if anyone has encountered this.

Could you please provide more information, it'll be helpful in understanding the issue and the steps you've taken to investigate the issue.

Can you also clarify if the view is a fullScreenCover and why there's two back buttons on the view?

Thanks for your response, attached is the intended view. It's actually not that the toolbar is in the wrong position; it's that the content below the toolbar is being placed incorrectly.

Steps I've taken to solve this:

  1. Attempted to reproduce in a test repo, but this was unfruitful. It has never happened during normal development; as I mentioned before, it only happens when the app is opened after not being open for some time
  2. On one occasion where I reproduced the issue, I was able to attach the debugger. I found that when a view was pushed onto the NavigationStack, duplicate views would be pushed onto the stack – e.g. after tapping into a single chat, the "path" of the NavigationStack would be something like ["Home", "Chat", "Chat", "Chat"...] Perhaps this is a useful clue?

SwiftUI Navigation - Top toolbar breaks and app is unusable
 
 
Q