Reputation: 20130
I got the next error on the CI:
531532 bytes retained by leaking objects
Signature: 57cc9bd9b14a813ead44f7eba2d9ffa1de2c4649
┬───
│ GC Root: Java local variable
│
├─ android.app.Instrumentation$InstrumentationThread thread
│ Leaking: UNKNOWN
│ Thread name: 'Instr: com.comp.test.runner.YInstrumentationRunner'
│ ↓ Instrumentation$InstrumentationThread.<Java Local>
│ ~~~~~~~~~~~~
├─ java.util.ArrayList instance
│ Leaking: UNKNOWN
│ ↓ ArrayList.elementData
│ ~~~~~~~~~~~
├─ java.lang.Object[] array
│ Leaking: UNKNOWN
│ ↓ Object[].[0]
│ ~~~
├─ org.junit.runner.Result$Listener instance
│ Leaking: UNKNOWN
│ ↓ Result$Listener.this$0
│ ~~~~~~
├─ org.junit.runner.Result instance
│ Leaking: UNKNOWN
│ ↓ Result.failures
│ ~~~~~~~~
├─ java.util.concurrent.CopyOnWriteArrayList instance
│ Leaking: UNKNOWN
│ ↓ CopyOnWriteArrayList.elements
│ ~~~~~~~~
├─ java.lang.Object[] array
│ Leaking: UNKNOWN
│ ↓ Object[].[4]
│ ~~~
├─ org.junit.runner.notification.Failure instance
│ Leaking: UNKNOWN
│ ↓ Failure.fThrownException
│ ~~~~~~~~~~~~~~~~
├─ androidx.test.espresso.NoMatchingViewException instance
│ Leaking: UNKNOWN
│ ↓ NoMatchingViewException.rootView
│ ~~~~~~~~
├─ com.android.internal.policy.DecorView instance
│ Leaking: YES (View.mContext references a destroyed activity)
│ mContext instance of com.android.internal.policy.DecorContext, wrapping activity com.comp.android.t.ui.TransactionAggregateActivity with mDestroyed = true
│ View#mParent is null
│ View#mAttachInfo is null (view detached)
│ View.mWindowAttachCount = 1
│ ↓ DecorView.mContentRoot
├─ android.widget.LinearLayout instance
│ Leaking: YES (DecorView↑ is leaking and View.mContext references a destroyed activity)
│ mContext instance of com.comp.android.t.ui.TransactionAggregateActivity with mDestroyed = true
│ View#mParent is set
│ View#mAttachInfo is null (view detached)
│ View.mWindowAttachCount = 1
│ ↓ LinearLayout.mContext
╰→ com.comp.android.t.ui.TransactionAggregateActivity instance
Leaking: YES (ObjectWatcher was watching this because com.comp.android.t.ui.TransactionAggregateActivity received Activity#onDestroy() callback and Activity#mDestroyed is true)
key = 61835653-e97b-48a8-b7a2-8663d45eeec5
watchDurationMillis = 8798
retainedDurationMillis = 3797
Upvotes: 0
Views: 482
Reputation: 8349
This is definitely unexpected. See the documentation: https://square.github.io/leakcanary/recipes/#running-leakcanary-in-instrumentation-tests
LeakCanary is automatically disabled by setting LeakCanary.config.dumpHeap to false when JUnit is on the runtime classpath.
The custom test listener (leakcanary.FailTestOnLeakRunListener) will only trigger an analysis when a test succeed, not when it failed.
So either you manually enabled LeakCanary in UI tests, or the code to detect that UI tests are running isn't working. Either way, you should probably file an issue to LeakCanary with those details.
Upvotes: 1