Skip to content

Leak for Message(Queue) in WebViewActivity #5453

Open
@jpelgrom

Description

@jpelgrom

Home Assistant Android app version(s): observed with commits from #5445, which is based on the recent main branch

Android version(s): 16

Device model(s): Google Pixel 7a

Home Assistant version: unrelated

Last working Home Assistant release (if known): first observed in #5419, so maybe before that (2025.6.5) but I'm not sure

Description of problem, include YAML if issue is related to notifications:

I'm seeing this leak popping up more frequently now, but do not have a good way to reproduce it. It seems to happen most frequently when the WebViewActivity is recreated (for example, by changing the device theme).

Companion App Logs:

┬───
│ GC Root: System class
│
├─ android.app.ActivityThread class
│    Leaking: NO (MessageQueue↓ is not leaking and a class is never leaking)
│    ↓ static ActivityThread.sMainThreadHandler
├─ android.app.ActivityThread$H instance
│    Leaking: NO (MessageQueue↓ is not leaking)
│    ↓ Handler.mQueue
├─ [android.os.MessageQueue](http://android.os.messagequeue/) instance
│    Leaking: NO (MessageQueue#mQuitting is false)
│    HandlerThread: "main"
│    ↓ MessageQueue[0]
│                  ~~~
├─ [android.os.Message](http://android.os.message/) instance
│    Leaking: UNKNOWN
│    Retaining 134 B in 4 objects
│    Message.what = 0
│    Message.when = 93097284 (687 ms after heap dump)
│    Message.obj = null
│    Message.callback = instance @43948936 of io.homeassistant.companion.
│    android.webview.WebViewActivity$$ExternalSyntheticLambda23
│    Message.target = instance @43948904 of [android.os.Handler](http://android.os.handler/)
│    ↓ Message.callback
│              ~~~~~~~~
├─ io.homeassistant.companion.android.webview.
│  WebViewActivity$$ExternalSyntheticLambda23 instance
│    Leaking: UNKNOWN
│    Retaining 12 B in 1 objects
│    f$0 instance of io.homeassistant.companion.android.webview.WebViewActivity
│    with mDestroyed = true
│    ↓ WebViewActivity$$ExternalSyntheticLambda23.f$0
│                                                 ~~~
╰→ io.homeassistant.companion.android.webview.WebViewActivity instance
     Leaking: YES (ObjectWatcher was watching this because io.homeassistant.
     companion.android.webview.WebViewActivity received Activity#onDestroy()
     callback and Activity#mDestroyed is true)
     Retaining 103.2 kB in 2188 objects
     key = 8535a6ba-c005-4a2d-a428-362779c1c85d
     watchDurationMillis = 5613
     retainedDurationMillis = 608
     mApplication instance of io.homeassistant.companion.android.
     HomeAssistantApplication
     mBase instance of androidx.appcompat.view.ContextThemeWrapper

METADATA

Build.VERSION.SDK_INT: 36
Build.MANUFACTURER: Google
LeakCanary version: 2.14
App process name: io.homeassistant.companion.android.debug
Class count: 45043
Instance count: 325260
Primitive array count: 223337
Object array count: 44041
Thread count: 83
Heap total bytes: 42440944
Bitmap count: 4
Bitmap total bytes: 30568
Large bitmap count: 0
Large bitmap total bytes: 0
Db 1: open /data/user/0/io.homeassistant.companion.android.
debug/no_backup/androidx.work.workdb
Db 2: open /data/user/0/io.homeassistant.companion.android.
debug/databases/HomeAssistantDB
Count of retained yet cleared: 5 KeyedWeakReference instances
Stats: LruCache[maxSize=3000,hits=134992,misses=275288,hitRate=32%]
RandomAccess[bytes=13583713,reads=275288,travel=139399383506,range=50877810,size
=63850549]
Analysis duration: 22919 ms

Screenshot or video of problem: n/a

Additional information: n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions