leakcanary icon indicating copy to clipboard operation
leakcanary copied to clipboard

Crash due to LeakCanary including unloaded class

Open Nattle opened this issue 4 years ago • 2 comments

02-12 15:27:16.274 17309-17472/com.refresh.refreshandroid D/LeakCanary: Analysis in progress, working on: FINDING_DOMINATORS 02-12 15:27:18.021 17309-17472/com.refresh.refreshandroid D/LeakCanary: Found 6 paths to retained objects, down to 2 after removing duplicated paths 02-12 15:27:18.021 17309-17472/com.refresh.refreshandroid D/LeakCanary: Analysis in progress, working on: INSPECTING_OBJECTS 02-12 15:27:18.059 17309-17472/com.refresh.refreshandroid D/LeakCanary: Analysis in progress, working on: REPORTING_HEAP_ANALYSIS 02-12 15:27:18.064 17309-17472/com.refresh.refreshandroid D/LeakCanary: ​ ==================================== HEAP ANALYSIS FAILED

You can report this failure at https://github.com/square/leakcanary/issues
Please provide the stacktrace, metadata and the heap dump file.
====================================
STACKTRACE

kotlin.KotlinNullPointerException
    at shark.AndroidResourceIdNames$Companion$readFromHeap$1.invoke(AndroidResourceIdNames.kt:86)
    at shark.AndroidResourceIdNames$Companion$readFromHeap$1.invoke(AndroidResourceIdNames.kt:19)
    at shark.GraphContext.getOrPut(GraphContext.kt:23)
    at shark.AndroidResourceIdNames$Companion.readFromHeap(AndroidResourceIdNames.kt:76)
    at shark.AndroidObjectInspectors$VIEW$inspect$1.invoke(AndroidObjectInspectors.kt:155)
    at shark.AndroidObjectInspectors$VIEW$inspect$1.invoke(AndroidObjectInspectors.kt:40)
    at shark.ObjectReporter.whenInstanceOf(ObjectReporter.kt:61)
    at shark.AndroidObjectInspectors$VIEW.inspect(AndroidObjectInspectors.kt:108)
    at shark.HeapAnalyzer.inspectObjects(HeapAnalyzer.kt:424)
    at shark.HeapAnalyzer.findLeaks(HeapAnalyzer.kt:204)
    at shark.HeapAnalyzer.analyzeGraph(HeapAnalyzer.kt:175)
    at shark.HeapAnalyzer.analyze(HeapAnalyzer.kt:101)
    at leakcanary.internal.HeapAnalyzerService.analyzeHeap(HeapAnalyzerService.kt:87)
    at leakcanary.internal.HeapAnalyzerService.onHandleIntentInForeground(HeapAnalyzerService.kt:61)
    at leakcanary.internal.ForegroundService.onHandleIntent(ForegroundService.kt:55)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.os.HandlerThread.run(HandlerThread.java:61)
====================================
METADATA

Build.VERSION.SDK_INT: 22
Build.MANUFACTURER: rockchip
LeakCanary version: 2.6
Analysis duration: 54583 ms
Heap dump file path: /mnt/internal_sd/Download/leakcanary-com.refresh.refreshandroid/2021-02-12_15-26-18_744.hprof
Heap dump timestamp: 1613161638059
====================================

02-12 15:27:18.094 17309-17309/com.refresh.refreshandroid D/LeakCanary: Watching instance of leakcanary.internal.HeapAnalyzerService (leakcanary.internal.HeapAnalyzerService received Service#onDestroy() callback) with key 1dc0f505-1f95-433b-866f-e5f84481f380

Nattle avatar Feb 12 '21 20:02 Nattle

Opening the heap dump with YourKit shows there are two AndroidResourceIdNames classes, one of which is unreachable. Unfortunately LeakCanary doesn't currently check for reachable vs unreachable classes, so here it's picking the wrong class.

Duplicate of #1759 though it's cool to have a fresh heap dump.

This was implemented in #1764 but needs more time investigating.

pyricau avatar Mar 26 '21 04:03 pyricau

I gave a refresh to #1764 and that fixed this crash.

pyricau avatar Nov 12 '22 02:11 pyricau

====================================
HEAP ANALYSIS RESULT
====================================
3 APPLICATION LEAKS

References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.

23470 bytes retained by leaking objects
Displaying only 1 leak trace out of 3 with the same signature
Signature: 39ea7a583548a3d9792c5bd58868f6d98d29e0d2
┬───
│ GC Root: Global variable in native code
│
├─ com.android.org.chromium.base.SystemMessageHandler instance
│    Leaking: NO (MessageQueue↓ is not leaking)
│    ↓ Handler.mQueue
├─ android.os.MessageQueue instance
│    Leaking: NO (MessageQueue#mQuitting is false)
│    HandlerThread: "main"
│    ↓ MessageQueue[1]
│                  ~~~
├─ android.os.Message instance
│    Leaking: UNKNOWN
│    Retaining 92 B in 2 objects
│    Message.what = 12001
│    Message.when = 38516051 (1179 ms after heap dump)
│    Message.obj = null
│    Message.callback = null
│    Message.target = instance @320886816 of com.refresh.refreshandroid.activities.ServicePanelWebview$1
│    ↓ Message.target
│              ~~~~~~
├─ com.refresh.refreshandroid.activities.ServicePanelWebview$1 instance
│    Leaking: UNKNOWN
│    Retaining 32 B in 1 objects
│    Anonymous subclass of android.os.Handler
│    this$0 instance of com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview with mDestroyed = true
│    ↓ ServicePanelWebview$1.this$0
│                            ~~~~~~
╰→ com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview instance
     Leaking: YES (ObjectWatcher was watching this because com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview received Activity#onDestroy() callback and Activity#mDestroyed is true)
     Retaining 7.8 kB in 201 objects
     key = f9009329-445e-4b6f-a557-ac5b75aea533
     watchDurationMillis = 6941
     retainedDurationMillis = 1940
     mApplication instance of io.bevi.android.application.Bevi
     mBase instance of android.app.ContextImpl

36 bytes retained by leaking objects
Displaying only 1 leak trace out of 3 with the same signature
Signature: 6cfe4d055b9d0b652d88208632a92a4b805006f6
┬───
│ GC Root: Global variable in native code
│
├─ io.bevi.android.application.Bevi instance
│    Leaking: NO (Application is a singleton)
│    mBase instance of android.app.ContextImpl
│    ↓ Application.mComponentCallbacks
│                  ~~~~~~~~~~~~~~~~~~~
├─ java.util.ArrayList instance
│    Leaking: UNKNOWN
│    Retaining 5.2 MB in 12 objects
│    ↓ ArrayList[2]
│               ~~~
├─ com.android.org.chromium.android_webview.AwContents$AwComponentCallbacks instance
│    Leaking: UNKNOWN
│    Retaining 12 B in 1 objects
│    ↓ AwContents$AwComponentCallbacks.this$0
│                                      ~~~~~~
├─ com.android.org.chromium.android_webview.AwContents instance
│    Leaking: UNKNOWN
│    Retaining 4.4 kB in 102 objects
│    mContext instance of com.android.webview.chromium.WebViewChromium$2, wrapping activity com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview with mDestroyed = true
│    ↓ AwContents.mContext
│                 ~~~~~~~~
╰→ com.android.webview.chromium.WebViewChromium$2 instance
     Leaking: YES (WebViewChromium$2 wraps an Activity with Activity.mDestroyed true)
     Retaining 12 B in 1 objects
     Anonymous subclass of android.content.ContextWrapper
     mBase instance of com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview with mDestroyed = true

2364 bytes retained by leaking objects
Displaying only 1 leak trace out of 3 with the same signature
Signature: 57a392fd2a4005cf2f0056863693c65694f4f19f
┬───
│ GC Root: Global variable in native code
│
├─ io.bevi.android.application.Bevi instance
│    Leaking: NO (Application is a singleton)
│    mBase instance of android.app.ContextImpl
│    ↓ Application.mComponentCallbacks
│                  ~~~~~~~~~~~~~~~~~~~
├─ java.util.ArrayList instance
│    Leaking: UNKNOWN
│    Retaining 5.2 MB in 12 objects
│    ↓ ArrayList[2]
│               ~~~
├─ com.android.org.chromium.android_webview.AwContents$AwComponentCallbacks instance
│    Leaking: UNKNOWN
│    Retaining 12 B in 1 objects
│    ↓ AwContents$AwComponentCallbacks.this$0
│                                      ~~~~~~
├─ com.android.org.chromium.android_webview.AwContents instance
│    Leaking: UNKNOWN
│    Retaining 4.4 kB in 102 objects
│    mContext instance of com.android.webview.chromium.WebViewChromium$2, wrapping activity com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview with mDestroyed = true
│    ↓ AwContents.mAwAutofillClient
│                 ~~~~~~~~~~~~~~~~~
├─ com.android.org.chromium.android_webview.AwAutofillClient instance
│    Leaking: UNKNOWN
│    Retaining 2.0 kB in 44 objects
│    ↓ AwAutofillClient.mContentViewCore
│                       ~~~~~~~~~~~~~~~~
├─ com.android.org.chromium.content.browser.ContentViewCore instance
│    Leaking: UNKNOWN
│    Retaining 2.0 kB in 43 objects
│    mContext instance of com.android.webview.chromium.WebViewChromium$2, wrapping activity com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview with mDestroyed = true
│    ↓ ContentViewCore.mPopupZoomer
│                      ~~~~~~~~~~~~
╰→ com.android.org.chromium.content.browser.PopupZoomer instance
     Leaking: YES (View.mContext references a destroyed activity)
     Retaining 788 B in 10 objects
     View not part of a window view hierarchy
     View.mAttachInfo is null (view detached)
     View.mWindowAttachCount = 0
     mContext instance of com.android.webview.chromium.WebViewChromium$2, wrapping activity com.refresh.refreshandroid.activities.landscape.ServicePanelLandcapeWebview with mDestroyed = true
====================================
0 LIBRARY LEAKS

A Library Leak is a leak caused by a known bug in 3rd party code that you do not have control over.
See https://square.github.io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks
====================================
0 UNREACHABLE OBJECTS

An unreachable object is still in memory but LeakCanary could not find a strong reference path
from GC roots.
====================================
METADATA

Please include this in bug reports and Stack Overflow questions.

Build.VERSION.SDK_INT: 22
Build.MANUFACTURER: rockchip
LeakCanary version: 2.6
App process name: com.refresh.refreshandroid
Class count: 7636
Instance count: 251062
Primitive array count: 33227
Object array count: 36656
Thread count: 64
Heap total bytes: 63778269
Bitmap count: 29
Bitmap total bytes: 0
Large bitmap count: 0
Large bitmap total bytes: 0
Stats: LruCache[maxSize=3000,hits=36017,misses=129480,hitRate=21%] RandomAccess[bytes=9385425,reads=129480,travel=59080601201,range=20386665,size=68002572]
Analysis duration: 1284 ms
Heap dump file path: /Users/py/Downloads/2021-02-12_15-26-18_744.hprof
Heap dump timestamp: 1668265339966
Heap dump duration: Unknown

pyricau avatar Nov 12 '22 15:11 pyricau