ra1028 / DifferenceKit

💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
https://ra1028.github.io/DifferenceKit
Apache License 2.0
3.54k stars 239 forks source link

Clues in how to debug "failed to demangle witness for associated type 'DifferenceIdentifier' in conformance .... #79

Closed tamc closed 4 years ago

tamc commented 4 years ago

This may be an Apple bug, but if anyone has time to give me pointers in diagnosing the root cause, I would appreciate it.

I'm seeing a crash:

failed to demangle witness for associated type 'DifferenceIdentifier' in conformance 'DifferenceKit.ArraySection<Tapestry.ProgressSection, DifferenceKit.AnyDifferentiable>: Differentiable' from mangled name '20DifferenceIdentifier0A3Kit14DifferentiablePQz'"

The crash trace says it occurs in this line:

let changeset = StagedChangeset(source: self.data, target: newData)

And inside that this line:

#6  (null) in diff<A, B>(source:target:useTargetIndexForUpdated:mapIndex:updatedElementsPointer:notDeletedEleme... ()

The crash only seems to occur on iOS 9.x devices (specifically, the old iPad Minis, so possibly the key is that it is 32 bit).

The crash does not occur in builds that are directly loaded from XCode onto a device, only on builds that are processed in TestFlight or the AppStore.

My guess is that this is therefore an Apple bug in how they are recompiling for older devices.

But if you have the time to offer any clues or hints as to the root cause of the bug so I can try and work around it, that would be very much appreciated.

ra1028 commented 4 years ago

I'm sorry, I have no knowledge. Someone may share a solution, so this issue will open for a while. If you have a self-solving solution, please share it.

WesleyJacobsMP commented 4 years ago

We have fixed this issue by adding DifferenceKit as a static framework (in our case by adding it as a swift package manager). Hope that helps for you @tamc

thecheatah commented 4 years ago

@WesleyJacobsMP i am running into the Sam issue. Are you saying in package.swift you marked the package as static? I tried doing that and I am still running into issues. Is there somewhere else where the package needs to be marked?

WesleyJacobsMP commented 4 years ago

@thecheatah We haven't marked it as static no. But we use DifferenceKit through another library (DiffableDataSources), adding that one as a SPM has resolved the issue for us.