After having some recomposition problems with a Li...
# compose
i
After having some recomposition problems with a List I started to look into the Compose Compiler reports and even though I have changed every single list to ImmutableList the reporting still gives me a weird result. A
Post
is (in theory) stable but a ImmutableList of Post is not... Am I missing something?
Copy code
stable class Post {
  stable val id: String
  stable val title: String
  stable val subtitle: String
  stable val description: String
  stable val tags: ImmutableList<String>
  stable val imageUrl: String
  stable val type: PostType
  <runtime stability> = 
}
the strange thing is the empty “<runtime stability>” then I wrap this into a sealed with 3 states (this is for extra context but not directly related)
Copy code
stable class Content {
  stable val showError: Boolean
  stable val tags: ImmutableList<Tag>
  unstable val posts: ImmutableList<Post> <------- ?¿?¿?¿
}
the Compose result is:
Copy code
restartable scheme("[androidx.compose.ui.UiComposable, [_]]") fun DiscoverList(
  stable scrollState: LazyGridState
  unstable items: ImmutableList<Post> <-------- ?¿?¿
  stable onItemViewed: Function2<Post, Int, Unit>
  stable onItemClicked: Function2<Post, Int, Unit>
  stable header: Function2<Composer, Int, Unit>
)
Post is a simple data class… is it because it has a List of Strings?
🧵 3
👀 1
❤️ 1
z
Can you link the code for PostType as well please?
i
Copy code
stable class PostType {
  stable val mode: PostMode
  <runtime stability> = Stable
}
PostType is basically a sealed class with 2 “options” (could be modeled as an Enum) but since it is reported as stable it should not be the problem
z
Are you able to add @Stable to it (and Post) without too much hassle? It would be interesting to see if that makes any difference. I had kind of the opposite happen a while back where a non-stable value was inferred stable.
i
wow, your case is more strange. The thing is “Post” is already stable (although it leaves the <runtime stability> = empty… maybe a bug or a corner case?) I’m using ImmutableList which in theory should make it stable.
z
Ive seen the <runtime stability> empty as well, no idea why that is. Does the module with Post use/depend on compose?
i
ok so.. I’ve tried removing the inner ImmutableList of strings in Post and then it reports the stability correctly… so it seems a ImmutableList of items which have more lists (immutable) won’t work
z
Good find! It sounds like a bug to me, maybe someone else can chime in on that to verify though!
s
which
ImmutableList
are you using?
j
Suggest filing a bug on this
Assuming this is the kotlinx immutablelist or guava immutablelist
i
kotlinx version