Status Update
Comments
no...@google.com <no...@google.com> #2
The crash started from content capture.
to...@gmail.com <to...@gmail.com> #3
So getting more and more crashes from this as more and more pixel users have updated.
What is needed to have this investigated and fixed ?
to...@gmail.com <to...@gmail.com> #4
Ok so I have a way to reproduce and there's a race somewhere with that capture call .... But I have no idea what is that capture things and when it runs.
On SDK 12L there's
public void setText(CharSequence text, BufferType type) {
setText(text, type, true, 0);
if (mCharWrapper != null) {
mCharWrapper.mChars = null;
}
}
That set the array to null.
So when reaching CharWrapper
(Called from TextUtils.writeToParcel
)
public String toString() {
return new String(mChars, mStart, mLength);
}
We end up with java.lang.NullPointerException: Attempt to get length of null array
since the array is null.
Sounds to me that allowing and putting null in a value and reading without check is an SDK issue that should be fixed, but since it's all internal it would be nice that the race introduced on latest Pixel was looked into also to stop those crashes.
I would have fixed that by reflexion but unfortunately:
Accessing hidden field Landroid/widget/TextView$CharWrapper;->mChars:[C (max-target-o, reflection, denied)
So I'm stuck.
This happens sometimes for still to be discovered reason when updating the text from a child of AppCompatTextView (With emoji disabled)
One way to force the issue is from onSizeChanged
to mainHandler.post { text = "AAA" }
I guess no proper ellipsis for Pixel phones for now.
to...@gmail.com <to...@gmail.com> #5
Ok so after some fresh air, this is the same issue as emoji but triggered by my code.
Once a TextView have it's text set via setText(char[] text, int start, int len)
it must not be set again via any other setText
methods as the mCharWrapper reset is wrongly done and will fail on some calls like the .toString()
.
This was the cause of EmojiCompat crashes
Don't know what have changed on Pixels to trigger this now and not before, but this is definitively an SDK error.
Of course all the setText are final so can't be fixed on child classes. For my case I'll stop using the char array version for Pixels for my ellipsis version. But this is something that will bite anyone using EmojiCompat and char arrays when the emoji do update the text.
se...@google.com <se...@google.com>
to...@gmail.com <to...@gmail.com> #6
So it seems that the code path also triggers memory leaks by keeping the spannable (Causing leaks via ClickableSpan and the lambdas)
┬───
│ GC Root: Global variable in native code
│
├─ android.content.pm.BaseParceledListSlice$1 instance
│ Leaking: UNKNOWN
│ Retaining 216.5 kB in 3312 objects
│ Anonymous subclass of android.os.Binder
│ ↓ BaseParceledListSlice$1.this$0
│ ~~~~~~
├─ android.content.pm.ParceledListSlice instance
│ Leaking: UNKNOWN
│ Retaining 216.0 kB in 3311 objects
│ ↓ BaseParceledListSlice.mList
│ ~~~~~
├─ java.util.ArrayList instance
│ Leaking: UNKNOWN
│ Retaining 216.0 kB in 3310 objects
│ ↓ ArrayList[104]
│ ~~~~~
├─ android.view.contentcapture.ContentCaptureEvent instance
│ Leaking: UNKNOWN
│ Retaining 1.2 kB in 18 objects
│ ↓ ContentCaptureEvent.mNode
│ ~~~~~
├─ android.view.contentcapture.ViewNode instance
│ Leaking: UNKNOWN
│ Retaining 1.1 kB in 17 objects
│ ↓ ViewNode.mText
│ ~~~~~
├─ android.view.contentcapture.ViewNode$ViewNodeText instance
│ Leaking: UNKNOWN
│ Retaining 688 B in 13 objects
│ ↓ ViewNode$ViewNodeText.mText
│ ~~~~~
├─ android.text.SpannableStringBuilder instance
│ Leaking: UNKNOWN
│ Retaining 640 B in 12 objects
│ ↓ SpannableStringBuilder.mSpans
│ ~~~~~~
├─ java.lang.Object[] array
│ Leaking: UNKNOWN
│ Retaining 36 B in 1 objects
│ ↓ Object[0]
│ ~~~
├─ org.leetzone.android.yatsewidget.helpers.media.
│ MediaHelper$makeCastClickable$1$1 instance
│ Leaking: UNKNOWN
│ Retaining 40 B in 2 objects
│ Anonymous subclass of android.text.style.ClickableSpan
│ ↓ MediaHelper$makeCastClickable$1$1.$clickAction
│ ~~~~~~~~~~~~
├─ org.leetzone.android.yatsewidget.ui.fragment.
│ InfoLoaderFragment$updateView$15 instance
│ Leaking: UNKNOWN
│ Retaining 16 B in 1 objects
│ Anonymous subclass of kotlin.jvm.internal.Lambda
│ ↓ InfoLoaderFragment$updateView$15.this$0
│ ~~~~~~
╰→ org.leetzone.android.yatsewidget.ui.fragment.InfoLoaderFragment instance
​ Leaking: YES (ObjectWatcher was watching this because org.leetzone.
​ android.yatsewidget.ui.fragment.InfoLoaderFragment received
​ Fragment#onDestroy() callback and Fragment#mFragmentManager is null)
​ Retaining 16.1 kB in 452 objects
​ key = ad4a77e9-1e59-477b-b4b1-e1d1c8ed963d
​ watchDurationMillis = 6693
​ retainedDurationMillis = 1687
se...@google.com <se...@google.com> #7
ClickableSpan is known to leak from the lambdas, and unfortunately there's not many options there (aside: this is why we haven't yet added the same feature to Compose, we're designing the lambdas out).
Taking a look at the other issue
se...@google.com <se...@google.com> #8
Looks like it's a NPE that's been possible since API 1, but an easy fix
to...@gmail.com <to...@gmail.com> #9
Yes fix is easy, set the wrapper to null not just the buffer on the reset.
About the leak, the question is more what was changed on Pixels to that contentcapture (don't know what it's supposed to do) things that now triggers it (and also trigger this bug) I do clean the spannable in ondestroy and did not face leaks before.
se...@google.com <se...@google.com> #10
That I don't know - can you make a separate bug with a repro for that so it can be passed to content capture?
se...@google.com <se...@google.com> #11
Based on both of these bugs, I'm getting the impression that something is calling .getText() and storing it longer than expected.
to...@gmail.com <to...@gmail.com> #12
I'm not sure I'll have enough time to build a repro, currently trying to find time to build repros for Compose and some nasty mem leaks :(
And well this issue was first assigned to content capture and was just ignored, so no high hopes, as often if I can't ping the proper guy issues falls in limbs.
se...@google.com <se...@google.com> #13
Ack. I'll make an internal bug and try to chase it down. I've fixed the NPE in U, and am trying to hotpatch it into a quarterly release.
Thanks for the incredibly high quality bug reports!
Thanks,
Sean
to...@gmail.com <to...@gmail.com> #14
Thanks to you for answering on the ping on the other one and previous interaction :)
It's most of the time a pleasure to work with final target Googlers, but after 10 years bugs reports it's often incredibly hard to reach the good one or even be triaged.
About the fix I have a doubt will, compiling with the future SDK embed the fix and so backport on all Android, or is the SDK just a wrapper and it will require the actual OS bump on devices?
se...@google.com <se...@google.com> #15
The fix I made is in TextView.java (exactly as you suggested). The NPE has been possible since API 1, and is pretty easy to trigger. The new behavior is in content capture, but we could fix it in TextView so triaged it as priority.
It will require a OS bump on devices to apply.
We do triage all bugs that come in, though we can't reply to every one. Recent regressions are prioritized on Text, FYI. So if you see something start breaking in a new release definitely mention that.
se...@google.com <se...@google.com>
se...@google.com <se...@google.com> #17
Bugjuggler:
bu...@google.com <bu...@google.com> #18
se...@google.com <se...@google.com> #19
Sorry about email spam there.
an...@google.com <an...@google.com> #20
Please review P2/P3/P4 issues in android_TM-QPR1-BC-triaged hotlist again and raise the Priority to P0/P1 if it’s a must-fix issue which meets QPR bar (go/pr-bar), or move it to other appropriate hotlists if it doesn’t meet the criteria soon.
For P0/P1 must-fix issues, please fix it and get the CL merged to git_tm-qpr-dev ASAP before target ToT (bug-fixing cutoff) date on 09/23.
Otherwise, you will need to submit go/pr-bug and get it approved in Release team’s BL meeting to have the CL merged once SW build enters cherrypick mode in the week of 09/26.
Thanks.
se...@google.com <se...@google.com> #21
ag/19267003 fixes this crash.
Adding content capture in case any other CLs are inbound from. Please assign this back to me if no CL is pending from
Thanks Sean
se...@google.com <se...@google.com> #22
Cherry-pick to tm-qpr-dev: ag/19340644
au...@google.com <au...@google.com> #23
So the crash is fixed but we still have a memory leak? Sean, let's keep
Description
As per the title, it's pretty rare and I can't reproduce but since the march update without update on my app I get the following crash reported to Play Console:
Occurs only on Pixels with Android 12 (The march update is an educated guess since it only started to appear in march)
The only thing my app does that most don't is to heavily rely on chararraybuffers.