Status Update
Comments
ch...@google.com <ch...@google.com>
ch...@google.com <ch...@google.com> #2
I was able to reproduce the issue from the dump, with -dontobfuscate
and horizontal class merging disabled for easier debugging.
The method is replaced by throw null
since R8 cannot find any calls that can possible dispatch to it. I tried disassembling the example.apk
you shared. According to example.map
, the class ScImageRenderer
has been renamed to Fxe
. When I lookup the definition of this class in example.apk
, it has been made abstract. Presumably, R8 has not found any allocations of the class. This makes me wonder whether the class is only instantiated by reflection and you are missing a -keep
rule to specify this?
Stack trace where the method is converted to throw null
:
at com.android.tools.r8.graph.ProgramMethod.convertToThrowNullMethod(ProgramMethod.java:131)
at com.android.tools.r8.graph.ProgramMethod.convertToAbstractOrThrowNullMethod(ProgramMethod.java:110)
at com.android.tools.r8.optimize.argumentpropagation.ArgumentPropagatorOptimizationInfoPopulator.setOptimizationInfo(ArgumentPropagatorOptimizationInfoPopulator.java:192)
at com.android.tools.r8.optimize.argumentpropagation.ArgumentPropagatorOptimizationInfoPopulator.setOptimizationInfo(ArgumentPropagatorOptimizationInfoPopulator.java:172)
at com.android.tools.r8.optimize.argumentpropagation.ArgumentPropagatorOptimizationInfoPopulator.lambda$setOptimizationInfo$1(ArgumentPropagatorOptimizationInfoPopulator.java:114)
at com.android.tools.r8.graph.DexProgramClass.lambda$forEachProgramMethodMatching$12(DexProgramClass.java:289)
at com.android.tools.r8.graph.MethodCollection.lambda$forEachMethodMatching$0(MethodCollection.java:134)
at com.android.tools.r8.graph.MethodCollectionBacking.lambda$forEachMethod$0(MethodCollectionBacking.java:60)
at com.android.tools.r8.graph.MethodMapBacking.traverse(MethodMapBacking.java:105)
at com.android.tools.r8.graph.MethodCollectionBacking.forEachMethod(MethodCollectionBacking.java:57)
at com.android.tools.r8.graph.MethodCollectionBacking.forEachMethod(MethodCollectionBacking.java:53)
at com.android.tools.r8.graph.MethodCollection.forEachMethodMatching(MethodCollection.java:131)
at com.android.tools.r8.graph.DexProgramClass.forEachProgramMethodMatching(DexProgramClass.java:288)
at com.android.tools.r8.graph.DexProgramClass.forEachProgramMethod(DexProgramClass.java:283)
at com.android.tools.r8.optimize.argumentpropagation.ArgumentPropagatorOptimizationInfoPopulator.setOptimizationInfo(ArgumentPropagatorOptimizationInfoPopulator.java:114)
at com.android.tools.r8.optimize.argumentpropagation.ArgumentPropagatorOptimizationInfoPopulator.lambda$setOptimizationInfo$0(ArgumentPropagatorOptimizationInfoPopulator.java:96)
br...@snapchat.com <br...@snapchat.com> #3
Noted. I'll do some digging to see if in this scenario we are instantiating through reflection.
I saw some code paths which do instantiate the class normally, but they may be effectively dead and the only remaining code path is through reflection. It'd be surprising that we've made it this far with the underlying issue without trouble if that's the case.
ch...@google.com <ch...@google.com> #4
I just checked again, and in the APK you shared the Fxe
class is instantiated (and not abstract!). I will try to build locally again using 8.6.27 and check if the class is also not abstract then.
br...@snapchat.com <br...@snapchat.com> #5
I've confirmed that the class ScImageRenderer
is not instantiated through reflection. Instead, it's instantiated in ScRenderersFactory
ap...@google.com <ap...@google.com> #6
Branch: main
commit 59a0c5881f96319f413675a906eb6ecdb48e1454
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Sep 19 14:01:19 2024
Reproduce monomorphic method state for interface method
Bug:
Change-Id: I73e2e4fd08f6be0b3446306ec1f618c9b583b4b1
A src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationMultipleInterfacesSameMethodTest.java
ch...@google.com <ch...@google.com> #7
Sorry for the long turnaround, Ben. I expect this should be fixed by
br...@snapchat.com <br...@snapchat.com> #8
Landing in 8.7 is good enough for me. I've been testing that version and no other issue with that.
Tangential question,I saw from lastest commits that you may optimizing r8 runtime latency. Is that the case? Anything we can help test out there
ch...@google.com <ch...@google.com> #9
We recently made a couple of build speed improvements to the evaluation of -if
rules. This work aimed to improve the handling of rules on the form -if class * extends ... -keepclassmembers class * { <1> *; }
, which were found to have a high build speed overhead in the platform (-if
rule evaluation in general, but whether it is observable probably depends on whether you have some -if
rules that are expensive to evaluate.
As a side project Rico has been working recently on adding support for generating perfetto traces from R8 builds to get more insights into build speed.
You might also be interested to learn that Rico has integrated resource shrinking into R8, for improved conditional tracing from code to resources and resources to code that does not rely on -keep
rules. This enables optimizations that cross the code/resource boundary, such as inlining of resource values.
ap...@google.com <ap...@google.com> #10
Branch: main
commit 5b6302ecfe7cda525ee986a95a4e9ae9fdfce7d4
Author: Christoffer Adamsen <christofferqa@google.com>
Date: Wed Sep 25 20:26:43 2024
Fix incorrect marking of virtual dispatch as monomorphic
Bug:
Change-Id: I630cd716ff68358db764f46914d67d9bf6e5d0f7
M src/main/java/com/android/tools/r8/optimize/argumentpropagation/codescanner/VirtualRootMethodsAnalysisBase.java
M src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationMultipleInterfacesSameMethodTest.java
ap...@google.com <ap...@google.com> #11
Branch: 8.6
commit 011f0b2a889c83aea4759f336fd62b17cf926e7b
Author: Christoffer Adamsen <christofferqa@google.com>
Date: Thu Sep 26 08:53:14 2024
Reproduce monomorphic method state for interface method
Bug:
Change-Id: I73e2e4fd08f6be0b3446306ec1f618c9b583b4b1
A src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationMultipleInterfacesSameMethodTest.java
ap...@google.com <ap...@google.com> #12
Branch: 8.6
commit 2b3a2cb4adccf4b6b9416c12a59c3dc8554bdda4
Author: Christoffer Adamsen <christofferqa@google.com>
Date: Thu Sep 26 08:53:29 2024
Version 8.6.30
Bug:
Change-Id: Id790a144fe4303eb17956e9742422a11f119a7d4
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #13
Branch: 8.6
commit 609b08c4f31ef72693d3ae4ec0126ef4dde57181
Author: Christoffer Adamsen <christofferqa@google.com>
Date: Thu Sep 26 08:53:22 2024
Fix incorrect marking of virtual dispatch as monomorphic
Bug:
Change-Id: I630cd716ff68358db764f46914d67d9bf6e5d0f7
M src/main/java/com/android/tools/r8/optimize/argumentpropagation/codescanner/VirtualRootMethodsAnalysisBase.java
M src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationMultipleInterfacesSameMethodTest.java
ap...@google.com <ap...@google.com> #14
Branch: 8.7
commit ec658a4dc6645f81aec4726695db2a38cf639c47
Author: Christoffer Adamsen <christofferqa@google.com>
Date: Thu Sep 26 08:52:48 2024
Version 8.7.15
Bug:
Change-Id: I92012fe58ca364773e31c519467b4d57b2760d73
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #15
Branch: 8.7
commit 926bb9a8f16d7041e6228361109aff18563b0863
Author: Christoffer Adamsen <christofferqa@google.com>
Date: Thu Sep 26 08:52:29 2024
Reproduce monomorphic method state for interface method
Bug:
Change-Id: I73e2e4fd08f6be0b3446306ec1f618c9b583b4b1
A src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationMultipleInterfacesSameMethodTest.java
ap...@google.com <ap...@google.com> #16
Branch: 8.7
commit 92b2e6f776486711d56f4dba4a062a0f504d899c
Author: Christoffer Adamsen <christofferqa@google.com>
Date: Thu Sep 26 08:52:38 2024
Fix incorrect marking of virtual dispatch as monomorphic
Bug:
Change-Id: I630cd716ff68358db764f46914d67d9bf6e5d0f7
M src/main/java/com/android/tools/r8/optimize/argumentpropagation/codescanner/VirtualRootMethodsAnalysisBase.java
M src/test/java/com/android/tools/r8/optimize/argumentpropagation/ArgumentPropagationMultipleInterfacesSameMethodTest.java
ap...@google.com <ap...@google.com> #17
Branch: 8.6
commit 3e7a649cb272a32d0340704f95065e9ac62ee7cc
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Sep 26 11:02:09 2024
Version 8.6.31
Bug:
Change-Id: I7e1552c74a66402b24be54d4614756f4e1e4b12d
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #18
Branch: 8.7
commit 73275aa55540c922bdbafdd17d06faaf3849b5d0
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Sep 26 11:01:27 2024
Version 8.7.16
Bug:
Change-Id: Ib3a599336cc39331d38f22960c451f42916d0ccf
M src/main/java/com/android/tools/r8/Version.java
ch...@google.com <ch...@google.com> #19
Verified that ScImageRenderer.getName
no longer throws with 8.6.31.
an...@google.com <an...@google.com> #20
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Ladybug | 2024.2.1 Patch 2
- Android Gradle Plugin 8.7.2
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
Description
Background
We are seeing the following runtime crash:
Analaysis
Where the original code looks like the following:
In the final binary, the class
ScImageRenderer
is compiled intoJDe
and thegetName
method is replaced withthrows null
.I'll share a compiler dump over email