Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose Web 1.2.1 regression: unexpected recompositions #2539

Closed
eymar opened this issue Dec 6, 2022 · 4 comments
Closed

Compose Web 1.2.1 regression: unexpected recompositions #2539

eymar opened this issue Dec 6, 2022 · 4 comments
Assignees

Comments

@eymar
Copy link
Collaborator

eymar commented Dec 6, 2022

Originally reported in compose-web slack: https://slack-chats.kotlinlang.org/t/8070137/this-may-be-bigger-than-compose-for-web-but-i-m-noticing-tha

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?

Basically, the behavior looks like this:
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.

It was working in 1.2.0 as well

If I annotate the class with @Immutable then the recompositions stop happening. But I shouldn't have to do that.

recomposes-too-often-bug.zip

@eymar eymar self-assigned this Dec 6, 2022
@eymar
Copy link
Collaborator Author

eymar commented Dec 6, 2022

It's likely related to update from kotlin/js 1.7.10 to kotlin/js 1.7.20 (the compiler plugin for 1.7.20 didn't consider inferred @Immutable from dependency modules)

@eymar
Copy link
Collaborator Author

eymar commented Dec 7, 2022

Hey @bitspittle,
we published a new build of compose compiler plugin you may want to try with kotlin 1.7.20.

// in your build.gradle.kts
compose {
    kotlinCompilerPlugin.set("1.3.2.2-beta01") // it's a temporary hack. The new compiler version will likely be included in compose-multiplatform 1.2.2
}

The issue should be gone.

Note: 1.3.2.2-beta01 is available only with:

maven {
            url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev")
        }

@bitspittle
Copy link

I gave this a shot locally and it seemed to work. Thank you!

@bitspittle
Copy link

bitspittle commented Dec 15, 2022

Did this miss the 1.2.2 release?

Edit: I just tested locally and 1.2.2 seems to work. Should we close this bug now?

@eymar eymar closed this as completed Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants