Toasty icon indicating copy to clipboard operation
Toasty copied to clipboard

[Leak] Toast$TN leaking in Android 11

Open KaustubhPatange opened this issue 4 years ago • 3 comments

The leak is captured from LeakCanary.

┬───
│ GC Root: Global variable in native code
│
├─ android.widget.Toast$TN instance
│    Leaking: UNKNOWN
│    ↓ Toast$TN.mPresenter
│               ~~~~
├─ android.widget.ToastPresenter instance
│    Leaking: UNKNOWN
│    ↓ ToastPresenter.mContext
│                     ~~~~
╰→ com.kpstv.yts.ui.activities.FinalActivity instance
​     Leaking: YES (ObjectWatcher was watching this because com.kpstv.yts.ui.activities.FinalActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
​     key = c2fb5f4f-112b-4489-a84e-8b37699b32c1
​     watchDurationMillis = 6111
​     retainedDurationMillis = 1110

METADATA

Build.VERSION.SDK_INT: 30
Build.MANUFACTURER: samsung
LeakCanary version: 2.4
App process name: com.kpstv.yts
Analysis duration: 33287 ms

This happens when the toast is in the queue (referenced) but the activity or containing fragment (in which it's about to show) goes out of existence. I've tested in on some devices & found out that Samsung devices are hotspots for this leak.

The fix, for now, is to set allowQueue to false from Toasty.Config.

KaustubhPatange avatar Feb 21 '21 07:02 KaustubhPatange

I also encountered this problem

wallyperry avatar Jun 07 '21 09:06 wallyperry

Did you ever get this leak resolved? @KaustubhPatange

phamsarah avatar Oct 25 '21 20:10 phamsarah

Any updates on this Leak?

pingatkaran avatar Nov 10 '22 17:11 pingatkaran