About a year ago, I developed and released an app on the App Store (I believe it was running on the Sequoia SDK at the time), and everything was working fine.
I’m now revisiting the project using the newer Tahoe SDK, and I’m running into an issue with DiffableDataSource. Specifically, the app hangs and CPU usage spikes to 100% when applying snapshots.
Has anyone experienced similar issues after upgrading to newer SDKs? Are there any recent changes or pitfalls with DiffableDataSource (e.g., threading, Hashable requirements, or snapshot handling) that I should be aware of?
Any insights or suggestions would be greatly appreciated.
extension Section {
enum Identifier: Int, CaseIterable {
case main
}
enum Item: Hashable {
case file(FileViewData)
}
}
struct FileViewData: Equatable, Hashable, Identifiable {
let id: String
let name: String
var accessoryViewData: KTFDownloadAccessoryViewData
init(
id: String,
name: String,
accessoryViewData: KTFDownloadAccessoryViewData = .nothing
) {
self.id = id
self.name = name
self.accessoryViewData = accessoryViewData
}
}
public enum KTFDownloadAccessoryViewData: Equatable, Hashable {
case nothing
case selected(SelectedState)
case completed
public enum SelectedState: Equatable, Hashable {
case nothing
case waiting
case downloading(Double)
}
}
When I changed FileViewData as below, no hangs but item appearance doesn't change of course.
struct FileViewData: Equatable, Hashable, Identifiable {
let id: String
let name: String
var accessoryViewData: KTFDownloadAccessoryViewData
init(
id: String,
name: String,
accessoryViewData: KTFDownloadAccessoryViewData = .nothing
) {
self.id = id
self.name = name
self.accessoryViewData = accessoryViewData
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
static func == (lhs: FileViewData, rhs: FileViewData) -> Bool {
return lhs.id == rhs.id
}
}