In analytics for our app we've noticed increased number of crashes for the getIntent().getExtras()
calls. It's intermittent and we can't replicate that.
Crashes come in two flavours:
12 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.os.Parcel.dataSize()' on a null object reference
13 at android.os.BaseBundle.<init>(BaseBundle.java:126)
14 at android.os.Bundle.<init>(Bundle.java:102)
15 at android.content.Intent.getExtras(Intent.java:5685)
and
12 Caused by: java.lang.IllegalArgumentException
13 at android.os.Parcel.nativeAppendFrom(Native Method)
14 at android.os.Parcel.appendFrom(Parcel.java:458)
15 at android.os.BaseBundle.<init>(BaseBundle.java:126)
16 at android.os.Bundle.<init>(Bundle.java:102)
17 at android.content.Intent.getExtras(Intent.java:5685)
Retrieving code is essentially as follows onResume() {... getIntent().getExtras() ...}
. We check if the bundle in not null but it crashes before that.
We do pass a custom parcelable but extensive unit tests are passing for marshalling and unmarshalling that.
Interesting stats for those crashes are that it mostly happen for Android 6+ (72% of sessions recorded with 95% of crashes happen there). Also unexpectedly crash rarely happens on Samsung devices (73% of sessions recorded with only 10% crashes happen for that manufacturer).
This crash contibutes ~0.15% to the app crashrate with a rising trend (probably because increasing number or users on API23+).
Anyone encountered something similar or has a solution already?
Late update but better than never. Crashes went away. Solution I used can be found here: How to marshall and unmarshall a Parcelable to a byte array with help of Parcel?
To be honest I've removed some unnecessary parcelling and unparcelling from our app which might have also helped but I think the former solution is the relevant one.