Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

Overview

official project Latest release Latest build

Compose Multiplatform, by JetBrains

Compose Kotlin UI framework port for desktop platforms (macOS, Linux, Windows) and Web, components outside of the core Compose repository at https://android.googlesource.com/platform/frameworks/support.

Preview functionality (check your application UI without building/running it) for desktop platforms is available via IDEA plugin (https://plugins.jetbrains.com/plugin/16541-compose-multiplatform-ide-support).

Repository organization

Getting latest version of Compose Multiplatform

See https://github.com/JetBrains/compose-jb/tags for the latest build number.

Comments
  • free(): invalid pointer - when running on Linux

    free(): invalid pointer - when running on Linux

    Trying to run almost any Compose app (including, for instance, the codeviewer sample) results in the JVM crashing with a free(): invalid pointer error. This was observed on a fresh install of Ubuntu 20.04 in a virtual machine, but is presumably true of all Ubuntus and a wide variety of other distributions and hardware configurations. Interestingly, @olonho tested on his physical Ubuntu 20.04 machine and did not encounter this failure, so the percentage of users impacted is not yet known. This appears to be a regression introduced between 0.3.0-build154 and 0.3.0-rc1.

    For more details, I know @theapache64 encountered the same error in https://github.com/JetBrains/compose-jb/issues/275#issuecomment-782896658 and posted a full backtrace dump. His dump also includes a shader compile error, which I do not see when running the codeviewer app, so is presumably unrelated.

    Questions for @theapache64 : (1) More just curiosity than anything, but also looking for patterns, are you running on a VM or physical hardware? (2) When running the codeviewer sample for instance, but I don't get nearly the same amount of debug info as you and I don't seem to be getting a hs_err_pid file. How did you get your full backtrace dump?

    opened by jimgoog 27
  • Exception during IR lowering

    Exception during IR lowering

    I've been trying to get JetBrains Compose to work with my existing project, but it keeps on giving me this error:

    java.lang.IllegalStateException: Backend Internal error: Exception during IR lowering
    File being compiled: C:/Users/20047/IdeaProjects/TradisAgnostic/src/main/kotlin/io/ejekta/core/struct/GameRegistry.kt
    The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.backend.common.ir.IrUtilsKt.copyValueParametersToStatic(IrUtils.kt:245)
    	at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
    	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(PhaseBuilders.kt:124)
    	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(PhaseBuilders.kt:112)
    	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
    	at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:30)
    	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
    	at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:41)
    	at org.jetbrains.kotlin.backend.jvm.JvmLower.lower(JvmLower.kt:395)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:138)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm$default(JvmBackendFacade.kt:125)
    	at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFiles(JvmBackendFacade.kt:112)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:40)
    	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:647)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:210)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:162)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:371)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:105)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:249)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:38)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:80)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:92)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:602)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:93)
    	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1644)
    	at jdk.internal.reflect.GeneratedMethodAccessor98.invoke(Unknown Source)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.base/java.security.AccessController.doPrivileged(Native Method)
    	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    	at java.base/java.security.AccessController.doPrivileged(Native Method)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:829)
    
    

    This is with build 0.3.0-build141 and Kotlin 1.4.21. Attached is what GameRegistry.kt looks like.

    GameRegistry.txt

    compiler 
    opened by ejektaflex 27
  • Support for animated gif images.

    Support for animated gif images.

    Trying to display the following animated gif image displays only the first frame because it supports only the Bitmap.

    Image(
         bitmap = imageFromResource("lottie-sample.gif"),
         modifier = Modifier.align(Alignment.BottomCenter).preferredSize(100.dp,100.dp)
    )
    

    lottie-sample

    enhancement discussion resources desktop 
    opened by sureshg 26
  • Example Todo app

    Example Todo app

    Hello! I played with MPP Jetpack Compose and I really enjoyed it! I'm impressed with the ability to just copy @Composable functions from Android to common. You rock! As a result I created a sample Todo app. The key point of this example is that 99% of the code is common (data, business logic, presentation, navigation and UI).

    This app uses the following libraries:

    There are multiple common modules:

    • utils - just some useful helpers
    • database - SQLDelight database definition
    • main - displays a list of todo items and a text field, adds items to the database
    • edit - accepts an item id and allows editing
    • root - navigates between main and edit

    The root module is integrated into both Android and Desktop apps.

    Here are some screenshots:

    During my work I discovered some issues/bugs.

    Common:

    • Caught a compiler error, can be reproduced in this separate branch - just try to build e.g. the Android app, there should be "Backend internal error".

    Android:

    • Keyboard overlaps the bottom input field sometimes
    • The app is not clickable after the keyboard is closed via "Back" button (minimize/restore solves the problem)
    • Saving UI state seems not working properly. I tried to use port my solution from Decompose (using UiSavedStateRegistry) and the list scrolling position is not preserved. It works well with normal Jetpack Compose alpha04.

    Desktop:

    • Built-in Compose icons do not compile. E.g. using Icons.Default.ArrowBack throws kotlin.NotImplementedError: An operation is not implemented during compilation.
    • The app does not honor system screen scale factor. I am using Ubuntu 19.04 and have 4k screen with 200% scale factor set in the settings. The app is rendered on the bottom left quarter of the window, but reacts on mouse in correct coordinates. Changing scale type to 100% solves the problem, but in this case I had to reduce the resolution. Please check the attached GIF of the ImageViewer sample app.
    • Maybe unrelated, desktop module shows all the code from dependent modules as red. But compiles and runs fine. External dependencies are also fine.
    • Jetpack Crossfade animation renders only first and last frames
    • Check boxes are just filled with solid color, no "tick" icons
    opened by arkivanov 26
  • "androidx dependency" is compiled by a new Kotlin compiler backend and cannot be loaded by the old compiler

    Hello,

    I created the base project using you getting started tutorial. Well, it runs, it works, but IntelliJ IDEA thinks it should not work. It shows me the error that I specified in the issue name. How can I fix this?

    image

    bug 
    opened by ggoraa 25
  • Followed

    Followed "Milestone 2" release tutorial. End up with `Window` with red underline

    I followed the tutorial here: https://blog.jetbrains.com/cross-post/jetpack-compose-for-desktop-milestone-2-released/

    but I ended up with a red underline under Window Screen Shot 2020-12-04 at 7 22 12 PM

    Using Intellij 2020.3 community edition. Can repro every time I create a new project. Screen Shot 2020-12-07 at 4 13 15 AM Screen Shot 2020-12-07 at 4 13 33 AM

    ide 
    opened by ColtonIdle 24
  • Document how to use ProGuard with Compose for Desktop

    Document how to use ProGuard with Compose for Desktop

    I build my binary with packageDmg / packageMsi and I'm looking for a sample how I must modify my build.gradle.kts to include an obfuscation step. I don't find an answer to that.

    I think it would be nice if the official template would just contain such a step because it's a hard requirement for anybody who ships business software to customers.

    In issue #607 this was asked, but the answer was using packageUberJarForCurrentOS and obfuscate that. I find that not really satisfying, because I want the DMG / MSI as a result.

    Further the Gradle task for Android comes with easy proguard support. Why shoul the nativeDistributions section not contain a proguardConfFile param just to make it work out of the box?

    enhancement native distribution p:normal 
    opened by AshStefanOltmann 23
  • Exported deb file renders blank screen - Ubuntu

    Exported deb file renders blank screen - Ubuntu

    When using run

    image

    When running deb file

    image

    OS : Ubuntu 16.04

    IDE Version

    IntelliJ IDEA 2020.3.1 (Community Edition)
    Build #IC-203.6682.168, built on December 29, 2020
    Runtime version: 11.0.9.1+11-b1145.63 amd64
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    Linux 4.15.0-129-generic
    GC: ParNew, ConcurrentMarkSweep
    Memory: 1934M
    Cores: 6
    
    Current Desktop: Unity
    
    wait for reply rendering native distribution 
    opened by theapache64 23
  • Skia crash when calling Image.makeFromEncoded(bytes).asImageAsset()

    Skia crash when calling Image.makeFromEncoded(bytes).asImageAsset()

    Unfortunately i am not able to reproduce it reliable. But when i am loading many images and display it some times it crashes. To reproduce it execute the following code and scroll fast up and down. Sometimes it happens after just 10-20 images loadings. Sometimes it takes much longer. Also it is not every time necessary to scroll fast. I also tried to load the data into bytearrays first and than show alle images instantly without loading but it will still not crash reliable. Please see the crash details in this file: hs_err_pid15251.log Here is the code to reproduce the bug:

    import androidx.compose.desktop.Window
    import androidx.compose.foundation.Image
    import androidx.compose.foundation.layout.Box
    import androidx.compose.foundation.layout.aspectRatio
    import androidx.compose.foundation.layout.fillMaxSize
    import androidx.compose.foundation.layout.fillMaxWidth
    import androidx.compose.foundation.lazy.LazyColumnFor
    import androidx.compose.runtime.*
    import androidx.compose.ui.Modifier
    import androidx.compose.ui.graphics.ImageAsset
    import androidx.compose.ui.graphics.asImageAsset
    import androidx.compose.ui.unit.IntSize
    import kotlinx.coroutines.Dispatchers
    import kotlinx.coroutines.withContext
    import org.jetbrains.skija.Image
    import java.net.URL
    
    data class RemoteImage(val url: String, val width: Int, val height: Int)
    
    suspend fun loadImageUrl(url: String) = withContext(Dispatchers.IO) {
        val bytes = URL(url).openStream().use { it.readAllBytes() }
        log("Decode bytes: ${bytes.size}")
        Image.makeFromEncoded(bytes).asImageAsset()
    }
    
    @Composable
    fun loadImageAsyn(url: String): ImageAsset? {
        var state: ImageAsset? by remember(url) { mutableStateOf(null) }
        LaunchedEffect(url) {
            state = try {
                loadImageUrl(url)
            } catch (err: Exception) {
                println("Unable to load image $url: ${err.message}")
                null
            }
        }
        return state
    }
    
    fun main() {
        val width = 1000
        val height = 600
        val remoteImageList = (0..500).map {
            RemoteImage(
                url = "https://picsum.photos/id/$it/$width/$height",
                width = width,
                height = height
            )
        }
    
        Window(
            title = "Image Browser",
            size = IntSize(200,800),
            centered = true,
        ) {
            LazyColumnFor(remoteImageList) { item ->
                val image = loadImageAsyn(item.url)
                val aspectRatio = item.width.toFloat() / item.height.toFloat()
                Box(Modifier.aspectRatio(aspectRatio).fillMaxWidth()) {
                    image?.let {
                        Image(modifier = Modifier.fillMaxSize(), asset = it)
                    }
                }
            }
        }
    }
    
    bug rendering 
    opened by timo-drick 23
  • Performance regression in modifying `MutableState`

    Performance regression in modifying `MutableState`

    Calls to drawRect (and other drawing methods) in a Canvas are significantly slower in Compose 1.1.1 than they were in 1.0.0-alpha3.

    EDIT: We now know that the actual performance regression is in the management of the MutableState objects - not the drawing of the rectangles.

    I've bisected the releases, and found that the regression happened in 1.0.0-alpha4-build396 (that is, 1.0.0-alpha4-build396 has the worse performance, while 1.0.0-alpha4-build385 is OK)

    Environment

    OS: MacOS 12.1 (Monterey) Compose version: 1.1.1

    Reproducible example

    The following code creates a Window, renders 2000 rectangles, and gradually moves them across the screen, from left to right.

    On my MacBook it runs approximately 4-5x slower in Compose 1.0.0-alpha4-build396, compared to 1.0.0-alpha4-build385.

    package com.vaticle.compose.perf
    
    import androidx.compose.foundation.Canvas
    import androidx.compose.foundation.layout.fillMaxSize
    import androidx.compose.runtime.Composable
    import androidx.compose.runtime.LaunchedEffect
    import androidx.compose.runtime.getValue
    import androidx.compose.runtime.mutableStateOf
    import androidx.compose.runtime.remember
    import androidx.compose.runtime.setValue
    import androidx.compose.runtime.withFrameNanos
    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.window.Window
    import androidx.compose.ui.window.WindowPlacement
    import androidx.compose.ui.window.application
    import androidx.compose.ui.window.rememberWindowState
    
    fun main() {
        application {
            Window(title = "Boxes", onCloseRequest = { exitApplication() }, state = rememberWindowState(WindowPlacement.Maximized)) {
                val boxes = rememberBoxes()
                Canvas(Modifier.fillMaxSize()) {
                    boxes.forEach {
                        drawRect(Color.Red, Offset(it.x, it.y), Size(18f, 6f))
                    }
                }
                LaunchedEffect(Unit) {
                    while (true) {
                        withFrameNanos { boxes.forEach { box -> box.x++ } }
                    }
                }
            }
        }
    }
    
    @Composable
    fun rememberBoxes(): List<Block> {
        val boxes = mutableListOf<Block>()
        for (i in 0 until 100) {
            for (j in 0 until 20) { boxes += Block(x = (j * 20).toFloat(), y = (i * 8).toFloat()) }
        }
        return remember { boxes }
    }
    
    class Block(x: Float, y: Float) {
        var x by mutableStateOf(x)
        var y by mutableStateOf(y)
    }
    
    performance desktop 
    opened by alexjpwalker 20
  • Canvas.drawArc is ignoring size parameter

    Canvas.drawArc is ignoring size parameter

    Canvas.drawArc is ignoring size parameter The issue is specific to desktop app. Android app is working as expected.

    image

    A workaround was to draw path with Path.addArcRad

    image

    bug rendering 
    opened by rustamsmax 19
  • Web canvas: Certain RoundedCornerShapes crash Skia

    Web canvas: Certain RoundedCornerShapes crash Skia

    Drawing a Surface with certain RoundedCornerShapes crashes Skia. It doesn't crash with RectangleShape or RoundedCornerShape(16.dp), only seems to crash when setting radii per corner, e.g. RounderCornerShape(topStart = 8.dp, topEnd = 8.dp). From the browser console:

    skiko.wasm:0x266c94 Uncaught RuntimeError: remainder by zero
        at skiko.wasm:0x266c94
        at skiko.wasm:0x2674ce
        at skiko.wasm:0x272f76
        at skiko.wasm:0x2d65f2
        at skiko.wasm:0x34aa97
        at skiko.wasm:0x2c3c7e
        at skiko.wasm:0x2c6aa3
        at skiko.wasm:0x279300
        at skiko.wasm:0x269ade
        at skiko.wasm:0x269522
    

    Sample project Run ./gradlew jsBrowserDist && ./gradlew jsBrowserRun, click the bottom option to repro the crash

    opened by DSteve595 0
  • ModalDrawer does not prevent tab navigation in background

    ModalDrawer does not prevent tab navigation in background

    See this example code:

    import androidx.compose.foundation.layout.Box
    import androidx.compose.foundation.layout.fillMaxSize
    import androidx.compose.material.DrawerValue
    import androidx.compose.material.ModalDrawer
    import androidx.compose.material.Text
    import androidx.compose.material.TextButton
    import androidx.compose.material.rememberDrawerState
    import androidx.compose.ui.Alignment
    import androidx.compose.ui.Modifier
    import androidx.compose.ui.unit.DpSize
    import androidx.compose.ui.unit.dp
    import androidx.compose.ui.window.WindowState
    import androidx.compose.ui.window.singleWindowApplication
    
    fun main() = singleWindowApplication(WindowState(size = DpSize(300.dp,100.dp))) {
        val drawerState = rememberDrawerState(DrawerValue.Open)
        ModalDrawer(
            drawerState = drawerState,
            drawerContent = {
                TextButton(onClick = {}) {
                    Text("Focusable as expected")
                }
            }
        ) {
            Box(Modifier.fillMaxSize()) {
                TextButton(onClick = {}, modifier = Modifier.align(Alignment.TopEnd)) {
                    Text("Should not be focusable")
                }
            }
        }
    }
    

    Mouse interaction with the items in the background is prevented, but keyboard interaction (via Tab navigation and, e.g., Enter to click) is not:

    image

    I guess this might not be limited to Compose for Desktop, since focus management is not platform specific from what I could tell from the source code. In case it also affects Jetpack Compose, I'm not sure where to raise the issue.

    Also, I didn't find any way to conveniently disable all interaction (including tab navigation) of some composable including its children. Using Modifier.focusProperties { canFocus = false } on the first child in content did disable focus reception for some children, but not for all.

    opened by ialokim 2
  • `SwingPanel` throws NPE on focus request if nothing focusable

    `SwingPanel` throws NPE on focus request if nothing focusable

    Kotlin: 1.7.20 Compose: 1.2.1

    If there's no component focusable inside a SwingPanel and you try to request focus to it via, e.g., tabbing, it'll crash the application.

    Try the following sample code,

    import androidx.compose.foundation.layout.*
    import androidx.compose.material.OutlinedTextField
    import androidx.compose.material.Text
    import androidx.compose.runtime.Composable
    import androidx.compose.runtime.mutableStateOf
    import androidx.compose.runtime.remember
    import androidx.compose.ui.Modifier
    import androidx.compose.ui.awt.SwingPanel
    import androidx.compose.ui.unit.dp
    import androidx.compose.ui.window.singleWindowApplication
    import javax.swing.JPanel
    
    fun main() = singleWindowApplication {
        val letsSetItToFocusable = false
        Column(
            modifier = Modifier.padding(50.dp).fillMaxSize(),
            verticalArrangement = Arrangement.spacedBy(8.dp),
        ) {
            SomethingToFocusOn()
            SwingPanel(
                factory = {
                    JPanel().apply {
                        if (letsSetItToFocusable) isFocusable = true
                    }
                },
                modifier = Modifier.fillMaxWidth().height(40.dp),
            )
            SomethingToFocusOn()
        }
    }
    
    @Composable
    fun SomethingToFocusOn() {
        val text = remember { mutableStateOf("") }
        OutlinedTextField(value = text.value, onValueChange = { text.value = it }, singleLine = true, label = {
            Text("Try tab to switch focus")
        })
    }
    

    Outcome:

    Capture

    Relevant stack trace:

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "java.awt.Component.requestFocus(java.awt.event.FocusEvent$Cause)" because the return value of "java.awt.FocusTraversalPolicy.getFirstComponent(java.awt.Container)" is null
    	at androidx.compose.ui.awt.FocusSwitcher$Content$1.invoke(SwingPanel.desktop.kt:191)
    	at androidx.compose.ui.awt.FocusSwitcher$Content$1.invoke(SwingPanel.desktop.kt:186)
    	at androidx.compose.ui.focus.FocusChangedModifierKt$onFocusChanged$2$1.invoke(FocusChangedModifier.kt:47)
    	at androidx.compose.ui.focus.FocusChangedModifierKt$onFocusChanged$2$1.invoke(FocusChangedModifier.kt:44)
    	at androidx.compose.ui.focus.FocusEventModifierLocal.propagateFocusEvent(FocusEventModifier.kt:137)
    	at androidx.compose.ui.focus.FocusTransactionsKt.sendOnFocusEvent(FocusTransactions.kt:279)
    	at androidx.compose.ui.focus.FocusModifier.setFocusState(FocusModifier.kt:79)
    	...
    

    Now, in the above sample code, set letsSetItToFocusable = true instead, and it won't crash anymore. That's because the SwingPanel now has a focusable component.

    Digging into the source code of SwingPanel, I found the following lines to be problematic:

    info.container.focusTraversalPolicy
        .getFirstComponent(info.container)
        .requestFocus(FocusEvent.Cause.TRAVERSAL_FORWARD)
    

    https://github.com/JetBrains/androidx/blob/release/1.2.1/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/SwingPanel.desktop.kt#L190

    info.container.focusTraversalPolicy
        .getLastComponent(info.container)
        .requestFocus(FocusEvent.Cause.TRAVERSAL_FORWARD)
    

    https://github.com/JetBrains/androidx/blob/release/1.2.1/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/SwingPanel.desktop.kt#L203

    The problem is, both getFirstComponent(…) and getLastComponent(…) of the FocusTraversalPolicy interface are allowed to return null, and yet the kotlin code is treating it that it won't. This was confirmed via a debugger, and also if you use the IDE to look for implementations of the FocusTraversalPolicy interface, you will find that it may indeed return null when no swing component is focusable.

    Suggestion: Honor the nullability of those methods, and perhaps simply skip over the SwingPanel if it has no focusable components when looking for components to focus to.

    crash p:high swing 
    opened by jasonsparc 0
  • IR lowering failed when using expect fun to get colorscheme

    IR lowering failed when using expect fun to get colorscheme

    I use a except fun to get dynamic color on android, and default material color for desktop. This is what my code look like:

    //in androidMain
    @Composable
    actual fun getColor(darkMode: Boolean): ColorScheme {
        if (darkMode) return dynamicDarkColorScheme(LocalContext.current)
        return dynamicLightColorScheme(LocalContext.current)
    }
    
    //in desktopMain
    @Composable
    actual fun getColor(darkMode: Boolean): ColorScheme {
        if (darkMode) return darkColorScheme()
        return lightColorScheme()
    }
    
    //in commonMain
    
    @Composable
    expect fun getColor(darkMode: Boolean = isSystemInDarkTheme()): ColorScheme
    
    
    @Composable
    fun AppTheme(content: @Composable () -> Unit = {},darkMode:Boolean){
        MaterialTheme(
                colorScheme = getColor(darkMode),
        ) {
            content()
        }
    }
    

    And I got this issue when building

    java.lang.Exception: IR lowering failed at: Color.kt
    	at androidx.compose.compiler.plugins.kotlin.lower.ComposableFunctionBodyTransformer.visitFile(ComposableFunctionBodyTransformer.kt:4580)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:48)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:24)
    	at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.kt:30)
    	at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.kt:33)
    	at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.kt:21)
    	at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
    	at org.jetbrains.kotlin.ir.declarations.IrModuleFragment.transformChildren(IrModuleFragment.kt:51)
    	at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:346)
    	at androidx.compose.compiler.plugins.kotlin.lower.ComposableFunctionBodyTransformer.lower(ComposableFunctionBodyTransformer.kt:492)
    	at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:176)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda$1(JvmIrCodegenFactory.kt:183)
    	at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:99)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:215)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:53)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.convertToIr(KotlinToJVMBytecodeCompiler.kt:230)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:113)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:158)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:99)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
    	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:475)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:125)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:373)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:318)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:180)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:79)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
    	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1746)
    	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
    	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:598)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:844)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:721)
    	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:720)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    	at java.base/java.lang.Thread.run(Thread.java:833)
    
    Caused by: java.lang.IllegalArgumentException: Failed requirement.
    

    My compose-jb version is 1.3.0-beta3

    bug compiler 
    opened by OneClip-Project 1
  • java.lang.NullPointerException at androidx.compose.ui.node.DelegatableNodeKt.requireOwner(DelegatableNode.kt:308)

    java.lang.NullPointerException at androidx.compose.ui.node.DelegatableNodeKt.requireOwner(DelegatableNode.kt:308)

    Hi. I'm playing with jetbrains compose and Decompose library https://github.com/arkivanov/Decompose using it's navigation

    On one of the page I'm using .fillMaxWidth() modifier and when navigates to this page I'm getting the next exception.

    The same code works fine on desktop version

    E/AndroidRuntime: FATAL EXCEPTION: main Process: com.serhiy.connect, PID: 10207 java.lang.NullPointerException at androidx.compose.ui.node.DelegatableNodeKt.requireOwner(DelegatableNode.kt:308) at androidx.compose.ui.node.SemanticsModifierNodeKt.invalidateSemantics(SemanticsModifierNode.kt:44) at androidx.compose.ui.node.NodeKindKt.autoInvalidateNode(NodeKind.kt:171) at androidx.compose.ui.node.NodeChain.updateNodeAndReplaceIfNeeded(NodeChain.kt:513) at androidx.compose.ui.node.NodeChain.updateFrom$ui_release(NodeChain.kt:130) at androidx.compose.ui.node.LayoutNode.setModifier(LayoutNode.kt:735) at androidx.compose.ui.node.ComposeUiNode$Companion$SetModifier$1.invoke(ComposeUiNode.kt:42) at androidx.compose.ui.node.ComposeUiNode$Companion$SetModifier$1.invoke(ComposeUiNode.kt:42) at androidx.compose.runtime.ComposerImpl$apply$operation$1.invoke(Composer.kt:1621) at androidx.compose.runtime.ComposerImpl$apply$operation$1.invoke(Composer.kt:1619) at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:808) at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:839) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:585) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:503) at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34) at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1228) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1238) at android.view.Choreographer.doCallbacks(Choreographer.java:898) at android.view.Choreographer.doFrame(Choreographer.java:826) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1213) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7892) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [[email protected], [email protected], StandaloneCoroutine{Cancelling}@ff31a27, [email protected]]

    question android 
    opened by serrg1994 22
Releases(v1.3.0-beta04-dev871)
Owner
JetBrains
JetBrains open source projects
JetBrains
FirestoreCleanArchitectureApp is an app built with Kotlin and Firestore that displays data in real-time using the MVVM Architecture Pattern. For the UI it uses Jetpack Compose, Android's modern toolkit for building native UI.

FirestoreCleanArchitectureApp FirestoreCleanArchitectureApp is an app built with Kotlin and Cloud Firestore that displays data in real-time using Andr

Alex 64 Nov 28, 2022
🎲 Kotlin Symbol Processor to auto-generate extensive sealed classes and interfaces for Android and Kotlin.

SealedX ?? Kotlin Symbol Processor to auto-generate extensive sealed classes and interfaces for Android and Kotlin. Why SealedX? SealedX generates ext

Jaewoong Eum 234 Nov 18, 2022
Simple Kotlin application that displays the currently available network interfaces on your machine

Network-Interface-Checker Simple Kotlin application that displays the currently available network interfaces on your machine. An executable jar can be

Joshua Soberg 3 Jun 10, 2022
A clone of hn.premii.com implemented in KMP with Web (React), iOS (Swift UI), Android and Desktop (Compose) UIs

An clone of hn.premii.com implemented in Kotlin Multiplatform with shared Android/Desktop Compose UI, SwiftUI on iOS and React for Web This example su

Tarek Belkahia 7 Feb 5, 2022
Building Web Applications with React and Kotlin JS Hands-On Lab

Building Web Applications with React and Kotlin JS Hands-On Lab This repository is the code corresponding to the hands-on lab Building Web Application

Brian Donnoe 0 Nov 13, 2021
Scaloid makes your Android code easy to understand and maintain.

Simpler Android Scaloid is a library that simplifies your Android code. It makes your code easy to understand and maintain by leveraging Scala languag

Sung-Ho Lee 2.1k Nov 23, 2022
A modular framework for building Discord bots in Kotlin using Kordex and Kord

Mik Bot A modular framework for building Discord bots in Kotlin using Kordex and Kord **If you are here for mikmusic, click here and there Deployment

Michael Rittmeister 30 Nov 23, 2022
KVision allows you to build modern web applications with the Kotlin language

KVision allows you to build modern web applications with the Kotlin language, without any use of HTML, CSS or JavaScript. It gives you a rich hierarchy of ready to use GUI components, which can be used as builder blocks for the application UI.

Robert Jaros 966 Nov 26, 2022
Web Container: A simple web container library for Android to help fellow developer to open WebView easily

WebContainer Description Web Container is a simple web container library for And

Achmad Ichsan Thaib 8 Nov 22, 2022
Template for a modern spring web service.

Spring Service Scaffold A scaffold for a web service operating with a Spring Framework backend, reactjs as frontend and a continuous testing and build

null 0 Nov 15, 2021
🛒 Mercado Libre App Clone using modern Android development with Hilt, Coroutines, Jetpack (Room, ViewModel), and Jetpack Compose based on MVVM architecture.

Meli Clone ?? Mercado Libre App Clone using modern Android development with Hilt, Coroutines, Jetpack (Room, ViewModel), and Jetpack Compose based on

Esteban Aragon 7 Sep 22, 2022
Consumer desktop from nutrition-framework API

About This Project (work-in-progress ?? ??️ ??‍♀️ ⛏ ) Consumer Dari Nutrition Framework General Framework for Application Development Around Nutrition

Faisal Amir 5 Jul 13, 2022
A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations.

kotlin-ktor-rest-api A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations. F

Selim Atasoy 31 Nov 7, 2022
Ktor is an asynchronous framework for creating microservices, web applications and more.

ktor-sample Ktor is an asynchronous framework for creating microservices, web applications and more. Written in Kotlin from the ground up. Application

mohamed tamer 5 Jan 22, 2022
A TODO list app with location reminders that remind the user to do something when the user is at a specific location

Project Title Location Reminder Getting Started A TODO list app with location reminders that remind the user to do something when the user is at a spe

Raghav Saboo 0 Dec 5, 2021
Build with Jetpack Compose & all modern techniques and architecture of android app development

IMDB Movie App Build with Jetpack Compose & all modern techniques and architecture of android app development ScreenShots ?? Built With ?? Kotlin - Fi

Jayant Kumar 6 Oct 24, 2022
Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture

Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture. I built this so that programmers learning Jetpack Compose Can use this repository as a learning material for Jetpack Compose.

Somnath Mishra 46 Oct 30, 2022
A project that takes advantage of docker and makes the load test easier

Performance Test It's a project that takes advantage of docker and makes the load test easier. Also, it collects metrics from each running container.

jorge cabrera 1 Dec 9, 2021
A Tachidesk Desktop UI built in JetBrains Compose

TachideskJUI A free and open source manga reader to read manga from a Tachidesk server. TachideskJUI can run the Tachidesk server on its own, or conne

null 209 Nov 22, 2022