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

Another framework InputMethodManager leak (Moto G 4.4.4) #2

Closed
teslacoil opened this issue May 8, 2015 · 3 comments
Closed

Another framework InputMethodManager leak (Moto G 4.4.4) #2

teslacoil opened this issue May 8, 2015 · 3 comments

Comments

@teslacoil
Copy link

LeakCanary is awesome, I love the work you guys do.

I was going to introduce some leaks intentionally to test, but found this one instead. Seems to be a Motorola-ism as AOSP KitKat doesn't have an InputMethodManager.sInstance .

In com.teslacoilsw.launcher:#materinova.30:39030.
* com.teslacoilsw.launcher.preferences.fragments.DockPreferences 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
* references com.teslacoilsw.launcher.preferences.SettingsActivity.mDelegate
* references android.support.v7.app.AppCompatDelegateImplV11.mActionBar
* references android.support.v7.internal.app.ToolbarActionBar.mDecorToolbar
* references android.support.v7.internal.widget.ToolbarWidgetWrapper.mToolbar
* references com.teslacoilsw.launcher.widget.FontFamilyToolbar.mMenuView
* references android.support.v7.widget.ActionMenuView.mPresenter
* references android.support.v7.widget.ActionMenuPresenter.mScrapActionButtonView
* references android.widget.FrameLayout.mChildren
* references array android.view.View[].[0]
* references com.teslacoilsw.launcher.widget.TintableSwitchCompat.mOnCheckedChangeListener
* references com.teslacoilsw.launcher.preferences.fragments.DockPreferences$1.this$0 (anonymous class implements android.widget.CompoundButton$OnCheckedChangeListener)
* leaks com.teslacoilsw.launcher.preferences.fragments.DockPreferences instance

* Reference Key: dee294f0-e103-4093-8556-5b0d59cfac16
* Device: motorola motorola XT1063 titan_retuglb
* Android Version: 4.4.4 API: 19
* Durations: watch=5007ms, gc=169ms, heap dump=719ms, analysis=18455ms

Motorola system version: 21.11.23.titan_retuglb.retuglb.en.US retus
@pyricau
Copy link
Member

pyricau commented May 9, 2015

I can't answer that question for sure without the heap dump, it's unclear what this leak is about.

SettingsActivity is not the leaking instance, so I'm going to assume it wasn't destroyed, otherwise you would probably have posted that as well. The leak here is DockPreferences, which I'm assuming is a fragment.

From what I can read, this is very likely a leak in your app. In DockPreferences you set an OnCheckedChangeListener on a TintableSwitchCompat that is a switch that seems to be living in the action bar. Then you probably do a fragment transaction, the DockPreferences fragment gets destroyed, but the action bar is still living and holding to that OnCheckedChangeListener. You should probably remove the listener when the fragment is destroyed.

I'm going to close this issue, but please follow up and let me know if that was it. It's kind of hard to do that without the codebase.

@pyricau pyricau closed this as completed May 9, 2015
@teslacoil
Copy link
Author

I'm actually now seeing this on Samsung kitkat as well, here's one with a full activity leak:

        LeakCanary  D  In com.teslacoilsw.launcher:#materinova.30:39030.
                    D  * com.teslacoilsw.launcher.theme.PickerActivity has leaked:
                    D  * GC ROOT static android.view.inputmethod.InputMethodManager.sInstance
                    D  * references android.view.inputmethod.InputMethodManager.mCurRootView
                    D  * references com.android.internal.policy.impl.PhoneWindow$DecorView.mContext
                    D  * leaks com.teslacoilsw.launcher.theme.PickerActivity instance
                    D  * Reference Key: d1220cf1-106c-408b-8d4b-25518c740ac6
                    D  * Device: samsung samsung SAMSUNG-SGH-I337 jflteuc
                    D  * Android Version: 4.4.2 API: 19
                    D  * Durations: watch=5013ms, gc=176ms, heap dump=683ms, analysis=21287ms

hprof: http://teslacoilsw.com/tmp/inputmethodmanager_sinstance_dump.hprof

And the Moto G again, this time with an activity leak:

        LeakCanary  D  In com.teslacoilsw.launcher:#materinova.30:39030.
                    D  * com.teslacoilsw.launcher.theme.PickerActivity has leaked:
                    D  * GC ROOT static android.view.inputmethod.InputMethodManager.sInstance
                    D  * references android.view.inputmethod.InputMethodManager.mCurRootView
                    D  * references com.android.internal.policy.impl.PhoneWindow$DecorView.mContext
                    D  * leaks com.teslacoilsw.launcher.theme.PickerActivity instance
                    D  * Reference Key: 3a630c98-7475-4aa4-afc7-d4d0dc6d280e
                    D  * Device: motorola motorola XT1063 titan_retuglb
                    D  * Android Version: 4.4.4 API: 19
                    D  * Durations: watch=5025ms, gc=152ms, heap dump=471ms, analysis=15821ms

I'm seeing it triggered by doing a startActivityForResult into a new process, so there is only one activity there and it gets onDestroyed at the end with nothing else in that process.

It looks like basically the same issue as the InputMethodManager mCurRootView, it's just the trace is a bit different thanks to the sInstance.

@pyricau
Copy link
Member

pyricau commented May 13, 2015

Known AOSP leak, already reported in #1. 1.3.1-SNAPSHOT already ignores this leak.

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

No branches or pull requests

1 participant