This may be bigger than compose for web, but I'm n...
# compose-web
d
This may be bigger than compose for web, but I'm noticing that starting in 1.2.1, that I'm getting recompositions that I shouldn't for methods which take a parameter from a library module. This seems like a huge regression, so I'm guessing it's already a KI?
I can file a bug / upload a repro project if necessary
Basically, the behavior looks like this:
Copy code
sealed interface Justification {
  object Left : Justification
  object Center: Justification
  object Right: Justification
}

@Composable
fun SpanText(text: String, just: Justification) {
    println("SpanText recomposed")
    // Use justification etc.
    Span { Text(text) }
}
If
Justification
is defined in the app module itself, it's fine. But if included from a library module, the println will get triggered every time.
If I annotate the class with
@Immutable
then the recompositions stop happening. But I shouldn't have to do that.
a
You probably need the compose compiler in that module. Is it not there?
d
It's definitely there
It was working in 1.2.0 as well
I'll upload a zip file later tonight
Here's the project. Feel free to let me know if anyone sees any user error. Run
:app:jsBrowserRun
to see it in action.
o
Thank you, David! You’re right, it’s a regression we missed 😞 https://github.com/JetBrains/compose-jb/issues/2539
d
No problem, hope then the report was helpful!
o
Hi @David Herman! https://github.com/JetBrains/compose-jb/issues/2539#issuecomment-1341320188 - there is a beta build with a fix
d
Thank you! I'll test it locally. As someone working on a library, I'm not sure I can actually make this change and push it out to users. I'm guessing the plan there will be to wait for Compose 1.2.2? (Will that still be paired with Kotlin 1.7.20?)
o
applying that compiler plugin to your library would help too if you have functions taking
Jusitification
as a parameter in the lib (so IR in your klib will be optimal) But of course when users take your lib and have their own functions with
Justification
as a parameter, they won’t have those optimizations unless they apply 1.3.2.2-beta01 too.
d
Gotcha
Yeah I'm more worried about the latter case.
I think since I'm still pre-release, the excessive recompositions are OK for now. And I can wait for 1.2.2 (assuming it will be at most a 2-3 month wait?)
o
we expect to publish 1.2.2 quite soon (this or next week if everything else is okay)
d
Oh wow, OK that's super great
That's far quicker than I need, so even if there's a delay, I'm OK with that. (I appreciate you probably have concerns beyond just me and my little library in the corner of course)
o
The issue you found and reported is a critical thing, so we really appreciate your help 🙂
d
Someone on my Discord found it. I'll pass on the appreciation 🙂
@Oleksandr Karpovich [JB] https://github.com/JetBrains/compose-jb/releases/tag/v1.2.2 doesn't seem to mention the recomposition issue. I'm assuming it's part of it though?
I just tried 1.2.2 locally and it seems to be working. Is it worth updating the release notes to mention this fix for Web?
o
Yes! thank you!