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

java.lang.VerifyError when running release build #3387

Closed
mipastgt opened this issue Jul 21, 2023 · 8 comments · Fixed by JetBrains/compose-multiplatform-core#706
Closed
Assignees
Labels
bug Something isn't working p:high High priority regression reproduced

Comments

@mipastgt
Copy link

Describe the bug
I have just upgraded my Compose multiplatform project (desktop & android) to Kotlin 1.9.0 and Compose 1.5.0-dev1114. This works without problems when I run from the IDE or when I execute the gradle task 'runDistributable'. But when I try to execute 'runReleaseDistributable' the build part works fine too but the program crashes immediately with:

Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    androidx/compose/animation/core/AnimationSpecKt.estimateAnimationDurationMillis(FFFFF)J @604: dstore
  Reason:
    Type top (current frame, locals[68]) is not assignable to double (stack map, locals[68])

See the full output in the attachment. What I find strange too is that the location is pointing to AnimationSpecKt but the error happens already when I parse the command line parameters of the main program.

This all worked before with Kotlin 1.8.22 and Compose 1.5.0-dev1104.

Affected platforms
Select one of the platforms below:

  • Desktop

Versions

  • Kotlin version*: 1.9.0
  • Compose Multiplatform version*: 1.5.0-dev1114
  • OS version(s)* (required for Desktop and iOS issues): macOS Ventura 13.4.1
  • OS architecture (x86 or arm64): x86
  • JDK (for desktop issues): OpenJDK 17.0.7+7

To Reproduce
Sorry, no reproducer.

Expected behavior
The release should work the same way as the non-release version.

output.txt.zip

@mipastgt mipastgt added bug Something isn't working submitted labels Jul 21, 2023
@mipastgt
Copy link
Author

Just switching back to Kotlin 1.8.22 doesn't make a difference. Only when I also switch back to Compose 1.5.0-dev1103 the release build works again.

@pjBooms pjBooms removed the submitted label Jul 21, 2023
@pjBooms
Copy link
Contributor

pjBooms commented Jul 21, 2023

Can you try to disable proguard for runReleaseDistributable? Will it help?

@pjBooms
Copy link
Contributor

pjBooms commented Jul 21, 2023

The problem is reproduced on https://github.com/JetBrains/compose-multiplatform-template

@pjBooms pjBooms added regression p:high High priority labels Jul 21, 2023
@mipastgt
Copy link
Author

Can you try to disable proguard for runReleaseDistributable? Will it help?

How do you do that correctly? Might be helpful for other reasons too.

@pjBooms
Copy link
Contributor

pjBooms commented Jul 21, 2023

How do you do that correctly? Might be helpful for other reasons too.

compose.desktop {
    application {
        buildTypes.release.proguard {
            isEnabled.set(false)
        }
    }
}

@mipastgt
Copy link
Author

With ProGuard disabled the release build seems to run as it did before.

AlexeyTsvetkov added a commit that referenced this issue Jul 21, 2023
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Jul 24, 2023
Fixes JetBrains/compose-multiplatform#3387

It is probably a bug of proguard, it can't properly inline variables in some cases.

## Test
export COMPOSE_CUSTOM_VERSION=46436.333.66
./gradlew :mpp:publishComposeJbToMavenLocal -Pcompose.platforms=jvm

Open https://github.com/JetBrains/compose-multiplatform-desktop-template

Insert this code:
```
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.material.Text
import androidx.compose.ui.window.singleWindowApplication

fun main() {
    singleWindowApplication {
        AnimatedVisibility(true) {
            Text("SDg")
        }
    }
}
```
./gradlew runReleaseDistributable

It runs without crashes after the fix. Before the fix it crashes with the crash:
```
Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    androidx/compose/animation/AnimatedVisibilityKt.estimateAnimationDurationMillis(FFFFF)J @504: dload
```
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Jul 25, 2023
Fixes JetBrains/compose-multiplatform#3387

It is probably a bug of proguard, it can't properly inline variables in some cases.

## Test
export COMPOSE_CUSTOM_VERSION=46436.333.66
./gradlew :mpp:publishComposeJbToMavenLocal -Pcompose.platforms=jvm

Open https://github.com/JetBrains/compose-multiplatform-desktop-template

Insert this code:
```
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.material.Text
import androidx.compose.ui.window.singleWindowApplication

fun main() {
    singleWindowApplication {
        AnimatedVisibility(true) {
            Text("SDg")
        }
    }
}
```
./gradlew runReleaseDistributable

It runs without crashes after the fix. Before the fix it crashes with the crash:
```
Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    androidx/compose/animation/AnimatedVisibilityKt.estimateAnimationDurationMillis(FFFFF)J @504: dload
```
AlexeyTsvetkov added a commit that referenced this issue Jul 26, 2023
* Add DSL flag to control ProGuard's optimizations

#3387

* Update default ProGuard version

* Revert ProGuard default version to 7.2.2.
@AlexeyTsvetkov
Copy link
Collaborator

The issue report in ProGuard repo Guardsquare/proguard#349

@mrjameshamilton
Copy link
Contributor

mrjameshamilton commented Jul 26, 2023

In-case useful for anyone with similar issues: instead of disabling ProGuard completely you can disable parts of ProGuard, or specify that specific methods should not be optimized in the ProGuard configuration:

  • -dontoptimize -> turn off optimization, but still allow shrinking (tree shaking) and name obfuscation
  • includecode modifier in keep rules e.g. -keep,includecode class myClass { *; } => this tell ProGuard ProGuard not to optimize code. You can also still enable shrinking and obfuscation: -keep,includecode,allowshrinking,allowobfuscation class myClass { *; }
  • -optimizations with negations to turn off specific optimizations that cause problems e.g. -optimizations !class/unboxing/enum ; see the manual page for a full list of optimizations.

igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 15, 2023
…tions. (#706)

Fixes JetBrains/compose-multiplatform#3387

It is probably a bug of proguard, it can't properly inline variables in some cases.

## Test
export COMPOSE_CUSTOM_VERSION=46436.333.66
./gradlew :mpp:publishComposeJbToMavenLocal -Pcompose.platforms=jvm

Open https://github.com/JetBrains/compose-multiplatform-desktop-template

Insert this code:
```
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.material.Text
import androidx.compose.ui.window.singleWindowApplication

fun main() {
    singleWindowApplication {
        AnimatedVisibility(true) {
            Text("SDg")
        }
    }
}
```
./gradlew runReleaseDistributable

It runs without crashes after the fix. Before the fix it crashes with the crash:
```
Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    androidx/compose/animation/AnimatedVisibilityKt.estimateAnimationDurationMillis(FFFFF)J @504: dload
```
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Nov 16, 2023
…tions. (#706)

Fixes JetBrains/compose-multiplatform#3387

It is probably a bug of proguard, it can't properly inline variables in some cases.

## Test
export COMPOSE_CUSTOM_VERSION=46436.333.66
./gradlew :mpp:publishComposeJbToMavenLocal -Pcompose.platforms=jvm

Open https://github.com/JetBrains/compose-multiplatform-desktop-template

Insert this code:
```
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.material.Text
import androidx.compose.ui.window.singleWindowApplication

fun main() {
    singleWindowApplication {
        AnimatedVisibility(true) {
            Text("SDg")
        }
    }
}
```
./gradlew runReleaseDistributable

It runs without crashes after the fix. Before the fix it crashes with the crash:
```
Exception in thread "main" java.lang.VerifyError: Instruction type does not match stack map
Exception Details:
  Location:
    androidx/compose/animation/AnimatedVisibilityKt.estimateAnimationDurationMillis(FFFFF)J @504: dload
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p:high High priority regression reproduced
Projects
None yet
4 participants