So I've been building my Mac app on our CI and sud...
# compose-desktop
f
So I've been building my Mac app on our CI and suddenly my new Mac builds aren't launching and I see
Copy code
$ /Applications/MyApp.app/Contents/MacOS/MyApp
Error occurred during initialization of VM
Could not reserve enough space for code cache (245760K)
Locally, my app builds and runs just fine. However, I don't have the certs too sign it locally. Would anyone know what's up? I tried running a CI build using a commit from weeks ago that I know in the past has generated a perfectly normal executable/binary, and that still failed with the same error. So it's almost certainly due to some change on the CI machines, I'm just trying to narrow down what?
f
Ah right, I actually just tried that
Copy code
jvmArgs("-XX:InitialCodeCacheSize=160K", "-XX:ReservedCodeCacheSize=32M")
Built it locally, still runs fine. Built it on CI machines and I still get
Copy code
Error occurred during initialization of VM
Could not reserve enough space for code cache (32768K)
Hmm
It's both built using Temurin 17.0.6
o
@alexey.tsvetkov Alexey, perhaps you may suggest some steps/ideas to investigate the issue? Does
Copy code
compose.desktop {
    application {
        jvmArgs += listOf("-Xmx2G")  // <- this
    }
}
affect the packaged (+signed) distribution? Is it applied to the packaged distribution?
f
For what it's worth, I was poking through the code and noticed there's a log file in
build/compose/tmp/createDistributable.args.txt
that has
Copy code
--java-options
"'-XX:InitialCodeCacheSize=160K'"
--java-options
"'-XX:ReservedCodeCacheSize=32M'"
i.e. the settings I configured. That's for running
jpackage
(I think).
Also these are my Compose settings in
build.gradle.kts
Copy code
compose.desktop {
    application {
        mainClass = ""
        jvmArgs("-XX:InitialCodeCacheSize=160K", "-XX:ReservedCodeCacheSize=32M")

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = ""
            packageVersion = version as String
            modules("java.sql")

            macOS {
                bundleID = ""
                iconFile.set(project.file("image/.icns"))
            }
        }
    }
}
(with some strings redacted).
j
Just to clarify, you are building the app on the CI server and then running the app locally (not running the app on the CI server), right? Shot in the dark, but is it possible this is related to entitlements? Specifically, you mention that you don't have a signing key locally, are entitlements only enforced if the app is signed? https://github.com/iterate-ch/cyberduck/issues/13347 I have no reason to believe that's the issue, other than it coming up in my search results when I did a google search, so I thought I'd mention it.
f
Yeah I'm trying to run the app locally. That's interesting, let me try the entitlements file.
j
Specifically I'm wondering if the issue is not related to the CI server, but if your local machine got an update from Apple that started being more strict about the enforcement of entitlements for signed apps. That's exactly the type of thing Apple would randomly start enforcing in an update 😛
f
Wow yeah that did it. Thanks so much @jim Embarrassed to say I did not check the Google results that far down lol.
j
👍 Glad it's working for you! Happy composing!
s
@Franklin I'm encountering the same issue. How did you solve this?
f
Create a file
default.entitlements
or whatever you want to name it
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "<http://www.apple.com/DTDs/PropertyList-1.0.dtd>">
<plist version="1.0">
<dict>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
</dict>
</plist>
In your
build.gradle.kts
file add
Copy code
compose.desktop {
    application {
        mainClass = ""

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = ""
            packageVersion = version as String

            macOS {
                bundleID = ""
                iconFile.set(project.file(""))
                entitlementsFile.set(project.file("default.entitlements")) // <----------- this line
            }
        }
    }
}
s
All of these entitlements are required for compose desktop?
j
Those look like they are entitlements required to run a JVM. None of those look compose-specific. Compose for desktop just happens to use a JVM.
s
I've never even heard of entitlements. This is new to me. Thanks for the easy instructions. Giving it a shot now.
LOL you have to explicitly allow a JIT
110 Views