JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.77k stars 1.14k forks source link

Performance regression in Web in 1.6.0 #4412

Open mahozad opened 5 months ago

mahozad commented 5 months ago

Describe the problem After updating to compose multiplatform 1.6.0 and adjusting the code:

- Window(title = "App") {
+ CanvasBasedWindow(
+     title = "App",
+     canvasElementId = "content",
+     applyDefaultStyles = false,
+     requestResize = { IntSize(width = 900, height = 800) }
+ ) {
Icon(
-   painterResource("m$n-logo.png"),
+   painterResource(DrawableResource("m$n-logo.png")),
- @OptIn(ExperimentalResourceApi::class)
+ @OptIn(InternalResourceApi::class)
suspend fun loadResource(path: String): ByteArray {
-    return resource(path).readBytes()
+    return readResourceBytes(path)
}
- <canvas id="ComposeTarget" width="900" height="800">Loading</canvas>
+ <canvas id="content"></canvas>

the web app performance is much worse than what it was in 1.5.10.

Affected platforms

Versions

Sample code See the source code here. And the live demo here.

Additional information I am facing this on a system that has no dedicated graphics card (so it uses CPU to render?).

eymar commented 5 months ago

Do you notice it only on a system without a dedicated GPU?

I see these errors in the console:

Screenshot 2024-03-12 at 11 10 19

I'm wondering if there were the same errors with 1.5.1x versions? I couldn't quickly find a working commit with 1.5.x in your repo to try it.

Btw, on my laptop I don't notice any performance issues with your app (the wave runs smoothly and Ui is responsive. But it has a GPU.

mahozad commented 5 months ago

Hello. The performance is bad on Chrome in an Android phone as well.

I too see those errors in the console.

On that system tried to run jsBrowserRun with cmp 1.5.12, 1.5.10, 1.5.0 and kotlin 1.9.22, 1.9.10 and all failed with the below error: https://github.com/JetBrains/compose-multiplatform/issues/4003:

kotlin.NotImplementedError: Generation of stubs for class org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl is not supported yet

On my system performance is not as bad but it was better in previous versions.

eymar commented 5 months ago

Did you have the same app built with 1.5.1x versions? We would try to compare it with one built with 1.6.0.

The error:

kotlin.NotImplementedError: Generation of stubs for class org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl is not supported yet

It could mean there's a library incompatible with other libraries in your project. For example when you updated one library ("A") to a newer verision, but you also have another lib which depends on older version of "A".

RafaelAthosPrime commented 5 months ago

Maybe related to #4199 ?

mahozad commented 4 months ago

Did you have the same app built with 1.5.1x versions? We would try to compare it with one built with 1.6.0.

Yes. But now cannot change the versions back to 1.5.1x and test the app again because of the error #4003.

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.