Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProGuard versions >= 7.4.0 make even trivial Compose desktop apps crash when optimizing #441

Open
mipastgt opened this issue Oct 12, 2024 · 2 comments

Comments

@mipastgt
Copy link

mipastgt commented Oct 12, 2024

I created a Compose desktop app template with the Jetbrains wizard and then just added a ProGuard configuration block to the build.gradle.kts

        buildTypes.release {
            proguard {
                // Versions "7.2.2" up to "7.3.0" work
                // Versions "7.4.0" up to "7.6.0" crash
                // When optimization is switched off, the newer versions work too.
                version.set("7.6.0")
                isEnabled.set(true)
                optimize.set(true)
                obfuscate.set(false)
            }
        }

With versions >= 7.4.0 the resulting app crashes with a

Exception in thread "DefaultDispatcher-worker-1" java.lang.VerifyError: Bad type on operand stack

This does not happen when ProGuard is disabled or optimization is switched off.
See attached error log and sample project.

In order to reproduce the problem with the attached sample project, you can just run the Gradle task :composeApp:runRelease which applies ProGuard to the build automatically.

I tested this on macOS 14.7 with Java 17.

I stumbled over this issue while I was trying to track down another ProGuard issue which may be related. See discussion on Slack
and #443

errors_log.txt.zip
ProGuardGeoError.zip

@mrjameshamilton
Copy link
Collaborator

Hi @mipastgt !

It looks like something is going wrong with method type specialization. As a workaround, you can disable that particular optimization if you don't want to disable all optimizations. I could build the sample by disabling the optimization with the following:

// build.gradle.kts
        buildTypes.release {
            proguard {
                version.set("7.6.0")
                isEnabled.set(true)
                optimize.set(true)
                obfuscate.set(false)
               // Add a configuration file.
		configurationFiles.from(project.file("compose-desktop.pro"))
            }
        }

// compose-desktop.pro
-optimizations !method/specialization/**

@mipastgt
Copy link
Author

Thanks, but normally I switch off optimizations anyway. I accidentally stumbled over this one with optimizations on.

The much more critical issue which I was actually investigating is this one: #443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants