Guardsquare / proguard

ProGuard, Java optimizer and obfuscator
https://www.guardsquare.com/en/products/proguard
GNU General Public License v2.0
2.91k stars 415 forks source link

Invalid instruction offset #311

Open wakaztahir opened 1 year ago

wakaztahir commented 1 year ago

https://github.com/JetBrains/compose-jb/issues/2650

wakaztahir commented 1 year ago

hitting this exception when proguard runs

Unexpected error while merging classes:
  Class        = [compose/icons/fluentuiicons/filled/GifKt]
  Target class = [androidx/compose/animation/SplineBasedDecayKt]
  Exception    = [java.lang.IllegalArgumentException] (Invalid instruction offset [298] in code with length [0])
Unexpected error
java.lang.IllegalArgumentException: Invalid instruction offset [298] in code with length [0]
    at proguard.classfile.editor.CodeAttributeEditor.replaceInstruction(CodeAttributeEditor.java:351) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.editor.InstructionWriter.replaceInstruction(InstructionWriter.java:289) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.editor.InstructionWriter.visitConstantInstruction(InstructionWriter.java:112) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.instruction.ConstantInstruction.accept(ConstantInstruction.java:181) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.editor.CodeAttributeComposer.appendInstruction(CodeAttributeComposer.java:346) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.editor.InstructionAdder.visitConstantInstruction(InstructionAdder.java:69) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.instruction.ConstantInstruction.accept(ConstantInstruction.java:181) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.attribute.CodeAttribute.instructionsAccept(CodeAttribute.java:175) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.attribute.CodeAttribute.instructionsAccept(CodeAttribute.java:147) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.editor.AttributeAdder.visitCodeAttribute(AttributeAdder.java:368) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:138) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:148) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.editor.MemberAdder.visitProgramMethod(MemberAdder.java:289) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:140) ~[proguard-core-9.0.1.jar:?]
    at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:695) ~[proguard-core-9.0.1.jar:?]
    at proguard.optimize.peephole.ClassMerger.visitProgramClass0(ClassMerger.java:260) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.optimize.peephole.ClassMerger.visitProgramClass(ClassMerger.java:145) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.classfile.ProgramClass.accept(ProgramClass.java:544) ~[proguard-core-9.0.1.jar:?]
    at proguard.optimize.peephole.HorizontalClassMerger.mergeInto(HorizontalClassMerger.java:145) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.optimize.peephole.HorizontalClassMerger.handleSiblings(HorizontalClassMerger.java:123) ~[proguard-base-7.2.2.jar:7.2.2]
    at java.util.HashMap$Values.forEach(HashMap.java:1065) ~[?:?]
    at proguard.optimize.peephole.HorizontalClassMerger.visitClassPool(HorizontalClassMerger.java:99) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.classfile.ClassPool.accept(ClassPool.java:277) ~[proguard-core-9.0.1.jar:?]
    at proguard.optimize.Optimizer.optimize(Optimizer.java:1186) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.optimize.Optimizer.execute(Optimizer.java:286) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.pass.PassRunner.run(PassRunner.java:24) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.ProGuard.optimize(ProGuard.java:448) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.ProGuard.execute(ProGuard.java:193) ~[proguard-base-7.2.2.jar:7.2.2]
    at proguard.ProGuard.main(ProGuard.java:623) [proguard-base-7.2.2.jar:7.2.2]
package compose.icons.fluentuiicons.filled

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.ImageVector.Builder
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
import compose.icons.fluentuiicons.FilledGroup

public val FilledGroup.Gif: ImageVector
    get() {
        if (_gif != null) {
            return _gif!!
        }
        _gif = Builder(name = "Gif", defaultWidth = 24.0.dp, defaultHeight = 24.0.dp, viewportWidth
                = 24.0f, viewportHeight = 24.0f).apply {
            path(fill = SolidColor(Color(0xFF212121)), stroke = null, strokeLineWidth = 0.0f,
                    strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
                    pathFillType = NonZero) {
                moveTo(18.75f, 3.501f)
                curveTo(20.5449f, 3.501f, 22.0f, 4.956f, 22.0f, 6.751f)
                verticalLineTo(17.2536f)
                curveTo(22.0f, 19.0485f, 20.5449f, 20.5036f, 18.75f, 20.5036f)
                horizontalLineTo(5.25f)
                curveTo(3.4551f, 20.5036f, 2.0f, 19.0485f, 2.0f, 17.2536f)
                verticalLineTo(6.751f)
                curveTo(2.0f, 4.956f, 3.4551f, 3.501f, 5.25f, 3.501f)
                horizontalLineTo(18.75f)
                close()
                moveTo(8.0146f, 8.8724f)
                curveTo(6.3884f, 8.8724f, 5.261f, 10.2821f, 5.261f, 11.9947f)
                curveTo(5.261f, 13.708f, 6.3886f, 15.1207f, 8.0146f, 15.1207f)
                curveTo(8.9024f, 15.1207f, 9.7177f, 14.6936f, 10.1263f, 13.9068f)
                lineTo(10.2025f, 13.7446f)
                lineTo(10.226f, 13.675f)
                lineTo(10.244f, 13.6004f)
                lineTo(10.2516f, 13.5174f)
                lineTo(10.2518f, 11.9966f)
                lineTo(10.245f, 11.9043f)
                curveTo(10.2054f, 11.6364f, 9.9957f, 11.4239f, 9.7292f, 11.38f)
                lineTo(9.6268f, 11.3716f)
                horizontalLineTo(8.6252f)
                lineTo(8.5329f, 11.3784f)
                curveTo(8.265f, 11.4181f, 8.0525f, 11.6278f, 8.0086f, 11.8942f)
                lineTo(8.0002f, 11.9966f)
                lineTo(8.007f, 12.089f)
                curveTo(8.0467f, 12.3569f, 8.2563f, 12.5694f, 8.5228f, 12.6133f)
                lineTo(8.6252f, 12.6216f)
                lineTo(9.001f, 12.6214f)
                verticalLineTo(13.3554f)
                lineTo(8.9948f, 13.3699f)
                curveTo(8.8061f, 13.6908f, 8.4432f, 13.8707f, 8.0146f, 13.8707f)
                curveTo(7.1487f, 13.8707f, 6.511f, 13.0717f, 6.511f, 11.9947f)
                curveTo(6.511f, 10.9187f, 7.1479f, 10.1224f, 8.0146f, 10.1224f)
                curveTo(8.436f, 10.1224f, 8.6758f, 10.1686f, 8.9757f, 10.3126f)
                curveTo(9.2868f, 10.462f, 9.6602f, 10.3309f, 9.8096f, 10.0197f)
                curveTo(9.959f, 9.7086f, 9.8279f, 9.3352f, 9.5168f, 9.1858f)
                curveTo(9.0335f, 8.9537f, 8.6115f, 8.8724f, 8.0146f, 8.8724f)
                close()
                moveTo(12.6289f, 8.9944f)
                curveTo(12.3151f, 8.9944f, 12.0554f, 9.2256f, 12.0107f, 9.527f)
                lineTo(12.0039f, 9.6194f)
                verticalLineTo(14.3815f)
                lineTo(12.0107f, 14.4739f)
                curveTo(12.0554f, 14.7752f, 12.3151f, 15.0065f, 12.6289f, 15.0065f)
                curveTo(12.9427f, 15.0065f, 13.2025f, 14.7752f, 13.2472f, 14.4739f)
                lineTo(13.2539f, 14.3815f)
                verticalLineTo(9.6194f)
                lineTo(13.2472f, 9.527f)
                curveTo(13.2025f, 9.2256f, 12.9427f, 8.9944f, 12.6289f, 8.9944f)
                close()
                moveTo(17.6222f, 9.0013f)
                lineTo(15.6248f, 8.9944f)
                curveTo(15.311f, 8.9933f, 15.0504f, 9.2236f, 15.0047f, 9.5249f)
                lineTo(14.9976f, 9.6172f)
                verticalLineTo(14.3654f)
                lineTo(15.0044f, 14.4578f)
                curveTo(15.0441f, 14.7257f, 15.2537f, 14.9381f, 15.5202f, 14.9821f)
                lineTo(15.6226f, 14.9904f)
                lineTo(15.715f, 14.9836f)
                curveTo(15.9829f, 14.9439f, 16.1953f, 14.7343f, 16.2393f, 14.4678f)
                lineTo(16.2476f, 14.3654f)
                lineTo(16.247f, 13.2504f)
                lineTo(17.37f, 13.2508f)
                lineTo(17.4624f, 13.2441f)
                curveTo(17.7303f, 13.2044f, 17.9427f, 12.9947f, 17.9867f, 12.7282f)
                lineTo(17.995f, 12.6258f)
                lineTo(17.9882f, 12.5335f)
                curveTo(17.9485f, 12.2656f, 17.7389f, 12.0531f, 17.4724f, 12.0092f)
                lineTo(17.37f, 12.0008f)
                lineTo(16.247f, 12.0004f)
                verticalLineTo(10.2454f)
                lineTo(17.6178f, 10.2513f)
                lineTo(17.7102f, 10.2448f)
                curveTo(18.0118f, 10.2012f, 18.2439f, 9.9422f, 18.245f, 9.6284f)
                curveTo(18.2461f, 9.3146f, 18.0157f, 9.0541f, 17.7145f, 9.0084f)
                lineTo(17.6222f, 9.0013f)
                lineTo(15.6248f, 8.9944f)
                lineTo(17.6222f, 9.0013f)
                close()
            }
        }
        .build()
        return _gif!!
    }

private var _gif: ImageVector? = null
wakaztahir commented 1 year ago

Here's source code for SplineBasedDecay

https://androidx.tech/artifacts/compose.animation/animation/1.1.1-source/androidx/compose/animation/SplineBasedDecay.kt.html

mrjameshamilton commented 1 year ago

Advice given on JetBrains issue to add some -keep rules or disable class merging: https://github.com/JetBrains/compose-jb/issues/2650#issuecomment-1399961404

To solve the underlying issue a self-contained reproducing sample would help.

wakaztahir commented 1 year ago

To reproduce

The repo @Qawaz/compose-icons contains a package named fluentui-system-icons

The whole repo is very large , just copy this folder from the repo and create a android release from it

I am following the advice given by jetbrains till then