Status Update
Comments
ch...@google.com <ch...@google.com> #2
Thanks for reporting this on the issue tracker.
Note that the two constructors that you are comparing are likely not the same constructor from the original app. Indeed, the one in good smali.png
is assigning the parameters to the instance fields, but the one in bad smali.png
is creating an instance of org.jsoup.parser.d
and assigning it to an instance field.
This is most likely explained by R8 merging a class from org.jsoup.parser
with your class PickupStepViewHelper_Factory
.
In order to diagnose this issue, it would be great if you could generate a zip dump of the inputs to R8 by running the below command (on the revision of the app that has the bug).
./gradlew assembleRelease --no-daemon -Dcom.android.tools.r8.dumpinputtodirectory=/path/to/dumps
This contains the class files, keep rules, etc. from the app and should allow us to reproduce the build.
It would be great if you could also share the resulting APK so that we can reproduce the stack trace and try to understand what might be causing this.
You can share this privately with
ca...@careem.com <ca...@careem.com> #3
Hi thanks for your reply. I will be happy to generate this for you and send it over.
FYI, though, I am not able to reproduce the problem again even rebuilding the same code in the same conditions. I will share everything today. Thanks
ca...@careem.com <ca...@careem.com> #4
Hi, files have been shared with the above emails. We were finally able to reproduce the issue with an old Gradle cache so hopefully you are able to see the issue with the shared files.
One detail I forgot to share if relevant at all, but I doubt. the build was generated with the new experimental dex layout optimization:
experimentalProperties["android.experimental.r8.dex-startup-optimization"] = true
ch...@google.com <ch...@google.com> #5
Thanks for sharing the relevant artifacts.
I was unable to reproduce the issue from launching the APK from the rebuild-old-cache-broken!
directory. Would it be possible for you to share the steps needed to reproduce the crash on a device?
I also tried building the dump (dump841321845439500.zip
) in the same folder to validate if I got the same DEX files out of this as in the above APK. Building this dump artifact leads to 6 DEX files (excluding the desugared library DEX file), but the broken APK has 9 DEX files (including the desugared library DEX file).
I then checked the compilation marker of the APK, which reveals that the APK is apparently built using D8 version 2.1.7-r1 (??), but the dump shows that you are using R8 version 8.2.33 for shrinking.
(Note that when you run D8 on the DEX generated by R8 you ruin the DEX startup optimization).
Another strange thing is that the desugared library file in your APK is classes3.dex
instead of classes9.dex
.
Could you maybe shed some light on what is happening here?
ca...@careem.com <ca...@careem.com> #6
Thanks for the detailed report.
About the dex number question I think I reproduced the problem which can explain also the weird D8 version problem:
we use a analytic tool called FullStory: they use a gradle plugin that instrument the code after is dexed/minified. Running the broken build without this tool, produced an APK with 6 dexes, and the smali in the apk looks correct.
I've uploaded the apk and the dumps inside the build-without-fullstory
folder in the shared Google Drive, if there is anything you want to look at, but I believe we can close this issue. I will report all the findings to them.
Thanks!
ch...@google.com <ch...@google.com> #7
Thanks for the update! Please don't hesitate to reopen this issue if you believe this is not caused by the FullStory instrumentation.
You may also want to make sure that FullStore uses a newer version of D8 and inform them that the tool is potentially breaking the dex startup optimization.
ca...@careem.com <ca...@careem.com> #8
Hi, sadly I think we need to reopen this issue. Today we got hit by this problem again. Fullstory has been disabled for about a couple of weeks now.
I am uploading a new set of files in the same Drive folder I have shared previously, in a zip file "new crash report.zip":
broken build CI
folder contains the original apk and mapping built from our CI we ended up shipping to production, including the de-obfuscated stacktraceworking local build
folder contains a local working rebuild of a different commit (but where the breaking code was not changed) together with the R8 dumps, apk, and mappingbroken build local - with baselines
folder contains the data for the build from the same commit that we shipped to production. it contains R8 dumps, apk, mapping and obfuscated stacktrace.broken build local - no baseline
same as above, but without baseline and startup layout optimization.smali broken build
where I highlight the point where the stacktrace throws the exceptionsmali working build
the smali from the working build where the code looks correct
additional notes: I could repro the crash constantly from a given commit but not from a different commit that had nothing to do with the breaking code. not sure whats going on but I cant find any way to find the problem on our side at this moment.
ch...@google.com <ch...@google.com>
ap...@google.com <ap...@google.com> #9
Branch: main
commit a56f115bd634e5dfc07cae900301e964254b78bd
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Tue Nov 28 17:50:50 2023
Reproduce incorrect field value propagation
Bug:
Change-Id: I98b238e0e057c4f3fc7a9aa245382f8f3257ff40
A src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/InstanceFieldsOnlyWrittenInInitializersWithSingleCallerPruningTest.java
ap...@google.com <ap...@google.com> #10
Branch: main
commit 84b4aa9a250732a33db9fe2424387093ab8f0c0e
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Nov 29 09:16:54 2023
Fix incorrect field value propagation
Bug:
Change-Id: I84e8b52e4e63b26da9220dd91b2ea983146b3ff3
M src/main/java/com/android/tools/r8/ir/analysis/fieldaccess/FieldAssignmentTracker.java
M src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
M src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/InstanceFieldsOnlyWrittenInInitializersWithSingleCallerPruningTest.java
ap...@google.com <ap...@google.com> #11
Branch: 8.2
commit 89b11dba9c7993adb5313dc5b6556f8fedcfc251
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Nov 29 11:31:50 2023
Reproduce incorrect field value propagation
Bug:
Change-Id: I98b238e0e057c4f3fc7a9aa245382f8f3257ff40
A src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/InstanceFieldsOnlyWrittenInInitializersWithSingleCallerPruningTest.java
ap...@google.com <ap...@google.com> #12
Branch: 8.2
commit 788b1b110e3504d645aa7ec247fee9e54a5b502a
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Nov 29 11:34:23 2023
Fix incorrect field value propagation
Bug:
Change-Id: I84e8b52e4e63b26da9220dd91b2ea983146b3ff3
M src/main/java/com/android/tools/r8/ir/analysis/fieldaccess/FieldAssignmentTracker.java
M src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
M src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/InstanceFieldsOnlyWrittenInInitializersWithSingleCallerPruningTest.java
ap...@google.com <ap...@google.com> #13
Branch: 8.2
commit 4d2724a59db24b5ea81ca9c8e534a45823c790de
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Nov 29 11:34:46 2023
Version 8.2.39
Bug:
Change-Id: I1e9bc6865f27ec2aaa80c67be723ac39f8227a5b
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #14
Branch: 8.1
commit cc4b07ee6d805eb0f25c73e39f0fc7691a5155a9
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Nov 29 11:26:57 2023
Version 8.1.74
Bug:
Change-Id: I0c03d99013362467a8dbf02457f2096bcecd428d
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #15
Branch: 8.1
commit f71c764804308bbb4c0ed59a42728f5ab30235db
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Wed Nov 29 11:25:08 2023
Reproduce incorrect field value propagation
Bug:
Change-Id: I98b238e0e057c4f3fc7a9aa245382f8f3257ff40
M src/test/java/com/android/tools/r8/TestParameters.java
A src/test/java/com/android/tools/r8/ir/optimize/membervaluepropagation/InstanceFieldsOnlyWrittenInInitializersWithSingleCallerPruningTest.java
ch...@google.com <ch...@google.com> #16
This should be fixed in R8 version 8.2.39. You can build with this version by making the following changes to settings.gradle
.
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
}
dependencies {
classpath("com.android.tools:r8:8.2.39")
}
}
}
Remember to remove this again when AGP bundles a newer version of R8 than this (e.g., AGP 8.2.1, AGP 8.3.0).
ca...@careem.com <ca...@careem.com> #17
thanks! updated locally and I will let you know if anything happens. thanks for your time.
FYI 8.2.39 is not available in the tags list here
sg...@google.com <sg...@google.com> #18
Tag for 8.2.39 pushed as well.
an...@google.com <an...@google.com> #19
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 Hedgehog | 2023.1.1 Patch 1
- Android Gradle Plugin 8.2.1
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!
so...@google.com <so...@google.com> #20
Comment added by automation: A postmortem has been automatically requested for this issue. Please author a postmortem on IRM. See go/android-postmortem-guidance for more context and details, including how to handle the case when this issue does not need a postmortem. If you have any questions not answered by go/android-postmortem-guidance, please email android-hygiene-tpm@, instead of reassigning the fixed bug. Thank you.
Description
Hello, we recently had a broken build resulting in a runtime ClassCastException (
org.jsoup.parser.e cannot be cast to cx2.a
).And this looked weird as the crashing code and module itself (the code comes from an internally published library) has no reference to any
org.jsoup.*
code. (see attachmentoriginal.png
from the class contained in the aar)Looking at the stack trace I opened the smali in the broken apk and I indeed found references of
org.jsoup
class in the primary constructor (attachmentbroken smali.png
) which is odd.Trying to reproduce the problem rebuilding the same code with same configuration the resulted smali in the apk it looks correct (attachment
good smali.png
)I am not sure how I can collect more informations here but I felt I had to file an issue with the little I have. I can privately share the APK and mapping file if needed.
Please note we just updated AGP from 8.1.1 to 8.2.0-rc01 and so R8 (but I am not sure which version is used)