Error with Compose List(items, id: \.self)
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 330
- Forks
- 76
- Avg merge
- 3h 6m
- Merged PRs (30d)
- 1
Description
I am building an app using Skip. I can successfully run it on iOS.
However I encounter a crash on Android. Here is the crash logs:
java.lang.IllegalArgumentException: Type of the key rss.feed.model.RSSItem@a1b47b03 is not supported. On Android you can only use types which can be stored inside the Bundle.
at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:78)
at androidx.compose.foundation.lazy.layout.LazySaveableStateHolder.SaveableStateProvider(LazySaveableStateHolder.kt:84)
at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactoryKt.SkippableItem-JVlU9Rs(LazyLayoutItemContentFactory.kt:134)
at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactoryKt.access$SkippableItem-JVlU9Rs(LazyLayoutItemContentFactory.kt:1)
at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:101)
at androidx.compose.foundation.lazy.layout.LazyLayoutItemContentFactory$CachedItemContent$createContentLambda$1.invoke(LazyLayoutItemContentFactory.kt:91)
Interestingly, I tried to run RSSItem on playground and It works fine. here is the swift class file for RSSItem
//
// RSSItem.swift
//
//
//
import Foundation
public struct RSSItem {
public var title: String
public var link: String
public var description: String
public var enclosure: String
public var pubDate: String
public var guid: String
public var creator: String
public var content: String
public init(){
self.title = ""
self.link = ""
self.description = ""
self.enclosure = ""
self.pubDate = ""
self.guid = ""
self.creator = ""
self.content = ""
}
}
extension RSSItem: Hashable {
public static func == (lhs: RSSItem, rhs: RSSItem) -> Bool {
return lhs.title == rhs.title
}
public func hash(into hasher: inout Hasher) {
hasher.combine(title)
}
}
Do you have any idea what may have caused the issue? I am loading the values of RSSItem in a List .
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported List(items, id: .self) usage and RSSItem.swift, then reproduce the Android crash and compare it with the playground behavior. Inspect how the Android List path handles item keys and saveable state; done means the RSSItem list no longer crashes on Android while retaining the reported iOS behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100