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

InputMethodManager.mCurRootView memory leak in Android 4.4 (devices is SM701) #322

Closed
ZhaoKaiQiang opened this issue Nov 10, 2015 · 13 comments

Comments

@ZhaoKaiQiang
Copy link

D/LeakCanary: In com.socks.jiandan:1.2:2.

  • com.socks.jiandan.ui.MainActivity has leaked:
  • GC ROOT static android.view.inputmethod.InputMethodManager.sInstance
  • references android.view.inputmethod.InputMethodManager.mCurRootView
  • references com.android.internal.policy.impl.PhoneWindow$DecorView.mContext
  • leaks com.socks.jiandan.ui.MainActivity instance

I find the code about this ,but why it not work for me?

INPUT_METHOD_MANAGER__ROOT_VIEW = new AndroidExcludedRefs("INPUT_METHOD_MANAGER__ROOT_VIEW", 6, VERSION.SDK_INT >= 15 && VERSION.SDK_INT <= 22, null) {
            void add(Builder excluded) {
                excluded.instanceField("android.view.inputmethod.InputMethodManager", "mCurRootView");
            }
};

my project is on here

@pyricau
Copy link
Member

pyricau commented Jan 4, 2016

Probably because this is happening on an Android version that's not between 15 and 22. Please update with the Android version info, and I'll reopen.

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

I have the same problem. LeakCanary tells me to ignore but still reported as a leak. Is that correct?

        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * LEAK CAN BE IGNORED.
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * mypackage.ui.map.MapComponentFragment has leaked:
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * GC ROOT android.view.inputmethod.InputMethodManager$1.this$0 (anonymous class extends com.android.internal.view.IInputMethodClient$Stub)
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * references android.view.inputmethod.InputMethodManager.mCurRootView
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * references com.android.internal.policy.impl.PhoneWindow$DecorView.mContext
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * references mypackage.ui.common.MainActivity.searchView
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * references mypackage.widget.CCSearchView.mOnQueryTextFocusChangeListener
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * references mypackage.ui.common.OverlayBaseFragment$4.this$0 (anonymous class implements android.view.View$OnFocusChangeListener)
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * references mypackage.ui.car.OverlayCarInfoFragment.mapComponentFragment
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * leaks mypackage.ui.map.MapComponentFragment instance
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * Reference Key: b80e4693-682d-44be-b3ee-86393f9c53ab
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * Device: samsung samsung SM-N910C treltexx
        01-07 09:21:53.980 4395-6469/mypackage D/LeakCanary: * Android Version: 5.1.1 API: 22 LeakCanary: 1.4-SNAPSHOT 2714152

As you can see v22 using the SNAPSHOT version.

@jrodbx
Copy link
Collaborator

jrodbx commented Jan 7, 2016

@skimarxall see here and here; this known AOSP issue still occurs in API 22

@marcelpinto
Copy link

@jrodbx is there a way to tell leakCanary to not report the leak? Is a bit annoying getting a message everytime this happens.

@jrodbx
Copy link
Collaborator

jrodbx commented Jan 7, 2016

currently there is not. feel free to open an issue and/or submit a PR.

@marcelpinto
Copy link

Thanks @jrodbx meanwhile I used the workaround for it #256

@jemshit
Copy link

jemshit commented Mar 20, 2016

Same here, on API 23, leakcanary 1.4-SNAPSHOT, it is not excluded as well. Should i ignore, doesn't seem it is related to my code

@pyricau
Copy link
Member

pyricau commented Mar 20, 2016

Right now it's supposed to be excluded up to LOLLIPOP_MR1. Is someone getting this on higher Android version? If yes, then please provide the Android version.

@jemshit
Copy link

jemshit commented Mar 20, 2016

@pyricau api 23, android M

pyricau added a commit that referenced this issue Mar 20, 2016
See #322

Also directly reference Lollipop constant.
@jjhesk
Copy link

jjhesk commented Jun 15, 2016

this ia api 23.

in xxxxxxxxxxxxxxx :0.4.3:1053.

  • xxxxxxxxxxx has leaked:
  • GC ROOT static android.view.inputmethod.InputMethodManager.sInstance
  • references android.view.inputmethod.InputMethodManager.mLastSrvView
  • references com.android.internal.policy.PhoneWindow$DecorView.mContext
  • leaks xxzzzzzzzzzxxxxxxxxxx instance
  • Retaining: 1.2 MB.
  • Reference Key: a7b50c31-fdba-475f-b1dd-6da1edc873b5
  • Device: HUAWEI HUAWEI EVA-AL10 EVA-AL10
  • Android Version: 6.0 API: 23 LeakCanary: 1.4-beta2 3799172
  • Durations: watch=6462ms, gc=151ms, heap dump=1366ms, analysis=13645ms
  • Details:
  • Class android.view.inputmethod.InputMethodManager
    | static RESULT_UNCHANGED_HIDDEN = 1
    | static MSG_SET_ACTIVE = 4
    | static RESULT_HIDDEN = 3
    | static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0
    | static sInstance = android.view.inputmethod.InputMethodManager@318862080 (0x13017300)
    | static SHOW_FORCED = 2
    | static DISPATCH_NOT_HANDLED = 0
    | static HIDE_NOT_ALWAYS = 2
    | static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1
    | static MSG_UNBIND = 3
    | static CONTROL_WINDOW_FIRST = 4
    | static CONTROL_START_INITIAL = 256
    | static RESULT_UNCHANGED_SHOWN = 0
    | static SHOW_IM_PICKER_MODE_AUTO = 0
    | static SHOW_IMPLICIT = 1
    | static CONTROL_WINDOW_VIEW_HAS_FOCUS = 1
    | static CONTROL_SHOW_INPUT = 65536
    | static MSG_DUMP = 1
    | static TAG = java.lang.String@1879246288 (0x700305d0)
    | static SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES = 2
    | static MSG_SEND_INPUT_EVENT = 5
    | static INPUT_METHOD_NOT_RESPONDING_TIMEOUT = 2500
    | static DEBUG = false
    | static PENDING_EVENT_COUNTER = java.lang.String@1879313800 (0x70040d88)
    | static RESULT_SHOWN = 2
    | static DISPATCH_IN_PROGRESS = -1
    | static MSG_FLUSH_INPUT_EVENT = 7
    | static $staticOverhead = byte[272]@1884161929 (0x704e0789)
    | static CONTROL_WINDOW_IS_TEXT_EDITOR = 2
    | static MSG_TIMEOUT_INPUT_EVENT = 6
    | static MSG_BIND = 2
    | static DISPATCH_HANDLED = 1
    | static SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES = 1
    | static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9
    | static HIDE_IMPLICIT_ONLY = 1
  • Instance of android.view.inputmethod.InputMethodManager
    | static RESULT_UNCHANGED_HIDDEN = 1
    | static MSG_SET_ACTIVE = 4
    | static RESULT_HIDDEN = 3
    | static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0
    | static sInstance = android.view.inputmethod.InputMethodManager@318862080 (0x13017300)
    | static SHOW_FORCED = 2
    | static DISPATCH_NOT_HANDLED = 0
    | static HIDE_NOT_ALWAYS = 2
    | static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1
    | static MSG_UNBIND = 3
    | static CONTROL_WINDOW_FIRST = 4
    | static CONTROL_START_INITIAL = 256
    | static RESULT_UNCHANGED_SHOWN = 0
    | static SHOW_IM_PICKER_MODE_AUTO = 0
    | static SHOW_IMPLICIT = 1
    | static CONTROL_WINDOW_VIEW_HAS_FOCUS = 1
    | static CONTROL_SHOW_INPUT = 65536
    | static MSG_DUMP = 1
    | static TAG = java.lang.String@1879246288 (0x700305d0)
    | static SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES = 2
    | static MSG_SEND_INPUT_EVENT = 5
    | static INPUT_METHOD_NOT_RESPONDING_TIMEOUT = 2500
    | static DEBUG = false
    | static PENDING_EVENT_COUNTER = java.lang.String@1879313800 (0x70040d88)
    | static RESULT_SHOWN = 2
    | static DISPATCH_IN_PROGRESS = -1
    | static MSG_FLUSH_INPUT_EVENT = 7
    | static $staticOverhead = byte[272]@1884161929 (0x704e0789)
    | static CONTROL_WINDOW_IS_TEXT_EDITOR = 2
    | static MSG_TIMEOUT_INPUT_EVENT = 6
    | static MSG_BIND = 2
    | static DISPATCH_HANDLED = 1
    | static SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES = 1
    | static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9
    | static HIDE_IMPLICIT_ONLY = 1
    | mActive = true
    | mBindSequence = 3227
    | mClient = android.view.inputmethod.InputMethodManager$1@318876576 (0x1301aba0)
    | mCompletions = null
    | mCurChannel = android.view.InputChannel@320338432 (0x1317fa00)
    | mCurId = java.lang.String@323088288 (0x1341efa0)
    | mCurMethod = com.android.internal.view.IInputMethodSession$Stub$Proxy@320338416 (0x1317f9f0)
    | mCurRootView = com.android.internal.policy.PhoneWindow$DecorView@318061568 (0x12f53c00)
    | mCurSender = null
    | mCurrentTextBoxAttribute = null
    | mCursorAnchorInfo = null
    | mCursorCandEnd = 0
    | mCursorCandStart = 0
    | mCursorRect = android.graphics.Rect@318876512 (0x1301ab60)
    | mCursorSelEnd = 0
    | mCursorSelStart = 0
    | mDummyInputConnection = android.view.inputmethod.BaseInputConnection@318876608 (0x1301abc0)
    | mFullscreenMode = false
    | mH = android.view.inputmethod.InputMethodManager$H@318876640 (0x1301abe0)
    | mHasBeenInactive = false
    | mIInputContext = android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper@318907056 (0x130222b0)
    | mInTransition = false
    | mLastSentUserActionNotificationSequenceNumber = -1
    | mLastSrvView = com.android.internal.policy.PhoneWindow$DecorView@321232896 (0x1325a000)
    | mMainLooper = android.os.Looper@315356736 (0x12cbf640)
    | mNextServedView = null
    | mNextUserActionNotificationSequenceNumber = 2
    | mPendingEventPool = android.util.Pools$SimplePool@318437344 (0x12faf7e0)
    | mPendingEvents = android.util.SparseArray@318876544 (0x1301ab80)
    | mRequestUpdateCursorAnchorInfoMonitorMode = 0
    | mSecImmHelper = huawei.android.view.inputmethod.HwSecImmHelper@318437360 (0x12faf7f0)
    | mServedConnecting = false
    | mServedInputConnection = null
    | mServedInputConnectionWrapper = null
    | mServedView = null
    | mService = com.android.internal.view.IInputMethodManager$Stub$Proxy@318437328 (0x12faf7d0)
    | mTmpCursorRect = android.graphics.Rect@318876480 (0x1301ab40)
    | shadow$klass = android.view.inputmethod.InputMethodManager
    | shadow$monitor = 0
  • Instance of com.android.internal.policy.PhoneWindow$DecorView
    | mBackgroundFallback = com.android.internal.widget.BackgroundFallback@317783504 (0x12f0fdd0)
    | mBackgroundPadding = android.graphics.Rect@319036608 (0x13041cc0)
    | mBarEnterExitDuration = 250
    | mChanging = false
    | mDefaultOpacity = -1
    | mDownY = 0
    | mDrawingBounds = android.graphics.Rect@319036576 (0x13041ca0)
    | mFadeAnim = null
    | mFeatureId = -1
    | mFloatingActionMode = null
    | mFloatingActionModeOriginatingView = null
    | mFloatingToolbar = null
    | mFloatingToolbarPreDrawListener = null
    | mFrameOffsets = android.graphics.Rect@319036704 (0x13041d20)
    | mFramePadding = android.graphics.Rect@319036640 (0x13041ce0)
    | mHideInterpolator = android.view.animation.PathInterpolator@319036928 (0x13041e00)
    | mLastBottomInset = 108
    | mLastHasBottomStableInset = true
    | mLastHasRightStableInset = false
    | mLastHasTopStableInset = true
    | mLastRightInset = 0
    | mLastTopInset = 72
    | mLastWindowFlags = -2122252032
    | mMenuBackground = null
    | mNavigationColorViewState = com.android.internal.policy.PhoneWindow$ColorViewState@322392176 (0x13375070)
    | mNavigationGuard = null
    | mPrimaryActionMode = null
    | mPrimaryActionModePopup = null
    | mPrimaryActionModeView = null
    | mRootScrollY = 0
    | mShowInterpolator = android.view.animation.PathInterpolator@319036800 (0x13041d80)
    | mShowPrimaryActionModePopup = null
    | mStatusColorViewState = com.android.internal.policy.PhoneWindow$ColorViewState@322392128 (0x13375040)
    | mStatusGuard = null
    | mWatchingForMenu = false
    | this$0 = com.android.internal.policy.HwPhoneWindow@315754672 (0x12d208b0)
    | mForegroundPaddingBottom = 0
    | mForegroundPaddingLeft = 0
    | mForegroundPaddingRight = 0
    | mForegroundPaddingTop = 0
    | mMatchParentChildren = java.util.ArrayList@319036512 (0x13041c60)
    | mMeasureAllChildren = false
    | mOverlayBounds = android.graphics.Rect@319036480 (0x13041c40)
    | mSelfBounds = android.graphics.Rect@319036448 (0x13041c20)
    | mAnimationListener = null
    | mCachePaint = null
    | mChildAcceptsDrag = false
    | mChildCountWithTransientState = 0
    | mChildTransformation = null
    | mChildren = android.view.View[12]@318607296 (0x12fd8fc0)
    | mChildrenCount = 3
    | mCurrentDrag = null
    | mCurrentDragView = null
    | mDisappearingChildren = null
    | mDragNotifiedChildren = null
    | mFirstHoverTarget = null
    | mFirstTouchTarget = null
    | mFocused = null
    | mGroupFlags = 2375763
    | mHoveredSelf = false
    | mInvalidateRegion = null
    | mInvalidationTransformation = null
    | mLastTouchDownIndex = 0
    | mLastTouchDownTime = 70906882
    | mLastTouchDownX = 43.0
    | mLastTouchDownY = 158.0
    | mLayoutAnimationController = null
    | mLayoutCalledWhileSuppressed = false
    | mLayoutMode = -1
    | mLayoutTransitionListener = android.view.ViewGroup$2@317783472 (0x12f0fdb0)
    | mLocalPoint = null
    | mNestedScrollAxes

@ant-github
Copy link

FAILURE:
java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack available

  • Reference Key: 3f876ccd-3f51-44f3-b397-400184455fd8
  • Device: samsung samsung SAMSUNG-SM-G900A klteuc
  • Android Version: 5.1.1 API: 22 LeakCanary: 1.4-beta2 3799172
  • Durations: watch=5071ms, gc=253ms, heap dump=7815ms, analysis=23215ms
  • Excluded Refs:
    | Field: android.view.inputmethod.InputMethodManager.mNextServedView
    | Field: android.view.inputmethod.InputMethodManager.mServedView
    | Field: android.view.inputmethod.InputMethodManager.mServedInputConnection
    | Field: android.view.inputmethod.InputMethodManager.mCurRootView
    | Field: android.animation.LayoutTransition$1.val$parent
    | Field: android.view.textservice.SpellCheckerSession$1.this$0
    | Field: android.support.v7.internal.widget.ActivityChooserModel.mActivityChoserModelPolicy
    | Field: android.widget.ActivityChooserModel.mActivityChoserModelPolicy
    | Field: android.accounts.AccountManager$AmsTask$Response.this$1
    | Field: android.media.MediaScannerConnection.mContext
    | Field: android.os.UserManager.mContext
    | Field: android.media.AudioManager$1.this$0
    | Field: android.widget.Editor$Blink.this$0
    | Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
    | Static field: android.text.TextLine.sCached
    | Thread:FinalizerWatchdogDaemon (always)
    | Thread:main (always)
    | Thread:LeakCanary-Heap-Dump (always)
    | Class:java.lang.ref.WeakReference (always)
    | Class:java.lang.ref.SoftReference (always)
    | Class:java.lang.ref.PhantomReference (always)
    | Class:java.lang.ref.Finalizer (always)
    | Class:java.lang.ref.FinalizerReference (always)
    | Root Class:android.os.Binder (always)

@ant-github
Copy link

ant-github commented Jul 14, 2016

Not able to get if this is an issue or not . Log showing NO LEAK FOUND, but still get the Leak Canary warning" App will freeze for some time".

D/LeakCanary: In ********:1.14:4.
* NO LEAK FOUND.

                                                          * Reference Key: ebf12938-5a5f-425b-9ba6-fe137588b92a
                                                          * Device: Xiaomi Xiaomi Redmi Note 3 kenzo
                                                          * Android Version: 5.1.1 API: 22 LeakCanary: 1.4-beta2 3799172
                                                          * Durations: watch=5034ms, gc=326ms, heap dump=1987ms, analysis=6309ms
                                                          * Excluded Refs:
                                                          | Field: android.view.inputmethod.InputMethodManager.mNextServedView
                                                          | Field: android.view.inputmethod.InputMethodManager.mServedView
                                                          | Field: android.view.inputmethod.InputMethodManager.mServedInputConnection
                                                          | Field: android.view.inputmethod.InputMethodManager.mCurRootView
                                                          | Field: android.animation.LayoutTransition$1.val$parent
                                                          | Field: android.view.textservice.SpellCheckerSession$1.this$0
                                                          | Field: android.support.v7.internal.widget.ActivityChooserModel.mActivityChoserModelPolicy
                                                          | Field: android.widget.ActivityChooserModel.mActivityChoserModelPolicy
                                                          | Field: android.accounts.AccountManager$AmsTask$Response.this$1
                                                          | Field: android.media.MediaScannerConnection.mContext
                                                          | Field: android.os.UserManager.mContext
                                                          | Field: android.media.AudioManager$1.this$0
                                                          | Field: android.widget.Editor$Blink.this$0
                                                          | Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
                                                          | Static field: android.text.TextLine.sCached
                                                          | Thread:FinalizerWatchdogDaemon (always)
                                                          | Thread:main (always)
                                                          | Thread:LeakCanary-Heap-Dump (always)
                                                          | Class:java.lang.ref.WeakReference (always)
                                                          | Class:java.lang.ref.SoftReference (always)
                                                          | Class:java.lang.ref.PhantomReference (always)
                                                          | Class:java.lang.ref.Finalizer (always)
                                                          | Class:java.lang.ref.FinalizerReference (always)
                                                          | Root Class:android.os.Binder (always)

Pengchengxiang pushed a commit to XLibrarys/leakcanary that referenced this issue Jan 2, 2017
See square#322

Also directly reference Lollipop constant.
@tmtrademarked
Copy link

As noted in this bug thread (https://code.google.com/p/android/issues/detail?id=205171) spun off from the original report, there's a similar leak that still manifests on M. The original fix required patching, so the exclusion may need to be adjusted upward.

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

8 participants