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
16.33k stars 1.18k forks source link

Targeting Desktop MacOS using JVM-based libraries (Like VLCJ) crash when called at runtime with permissions error, runs fine in the IDE #4712

Closed realityexpander closed 2 months ago

realityexpander commented 7 months ago

Describe the bug

When attempting to build a MacOS Desktop target using the VLCJ library (per the example in the experimental folder), running it locally works as expected.

After creating all the proper settings and configurations for a signed App acceptance per Apple's instructions and successfully uploading of a build (which runs fine locally), and is accepted by Apple. The App is then made available in TestFlight for users to download.

Upon a user downloading an launching the App, everything works fine until accessing the VLCJ videoplayer, which causes a crash. The library is successfully loaded, but something else is causing a violation (permissions? library not signed?):

I am able to get any regular Kotlin-native library (for KMM/KMP) work fine on all platforms. It's just these libaries that link back to JVM somewhere... like VLCJ or WebView.

Please forgive my lack of proper terminology, I am an Android/iOS developer, MacOS desktop is totally new to me.

Affected platforms

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

Reference project and commit: https://github.com/realityexpander/CloudCoverUSA2/blob/37feae3c18c55591331c2981eb149b2ab3e84dd9/composeApp/src/commonMain/kotlin/App.kt#L471

Include a JVM library (like this:)

// build.graadle.kts (:composeApp)
desktopMain.dependencies {
            implementation(compose.desktop.currentOs)
            implementation(compose.desktop.common)
            implementation(libs.ktor.client.java)
            implementation(libs.coil.network.ktor)

            // for vlcj
            implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.8.0")
            implementation("uk.co.caprica:vlcj:4.8.2")
        }

Running locally (using composeDesktop:run, composeDesktop:runRelease) works great. composeDesktop:runDistributable and composeDesktop:runReleaseDistributable have never worked for me.

Target MacOS desktop using the packagePkg task. Everything signs properly and upload is accepted by Apple. Upon downloading and accessing the VLCJ component causes a crash at runtime, and these windows pop-up:

Screenshot 2024-04-26 at 3 27 46 PM Screenshot 2024-04-26 at 3 27 21 PM Screenshot 2024-04-26 at 3 27 53 PM

Expected behavior I expect the same behavior when running locally, ie: the VLCJ library has full functionality and does not crash at runtime after distribution via Apple TestFlight or production.

Screenshots Included above

Additional context Here's the log from the Cloud Cover USA 2 > Data > Library > Logs > Cloud Cover USA 2_debug.log

[0421/134207.769659:FATAL:mach_port_rendezvous.cc(148)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in org.jcef.jcef.helper.MachPortRendezvousServer.70484: Permission denied (1100)
[0421/134229.391927:FATAL:mach_port_rendezvous.cc(148)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in org.jcef.jcef.helper.MachPortRendezvousServer.70557: Permission denied (1100)
[0421/135312.446145:FATAL:mach_port_rendezvous.cc(148)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in org.jcef.jcef.helper.MachPortRendezvousServer.71147: Permission denied (1100)
[0421/140441.134448:FATAL:mach_port_rendezvous.cc(148)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in org.jcef.jcef.helper.MachPortRendezvousServer.72941: Permission denied (1100)
[0421/162047.433538:FATAL:mach_port_rendezvous.cc(148)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in org.jcef.jcef.helper.MachPortRendezvousServer.85663: Permission denied (1100)

here's the project I'm using: https://github.com/realityexpander/CloudCoverUSA2/blob/37feae3c18c55591331c2981eb149b2ab3e84dd9/composeApp/src/commonMain/kotlin/App.kt#L471

PS: I targeted iOS and use KMM/KMP libraries for video and it works on Desktop for arm64 macs with no problems.

okushnikov commented 3 months ago

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