-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Research performance issues on Desktop #3543
Comments
Windows 11, Corretto 18, 10000 squares
A reduced benchmark: import androidx.compose.ui.awt.ComposeWindow // for >= 1.0.0
// import androidx.compose.desktop.ComposeWindow // for 0.4.0
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import java.awt.Dimension
import javax.swing.SwingUtilities
import kotlin.math.roundToInt
fun main() = SwingUtilities.invokeLater {
System.setProperty("skiko.renderApi", "OPENGL")
System.setProperty("skiko.vsync.enabled", "false")
ComposeWindow().apply {
size = Dimension(1280, 720)
setContent {
App()
}
isVisible = true
}
}
val particlesCount = 10_000
val fpsCounter = FPSCounter()
var time by mutableStateOf(0L)
@Composable
fun App() = Canvas(Modifier.fillMaxSize()) {
drawIntoCanvas {
time++
fpsCounter.tick()
drawRect(Color.Red)
repeat(particlesCount) {
val x = Math.random().toFloat()
val y = Math.random().toFloat()
drawRect(
color = Color.White,
Offset(size.width * x, size.height * y),
Size(10f, 10f)
)
}
}
}
// a reduced copy from skiko
class FPSCounter(
private val periodSeconds: Double = 2.0,
) {
private val times = mutableListOf<Long>()
private var lastLogTime = System.nanoTime()
private var lastTime = System.nanoTime()
fun tick() {
val time = System.nanoTime()
val frameTime = time - lastTime
lastTime = time
times.add(frameTime)
if ((time - lastLogTime) > periodSeconds.secondsToNanos() && times.isNotEmpty()) {
val average = (nanosPerSecond / times.average()).roundToInt()
times.clear()
lastLogTime = time
println("FPS $average")
}
}
private val nanosPerSecond = 1_000_000_000.0
private fun Double.secondsToNanos(): Long = (this * nanosPerSecond).toLong()
} |
The regression is in Skiko or in Skia, not in Compose itself. A pure Skiko benchmark shows similar regressions:
|
Does this mean that it could have some effects on other targets as well? iOS? If so, fixing this problem is going to boost performance for all targets. |
If it is not a Java/JNI overhead issue, then, yes, it should also affect iOS/web platforms. |
JetBrains/skiko@master...es/regression-rollback Regression is not present on macOS targets. We will try to update to latest Skia and see if they fixed the issue. |
Hey, Any news about this issue? |
We plan to update Skia, and if this won't resolve the issue, we'll look further. It either a Skia regression, or a build configuration change. |
Awesome, thanks for the great work! I'm working on a drawing app and users are encountering some latency issues, I hope that this will fix it. |
Upgrading Skia from m110 to m116 doesn't help. I checked the new Skiko with this PR - FPS is the same |
Hello, is there any news regarding this problem? |
Any news about this problem? I'm very worried because my customers of my desktop project have low-end specs and the FPS is about 10~15 that doesn't support OPENGL |
Any news about this problem? |
Any news? Same problem with the version 1.6.0 |
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
According to this article and performed tests with different versions of Compose, performance regression has been noticed after Compose 1.0 and Compose 1.2 (tested on Windows).
This is a potential point for further optimization.
The text was updated successfully, but these errors were encountered: