Flix
Flix copied to clipboard
Segmentation fault: 11 While emitting IR SIL function ...
Maybe you will find Segmentation fault: 11 While emitting IR SIL function ... error info when use AnimatableCollectionViewProvider
. This look like Swift bug.
This issue will closed when this error go away.
This code will cause Segmentation fault: 11:
class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
}
func createValues() -> Observable<[Value]> {
return Observable.empty()
}
typealias Cell = RadioCollectionViewCell
typealias Value = Option
}
There are some workaround methods:
add createAnimatableNodes
:
class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
}
func createValues() -> Observable<[Value]> {
return Observable.empty()
}
typealias Cell = RadioCollectionViewCell
typealias Value = Option
func createAnimatableNodes() -> Observable<[IdentifiableNode]> {
let providerIdentity = self._flix_identity
return createValues()
.map { $0.map { IdentifiableNode(providerIdentity: providerIdentity, valueNode: $0) } }
}
}
or add a model to warp this Option
:
struct SegmentationFault11Warp<Value: Equatable & StringIdentifiableType>: Equatable & StringIdentifiableType {
var identity: String {
return value.identity
}
let value: Value
}
class TestRadioProvider<Option: Equatable & StringIdentifiableType>: AnimatableCollectionViewProvider {
func configureCell(_ collectionView: UICollectionView, cell: RadioCollectionViewCell, indexPath: IndexPath, value: Value) {
}
func createValues() -> Observable<[Value]> {
return Observable.empty()
}
typealias Cell = RadioCollectionViewCell
typealias Value = SegmentationFault11Warp<Option>
}
This very helpful !
@DianQK wondering how to explain the crash and your advised ways of workaround ?