TabView with TabSection crashing on iPad

We have an iPad app and are using the new TabView and TabSection views in our sidebar. The TabSection is populated with data from a @FetchRequest that fetches data from CoreData. The data in CoreData is updated by a single worker that makes sure every value only exists once. This is done by using an OperationQueue with maxConcurrentOperationCount set to 1.

This is crashing for our users, and we can't figure out why. We can't reproduce it, and it only seems to happen on iPadOS. We have the same code running on macOS and haven't received any reports. (We collect them all via 3rd party).

The error is:

NSInternalInconsistencyException
Fatal: supplied item identifiers are not unique. Duplicate identifiers: {(
    ...
)}

Where ... is one to many comma separated strings.

In our latest update we made sure the values are unique by passing them through a Set, unfortunately this is till crashing. Here's the fix we tried.

var uniqueTags: [HashTag] {
        let set = Set(hashTags)
        let array = Array(set)
        return array.sorted {
            $0.name?.lowercased() ?? "" < $1.name?.lowercased() ?? ""
        }
    }

We're out of ideas and have no idea what to do next.

@JagCesar2 What steps have you taken to investiagte the source of the exception and have you used a Sysdiagnose Log to narrow down the issue ? Since the problem is hard to reproduce, see Using a Sysdiagnose Log to Debug a Hard-to-Reproduce Problem for hints on how to capture an actionable sysdiagnose log.

I'm experiencing the same issue. It occurs, when minimising the app. My guess is that this happens while generating the snapshot for the app switcher. Even adding an empty section will crash my app:

TabSection("Feeds") {
 Tab("Home", systemImage: "house", value: Navigation.Sidebar.default) {
    EmptyView()
 }
}

Removing the wrapping "TabSection" fixes the issue.

@DTS Engineer We've figured out how to reproduce the bug. Sample code, video recording and instructions on how to reproduce have been submitted to feedback FB15483634

@seboslaw If you want to see how we reproduce it you can check out my mastodon post https://mastodon.social/@JagCesar/113302327859190678

Fingers crossed DTS responds with a workaround 🤞

@JagCesar2 Hey, have you heard anything from your bug report? I just dug back into this issue and was able to reproduce it with Apple's own DestinationVideo project: https://developer.apple.com/documentation/visionos/destination-video

Only thing you need to modify is uncheck 'Requires full screen' in Deployment info. After that select any item in the sidebar and minimise the app. If it doesn't crash after the 1st attempt, retry it a couple of times. For me it always bails with:

SwiftUI/SidebarAdaptableTabViewStyle_iOS.swift:482: Fatal error: Tried to update with invalid selection value

I also created a radar under FB15759496

TabView with TabSection crashing on iPad
 
 
Q