Giter Club home page Giter Club logo

Comments (8)

DatL4g avatar DatL4g commented on August 17, 2024

Yes read, write and execute permission is needed, so you have to use an install directory capable of these for the user.

You could use my tooling library, which takes care of it for each platform, take a look at #2

from kcef.

tomastiminskas avatar tomastiminskas commented on August 17, 2024

@DatL4g I'm using your Tooling library. The only difference I see with the example on the ticket are the jvmArgs in the build.gradle file. I was using this:

jvmArgs("--add-opens", "java.desktop/sun.awt=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/java.awt.peer=ALL-UNNAMED")

if (System.getProperty("os.name").contains("Mac")) {
     jvmArgs("--add-opens", "java.desktop/sun.lwawt=ALL-UNNAMED")
     jvmArgs("--add-opens", "java.desktop/sun.lwawt.macosx=ALL-UNNAMED")
}

instead of this:

jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/sun.awt=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/sun.java2d=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/java.awt.peer=ALL-UNNAMED")

if (System.getProperty("os.name").contains("Mac")) {
     jvmArgs("--add-opens", "java.desktop/sun.lwawt=ALL-UNNAMED")
     jvmArgs("--add-opens", "java.desktop/sun.lwawt.macosx=ALL-UNNAMED")
}

Could that be the cause of the issue on Windows?

from kcef.

DatL4g avatar DatL4g commented on August 17, 2024

It's possible, can't tell for sure as this are jcef requirements and I don't have a deep insight
I recommend to use my implementation as it has no downside

from kcef.

tomastiminskas avatar tomastiminskas commented on August 17, 2024

@DatL4g ok I will test and let you know. I'm actually using your implementation. I'm just confused about one thing, in the ticket you linked in a previous comment you said we should use this:

val appWriteableRootFolder = Tooling.getApplicationWriteableRootFolder("your-app-name") ?: File("./")
val kcefInstallDir = File(appWriteableRootFolder, "kcef-bundle")

But later on the ticket you mentioned a full example of the burningseries project and when looking at the code I'm seeing you are using:

File(AppIO.getWriteableExecutableFolder(), "kcef-bundle")

and inside that class you are not using Tooling.getApplicationWriteableRootFolder. Should I use Tooling library or try a similar implementation than the one on AppIO class?

Thanks

from kcef.

DatL4g avatar DatL4g commented on August 17, 2024

The burning series project is just a bit older and the tooling library didn't exist back then. However the implementation is the same.

from kcef.

tomastiminskas avatar tomastiminskas commented on August 17, 2024

@DatL4g got it, thanks. I will test again with the changes on jvmArgs and let you know

from kcef.

tomastiminskas avatar tomastiminskas commented on August 17, 2024

@DatL4g I'm still getting "restart required" callback when not running app as an administrator. If I run as an administrator everything worked perfect. I will copy my code here in case you see something that might be causing the issues:

KCEF initialization

@Composable
fun WebViewInitializing(
    dashboardViewModel: DashboardViewModel
) {
    if (dashboardViewModel.isWebViewLoading()) {
        return
    }

    println("WEBVIEW LOADING")

    // Init WebView
    var restartRequired by remember { mutableStateOf(false) }
    var error by remember { mutableStateOf("") }
    var downloading by remember { mutableStateOf(0F) }
    var initialized by remember { mutableStateOf(false) } // if true, KCEF can be used to create clients, browsers etc
    val isDebug = false

    LaunchedEffect(Unit) {
        withContext(Dispatchers.IO) { // IO scope recommended but not required

            val kcefInstallDir = if (isDebug) {
                File("kcef-bundle")
            } else {
                val rootFolder = Tooling.getApplicationWriteableRootFolder("Sphinx") ?: File("./")
                File(rootFolder, "kcef-bundle")
            }

            KCEF.init(
                builder = {
                    installDir(kcefInstallDir)

                    progress {
                        onDownloading {
                            downloading = it
                            dashboardViewModel.setWebViewState(DashboardViewModel.WebViewState.Loading)
                        }
                        onInitialized {
                            dashboardViewModel.setWebViewState(DashboardViewModel.WebViewState.Initialized)
                            toast("Finished loading WebView library")
                            initialized = true
                        }
                    }
                },
                onError = {
                    error = it?.localizedMessage ?: ""
                    dashboardViewModel.setWebViewState(DashboardViewModel.WebViewState.Failed)
                    toast(error)
                },
                onRestartRequired = {
                    restartRequired = true
                    dashboardViewModel.setWebViewState(DashboardViewModel.WebViewState.Failed)
                    toast("Restart Required")
                }
            )
        }
    }
}

build.gradle.kts

import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import java.io.FileInputStream
import java.util.*

plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose") version "1.5.11"
}

group = "chat.sphinx"
version = "1.0"

repositories {
    mavenCentral()
    maven(url = "https://jitpack.io")
    maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
    maven(url = "https://jogamp.org/deployment/maven")
}

kotlin {
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
        }
        withJava()
    }

    sourceSets {
        val jvmMain by getting {
            val kmpTorBinaryVersion = "0.4.7.8"
            val korauVersion = "3.2.0"
            val korioVersion = "3.2.0"

            dependencies {
                implementation(project(":common"))
                implementation(compose.desktop.currentOs)
                api(compose.preview)
                
                implementation("dev.datlag:kcef:2023.10.13")
                implementation("dev.datlag.tooling:tooling:1.1.0")
                implementation("io.matthewnelson.kotlin-components:kmp-tor-binary-linuxx64:$kmpTorBinaryVersion")
                implementation("io.matthewnelson.kotlin-components:kmp-tor-binary-macosx64:$kmpTorBinaryVersion")
                implementation("io.matthewnelson.kotlin-components:kmp-tor-binary-mingwx64:$kmpTorBinaryVersion")
                implementation("com.soywiz.korlibs.korio:korio:$korioVersion")
                implementation("com.soywiz.korlibs.korau:korau:$korauVersion")
                implementation("org.jetbrains.compose.ui:ui-graphics:1.5.1")
                implementation("uk.co.caprica:vlcj:4.7.1")
                

//                implementation ("com.github.skydoves:landscapist-glide:1.3.6")
//                implementation ("io.coil-kt:coil-compose:1.4.0")
            }
        }
        val jvmTest by getting
    }
}

compose.desktop {

    application {
        mainClass = "MainKt"

        jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
        jvmArgs("--add-opens", "java.desktop/sun.awt=ALL-UNNAMED")
        jvmArgs("--add-opens", "java.desktop/sun.java2d=ALL-UNNAMED")
        jvmArgs("--add-opens", "java.desktop/java.awt.peer=ALL-UNNAMED")

        if (System.getProperty("os.name").contains("Mac")) {
            jvmArgs("--add-opens", "java.desktop/sun.lwawt=ALL-UNNAMED")
            jvmArgs("--add-opens", "java.desktop/sun.lwawt.macosx=ALL-UNNAMED")
        }

        buildTypes {
            release {
                proguard {
                    configurationFiles.from(file("compose-desktop.pro"))
                }
            }
        }

        nativeDistributions {
            // Modules suggested by suggestRuntimeModules (avoids the ClassNotFoundException)
            modules("java.instrument", "java.management", "java.prefs", "java.sql", "jdk.unsupported")
            includeAllModules = true

            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "Sphinx"
            packageVersion = "1.0.23"

            val sphinxProperties = Properties().apply {
                val localPropertiesFile = project.file("../local.properties")
                if (localPropertiesFile.exists()) {
                    load(FileInputStream(localPropertiesFile))
                }
            }

            val macOsBundleID = sphinxProperties.getProperty("macOs.bundleID")
            val macOsSigningIdentity = sphinxProperties.getProperty("macOs.signing.identity")

            macOS {
                if (macOsBundleID?.isNotEmpty() == true) {
                    bundleID = macOsBundleID
                }

                signing {
                    if (macOsSigningIdentity?.isNotEmpty() == true) {
                        sign.set(true)
                        identity.set(macOsSigningIdentity)
                    }
                }
                iconFile.set(project.file("sphinx-logo.icns"))
            }
            windows {
                iconFile.set(project.file("sphinx-logo-64.ico"))
                dirChooser = true
            }
            linux {
                iconFile.set(project.file("sphinx-logo.png"))
            }
        }
    }
}

Any ideas?

from kcef.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.