Liam
04/11/2025, 9:51 PMJComponent
returned from FileEditor::getComponent
to the component of the editor tab.
Compose seems to do some pretty heavy initialization when addNotify
is called, and almost 500ms is spent on androidx.compose.ui.awt.ComposePanel#createComposeContainer
. 180ms on createDirectXOffscreenDevice
(I'm on windows). The next time I switch to the editor it takes about 100ms. Other file editors open much quicker. I also implemented a simple button incrementing a counter in compose, which (after it was displayed) was responsive as expected. So it's just something about (re-)attaching the component.
Before I invest more time into this, I just wanted to confirm if this is expected/known, and if something like a file editor (which is recreated quite often) is even supposed to be supported by jewel? If its something that is expected to improve over time, I can live with the loading time, but if this is not really going to be a supported use case, I can probably save me a lot of future headaches by implementing another solution now 😄
For reference, this is what I'm doing:
class MyFileEditor(private val file: VirtualFile) : NavigatableFileEditor, UserDataHolderBase() {
init {
enableNewSwingCompositing()
}
private val panel = JewelComposePanel { Text("Hello World") }
override fun getComponent(): JComponent {
return panel
}
override fun getPreferredFocusedComponent(): JComponent? {
return panel
}
// The rest is standard file editor boilerplate, just enough to get it to display...
}
seb
04/13/2025, 11:37 AMseb
04/13/2025, 11:39 AMseb
04/13/2025, 11:41 AMLiam
04/14/2025, 3:04 PM