RUMM-1580: Fix SDK initialization crash on KitKat for a minified build due to DexVerifier rejecting opcode#690
Conversation
|
|
||
| override fun onActivityPostResumed(activity: Activity) { | ||
| super.onActivityPostResumed(activity) | ||
| // this method doesn't call super, because having super call creates a crash |
There was a problem hiding this comment.
Wouldn't that break the behavior on recent version of the OS ? Instead maybe we could have an
if (Version > KitKat) {
super.onActivityPostResumed(activity)
// …
}
There was a problem hiding this comment.
it won't break, since onActivityPostResumed in super is empty. Version check doesn't help as I've stated in the PR description.
There was a problem hiding this comment.
I'm still concerned as the super implementation might not be empty in future versions of Android. I don't see any simple way to mitigate this, except maybe creating an ActivityViewTrackingStrategyKitKat class which will be 99.99% the same. Let's keep your fix for now, and keep this in mind for future Android versions
There was a problem hiding this comment.
Yes, forward compatibility can be a concern. I'm not sure if ActivityViewTrackingStrategyKitKat would work though, because it means that both ActivityViewTrackingStrategyKitKat and ActivityViewTrackingStrategyLollipop will be referenced from the same class in the import statement, and it means DexVerifier will still go through the class with super call during class load process.
Alternatively we can just schedule dropping KitKat support in the future.
Codecov Report
@@ Coverage Diff @@
## master #690 +/- ##
============================================
- Coverage 88.63% 88.34% -0.29%
+ Complexity 1709 1650 -59
============================================
Files 189 184 -5
Lines 5645 5411 -234
Branches 695 672 -23
============================================
- Hits 5003 4780 -223
+ Misses 407 400 -7
+ Partials 235 231 -4
|
|
|
||
| override fun onActivityPostResumed(activity: Activity) { | ||
| super.onActivityPostResumed(activity) | ||
| // this method doesn't call super, because having super call creates a crash |
There was a problem hiding this comment.
I'm still concerned as the super implementation might not be empty in future versions of Android. I don't see any simple way to mitigate this, except maybe creating an ActivityViewTrackingStrategyKitKat class which will be 99.99% the same. Let's keep your fix for now, and keep this in mind for future Android versions
1fa13e8 to
f633bdb
Compare
f633bdb to
87365c1
Compare
What does this PR do?
Fixes #678. Crash happens only on KitKat with minified build due to
DexVerfierrejecting bytecode of the classActivityViewTrackingStrategy, specifically bytecode of this linedd-sdk-android/dd-sdk-android/src/main/kotlin/com/datadog/android/rum/tracking/ActivityViewTrackingStrategy.kt
Line 72 in 3493382
Error says:
Opcode
0x6fcorresponds to the super invocation. There is nothing special about this opcode, I can see other instances of this opcode being successfully replaced instead of being rejected. And this error happens only on KitKat (hence Dalvik), it doesn't repro with newer APIs (ART).Not sure why it happens, probably there is something special about backporting
default(onActivityPostResumedis adefaultmethod) methods to the pre-Lollipop APIs, but the easiest fix is just to removesupercall and it is safe to do with current inheritance hierarchy because default implementation is just empty.Things like using
RequiresApi,TargetApi, wrapping in build version check condition didn't help. Adding ProGuard instructions also didn't help: APK explorer shows that the necessary class and method are there, but app still crashes.Review checklist (to be filled by reviewers)