Open yaroslavkulinich opened 3 years ago
@yaroslavkulinich, thanks for reporting. What is your environment (OS, graphics hardware)? What happens with CPU consumption in these moments?
MacOS Big Sur, 16 GB, Intel Iris Plus Graphics 1536 (MacBook Pro 2020). Nothing special with CPU consumption.
Video with described behavior.
Thank you! Can I get your code somewhere?
Repository with the project running on video. Launched with adopt-openjdk-16.0.2
Main.kt
fun main() = application {
androidx.compose.ui.window.Window(onCloseRequest = ::exitApplication) {
App()
}
}
@Composable
@Preview
fun App() {
DesktopMaterialTheme {
Row {
SwingPanel(
modifier = Modifier.fillMaxSize().weight(1f),
factory = {
JPanel().apply {
layout = BoxLayout(this, BoxLayout.Y_AXIS)
val ww = WorldWindowGLCanvas().apply {
model = BasicModel()
}
add(ww)
}
}
)
Column(Modifier.width(200.dp).fillMaxWidth()) {
val textFieldState = remember { mutableStateOf("") }
val focusManager = LocalFocusManager.current
TextField(
value = textFieldState.value,
onValueChange = { textFieldState.value = it },
label = { Text("TextField") }
)
Spacer(Modifier.height(4.dp))
Button(
modifier = Modifier.fillMaxWidth(),
onClick = { focusManager.clearFocus() }
) {
Text("Clear focus")
}
}
}
}
}
Could you try to replace main with
fun main() = SwingUtilities.invokeLater {
ComposeWindow().apply {
size = Dimension(300, 300)
defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE
setContent {
App()
}
isVisible = true
}
}
and see if the issue persist?
@akurasov Wow! Great! Issue gone!
@akurasov Thank you!
It means, issue iss related with known problem of high CPU consumption during animation. This specific case will be fixed soon (probably next Compose build). What I proposed is a temporary workaround.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
I have the WorldWind Java 3D map (OpenGL) working in separate SwingPanel and regular Composable with TextField displayed side-by-side.
The problem is simple to reproduce. When I try to edit any of my TextFields, the map (inside SwingPanel) freezes and I can't do anything with it, even resize correctly (stretched picture effect when change window size).
After I remove focus from TextField (navigate to another composable for example) - everything becomes fine.