Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewRootImpl.mContext Leak #94

Closed
Consoar opened this issue May 14, 2015 · 11 comments
Closed

ViewRootImpl.mContext Leak #94

Consoar opened this issue May 14, 2015 · 11 comments

Comments

@Consoar
Copy link

Consoar commented May 14, 2015

The leak happens on my LG G2 (5.0.2 30D),it can't be reproduced on AOSP

here is the trace:

1.
* com.squareup.leakcanary.internal.DisplayLeakActivity has leaked:
* GC ROOT android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue
* references android.os.MessageQueue.mMessages
* references android.os.Message.next
* references android.os.Message.target
* references android.view.ViewRootImpl$ViewRootHandler.this$0
* references android.view.ViewRootImpl.mContext
* leaks com.squareup.leakcanary.internal.DisplayLeakActivity instance

* Reference Key: 7ee91bb5-42e5-4e0d-807a-3878007c9fde
* Device: LGE lge LG-D802 g2_vdf_com
* Android Version: 5.0.2 API: 21
* Durations: watch=5056ms, gc=140ms, heap dump=1179ms, analysis=24079ms

2.
* bos.consoar.lasttime.ui.activity.ThingDetailActivity has leaked:
* GC ROOT android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue
* references android.os.MessageQueue.mMessages
* references android.os.Message.next
* references android.os.Message.target
* references android.view.ViewRootImpl$ViewRootHandler.this$0
* references android.view.ViewRootImpl.mContext
* leaks bos.consoar.lasttime.ui.activity.ThingDetailActivity instance

* Reference Key: 21cdd701-daa8-421f-9f5d-f24faeef03b7
* Device: LGE lge LG-D802 g2_vdf_com
* Android Version: 5.0.2 API: 21
* Durations: watch=5039ms, gc=160ms, heap dump=1419ms, analysis=25165ms

I don't know why ViewRootImpl.mContext leak happened。I really need you help。Thanks。

@pyricau
Copy link
Member

pyricau commented May 14, 2015

Can you try again with 1.3.1-SNAPSHOT and put the output here? https://github.com/square/leakcanary/blob/master/CHANGELOG.md#dependencies

@Consoar
Copy link
Author

Consoar commented May 15, 2015

@Consoar
Copy link
Author

Consoar commented May 15, 2015

@pyricau
Copy link
Member

pyricau commented May 17, 2015

ViewRootImpl.mView is null, so it's been detached from the window.

However, a android.view.View$ScrollabilityCache callback has been posted to that ViewRootImpl handler, and that chain of posted messages causes the handler to leak and with it the ViewRootImpl and the activity context.

@Consoar this one is tricky. If you can repro, can you then provide a heap dump? Need to poke around the view that's posting this callback.

@ChaitanyaPramod
Copy link

I also am on LG G2 (5.0.2) and seeing this leak.

@pyricau Can you help me understand why this leak is reported even when it appears to be excluded here?

Edit:
My bad, my leak is slightly different (but still originating in Choreographer$FrameDisplayEventReceiver.mMessageQueue)

1.
In in.zeta.android.debug:0.2.6 debug-2.6-22-ga750fa9:14.
* in.zeta.android.ui.activity.ZetaSignUpActivity has leaked:
* GC ROOT android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue
* references android.os.MessageQueue.mMessages
* references android.os.Message.next
* references android.os.Message.target
* references android.view.ViewRootImpl$ViewRootHandler.this$0
* references android.view.ViewRootImpl.mDisplayManager
* references android.hardware.display.DisplayManager.mContext
* leaks in.zeta.android.ui.activity.ZetaSignUpActivity instance

* Reference Key: e2c1d3c6-3d9f-492f-87d2-110cf319885d
* Device: LGE lge LG-D802 g2_open_com
* Android Version: 5.0.2 API: 21 LeakCanary: 1.3.1
* Durations: watch=5027ms, gc=132ms, heap dump=2612ms, analysis=26849ms

2.
In in.zeta.android.debug:0.2.6 debug-2.6-22-ga750fa9:14.
* com.squareup.leakcanary.internal.DisplayLeakActivity has leaked:
* GC ROOT android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue
* references android.os.MessageQueue.mMessages
* references android.os.Message.callback
* references android.view.View$ScrollabilityCache.host
* references android.widget.ListView.mContext
* leaks com.squareup.leakcanary.internal.DisplayLeakActivity instance

* Reference Key: 97f620d5-4721-4580-9eaf-0624cedfdb82
* Device: LGE lge LG-D802 g2_open_com
* Android Version: 5.0.2 API: 21 LeakCanary: 1.3.1
* Durations: watch=5474ms, gc=196ms, heap dump=2829ms, analysis=21414ms

@trietbui85
Copy link

I also got the same leak with v1.3.1:

In com.midoplay:0.7.2:92.

  • com.midoplay.HomeActivity has leaked:
  • GC ROOT android.view.Choreographer$FrameDisplayEventReceiver.this$0
  • references android.view.Choreographer.mCallbackQueues
  • references array android.view.Choreographer$CallbackQueue[].[1]
  • references android.view.Choreographer$CallbackQueue.mHead
  • references android.view.Choreographer$CallbackRecord.action
  • references android.animation.ValueAnimator$AnimationHandler.mAnimations
  • references java.util.ArrayList.array
  • references array java.lang.Object[].[16]
  • references android.animation.ObjectAnimator.mTarget
  • references com.midoplay.views.CountdownTimerView.mContext
  • leaks com.midoplay.HomeActivity instance
  • Reference Key: b0387b92-d22c-4193-985d-dc8d01f9f3df
  • Device: samsung samsung SM-T331 millet3gxx
  • Android Version: 4.4.2 API: 19 LeakCanary: 1.3.1
  • Durations: watch=5027ms, gc=276ms, heap dump=1576ms, analysis=38859ms

@sibelius
Copy link

I've got this leak that could be similar

    In com.example:1.5.0:27.
    * com.example.ui.record.RecordFragment has leaked:
    * GC ROOT android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue
    * references android.os.MessageQueue.mMessages
    * references android.os.Message.target
    * references android.os.CountDownTimer(.this$0 (anonymous class extends android.os.Handler)
    * references com.example.ui.record.RecordFragment$5.this$0 (anonymous class extends android.os.CountDownTimer)
    * leaks com.example.ui.record.RecordFragment instance
    * Reference Key: 19d180c7-0cf4-4851-84b7-5be36239204a
    * Device: Sony Sony Xperia SP C5303
    * Android Version: 5.1.1 API: 22 LeakCanary: 1.3.1
    * Durations: watch=5487ms, gc=184ms, heap dump=4438ms, analysis=25756ms
    * Details:
    * Instance of android.view.Choreographer$FrameDisplayEventReceiver
    |   mFrame = 285356
    |   mHavePendingVsync = false
    |   mTimestampNanos = 88717532073026
    |   this$0 = android.view.Choreographer [id=0x12f7f6c0]
    |   mCloseGuard = dalvik.system.CloseGuard [id=0x708a5058]
    |   mMessageQueue = android.os.MessageQueue [id=0x12c6f190]
    |   mReceiverPtr = -1189614264
    * Instance of android.os.MessageQueue
    |   mBlocked = false
    |   mIdleHandlers = java.util.ArrayList [id=0x12c67c60]
    |   mMessages = android.os.Message [id=0x12e99200]
    |   mNextBarrierToken = 267
    |   mPendingIdleHandlers = android.os.MessageQueue$IdleHandler[] [id=0x12ff01e0;length=4]
    |   mPtr = -1190220232
    |   mQuitAllowed = false
    |   mQuitting = false
    * Instance of android.os.Message
    |   static $staticOverhead = byte[] [id=0x70a09439;length=72;size=88]
    |   static CREATOR = android.os.Message( [id=0x708c0030]
    |   static FLAGS_TO_CLEAR_ON_COPY_FROM = 1
    |   static FLAG_ASYNCHRONOUS = 2
    |   static FLAG_IN_USE = 1
    |   static MAX_POOL_SIZE = 50
    |   static gCheckRecycle = true
    |   static sPool = android.os.Message [id=0x13188780]
    |   static sPoolSize = 10
    |   static sPoolSync = java.lang.Object [id=0x708c0028]
    |   arg1 = 0
    |   arg2 = 0
    |   callback = null
    |   data = null
    |   flags = 1
    |   next = android.os.Message [id=0x12f14140]
    |   obj = null
    |   replyTo = null
    |   sendingUid = -1
    |   target = android.os.CountDownTimer( [id=0x12c28600]
    |   what = 1
    |   when = 88717653
    * Instance of android.os.CountDownTimer(
    |   this$0 = com.example.ui.record.RecordFragment$5 [id=0x12c6e3d0]
    |   mAsynchronous = false
    |   mCallback = null
    |   mLooper = android.os.Looper [id=0x12c67c40]
    |   mMessenger = null
    |   mQueue = android.os.MessageQueue [id=0x12c6f190]
    * Instance of com.example.ui.record.RecordFragment$5
    |   this$0 = com.example.ui.record.RecordFragment [id=0x12d90bc0]
    |   mCancelled = false
    |   mCountdownInterval = 1000
    |   mHandler = android.os.CountDownTimer( [id=0x12c28600]
    |   mMillisInFuture = 4000
    |   mStopTimeInFuture = 705581385
    * Instance of com.example.ui.record.RecordFragment
    |   static $staticOverhead = byte[] [id=0x13125c01;length=16;size=32]
    |   static REQUEST_CHECK_SETTINGS = 0
    |   static TAG = java.lang.String [id=0x1313e880]
    |   currentTimeCallback = com.example.ui.record.RecordFragment$CurrentTimeCallback [id=0x130f4d30]
    |   handleMediaPlayer = com.example.ui.record.RecordFragment$HandleMediaPlayer [id=0x130f4d00]
    |   kindStr = java.lang.String[] [id=0x1313e8a0;length=5]
    |   lastKnownLocationObservable = rx.Observable [id=0x1314b260]
    |   lastKnownLocationSubscription = rx.observers.SafeSubscriber [id=0x13147d30]
    |   locationProvider = pl.charmas.android.reactivelocation.ReactiveLocationProvider [id=0x1314b0d0]
    |   locationUpdatesObservable = rx.Observable [id=0x1314b550]
    |   mCounter = com.example.ui.record.RecordFragment$5 [id=0x12c6e3d0]
    |   mDate = java.util.Date [id=0x130f4e80]
    |   mEmpId = java.lang.String [id=0x12e9b320]
    |   mFilename = java.lang.String [id=0x13149920]
    |   mIMEI = java.lang.String [id=0x13149e00]
    |   mKind = java.lang.String [id=0x130ef6a0]
    |   mLatitude = -23.5654487
    |   mLongitude = -46.689545
    |   mPlayer = null
    |   mPrefs = android.app.SharedPreferencesImpl [id=0x12ed2540]
    |   mProgress = null
    |   mRecMicToMp3 = com.example.lame.RecMicToMp3 [id=0x13149ae0]
    |   mTimeSource = java.lang.String [id=0x12f82a40]
    |   recorderHandler = com.example.ui.record.RecordFragment$RecorderHandler [id=0x1313e920]
    |   tvChronometer = android.support.v7.widget.AppCompatTextView [id=0x13126800]
    |   updatableLocationSubscription = rx.observers.SafeSubscriber [id=0x131527f0]
    |   mAdded = true
    |   mAllowEnterTransitionOverlap = null
    |   mAllowReturnTransitionOverlap = null
    |   mAnimatingAway = null
    |   mArguments = null
    |   mBackStackNesting = 0
    |   mCalled = true
    |   mCheckedForLoaderManager = true
    |   mChildFragmentManager = android.support.v4.app.FragmentManagerImpl [id=0x13134970]
    |   mContainer = null
    |   mContainerId = 2131558529
    |   mDeferStart = false
    |   mDetached = false
    |   mEnterTransition = null
    |   mEnterTransitionCallback = null
    |   mExitTransition = null
    |   mExitTransitionCallback = null
    |   mFragmentId = 2131558539
    |   mFragmentManager = android.support.v4.app.FragmentManagerImpl [id=0x13134120]
    |   mFromLayout = true
    |   mHasMenu = false
    |   mHidden = false
    |   mHost = android.support.v4.app.FragmentActivity$HostCallbacks [id=0x130fb9c0]
    |   mInLayout = true
    |   mIndex = 0
    |   mInnerView = android.widget.RelativeLayout [id=0x13126400]
    |   mLoaderManager = null
    |   mLoadersStarted = true
    |   mMenuVisible = true
    |   mNextAnim = 0
    |   mParentFragment = null
    |   mReenterTransition = java.lang.Object [id=0x12ed93c0]
    |   mRemoving = false
    |   mRestored = false
    |   mResumed = true
    |   mRetainInstance = false
    |   mRetaining = false
    |   mReturnTransition = java.lang.Object [id=0x12ed93c0]
    |   mSavedFragmentState = null
    |   mSavedViewState = null
    |   mSharedElementEnterTransition = null
    |   mSharedElementReturnTransition = java.lang.Object [id=0x12ed93c0]
    |   mState = 5
    |   mStateAfterAnimating = 0
    |   mTag = null
    |   mTarget = null
    |   mTargetIndex = -1
    |   mTargetRequestCode = 0
    |   mUserVisibleHint = true
    |   mView = android.widget.RelativeLayout [id=0x13126400]
    |   mWho = java.lang.String [id=0x1313ea40]')))))

@pyricau
Copy link
Member

pyricau commented Jan 4, 2016

Please refrain from posting different leaktraces on the same issue.

@pyricau pyricau closed this as completed Jan 4, 2016
@thrlr123
Copy link

thrlr123 commented Oct 1, 2018

@sibelius How dod you solve the leak above? I have the same issue. I am canceling the timer in onPause and starting in onResume but I still see the leak which is exactly the same as yours.

@sibelius
Copy link

sibelius commented Oct 1, 2018

i've moved to react-native and all the leaks has been solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants