Leakcanary: Leak android.gestureboost.GestureBoostManager , Android 7.0

Created on 9 Feb 2017  ·  21Comments  ·  Source: square/leakcanary

com.zxsd.shoppingguide.activity.AggregationEntryActivity has leaked:
GC ROOT static android.gestureboost.GestureBoostManager.sGestureBoostManager
references android.gestureboost.GestureBoostManager.mContext
leaks com.zxsd.shoppingguide.activity.AggregationEntryActivity instance
Retaining: 4.9 KB.
Reference Key: def072d8-5909-4709-9365-9a244a488e02
Device: HUAWEI honor FRD-AL10 FRD-AL10
Android Version: 7.0 API: 24 LeakCanary: 1.5 00f37f5
Durations: watch=5011ms, gc=173ms, heap dump=1862ms, analysis=103468ms
Details:
Class android.gestureboost.GestureBoostManager
static sGestureBoostManager = android.gestureboost.GestureBoostManager@317230672 (0x12e88e50)
static SWITCH_GESTURE_BOOST = 4
static $classOverhead = byte[652]@318563329 (0x12fce401)
static TAG = java.lang.String@1896298040 (0x71073638)
static GESTURE_BOOST_CODE = 10001
static RMS_EXT_CODE_BASE = 10000
Instance of android.gestureboost.GestureBoostManager
static sGestureBoostManager = android.gestureboost.GestureBoostManager@317230672 (0x12e88e50)
static SWITCH_GESTURE_BOOST = 4
static $classOverhead = byte[652]@318563329 (0x12fce401)
static TAG = java.lang.String@1896298040 (0x71073638)
static GESTURE_BOOST_CODE = 10001
static RMS_EXT_CODE_BASE = 10000
mAwareService = null
mContext = com.zxsd.shoppingguide.activity.AggregationEntryActivity@315123200 (0x12c86600)
mGestureBoostflag = false
shadow$_klass_ = android.gestureboost.GestureBoostManager
shadow$_monitor_ = 0
Instance of com.zxsd.shoppingguide.activity.AggregationEntryActivity
static $change = null
static $classOverhead = byte[4544]@316317697 (0x12daa001)
static serialVersionUID = 0
appBarLayout = android.support.design.widget.AppBarLayout@320813056 (0x131f3800)
btnLeft = android.support.v7.widget.AppCompatTextView@321179648 (0x1324d000)
btnRight = android.support.v7.widget.AppCompatTextView@321239040 (0x1325b800)
btnRightTwo = android.support.v7.widget.AppCompatTextView@321226752 (0x13258800)
bundle = android.os.Bundle@320594560 (0x131be280)
container = android.widget.FrameLayout@321443840 (0x1328d800)
fragment = com.zxsd.shoppingguide.fragment.AggregationEntryFragment@315122880 (0x12c864c0)
imgBack = android.support.v7.widget.AppCompatImageButton@321182720 (0x1324dc00)
imgMore = android.support.v7.widget.AppCompatImageButton@321236992 (0x1325b000)
layoutId = 2130968603
toolbar = android.support.v7.widget.Toolbar@321156096 (0x13247400)
toolbarTitle = android.support.v7.widget.AppCompatTextView@321447936 (0x1328e800)
mDelegate = android.support.v7.app.AppCompatDelegateImplN@314888832 (0x12c4d280)
mEatKeyUpEvent = false
mResources = null
mThemeId = 2131361857
mCreated = true
mFragments = android.support.v4.app.FragmentController@316415936 (0x12dc1fc0)
mHandler = android.support.v4.app.FragmentActivity$1@319517120 (0x130b71c0)
mNextCandidateRequestIndex = 0
mOptionsMenuInvalidated = false
mPendingFragmentActivityResults = android.support.v4.util.SparseArrayCompat@320594752 (0x131be340)
mReallyStopped = true
mRequestedPermissionsFromFragment = false
mResumed = false
mRetaining = false
mStopped = true
mStartedActivityFromFragment = false
mStartedIntentSenderFromFragment = false
mExtraDataMap = android.support.v4.util.SimpleArrayMap@320428232 (0x131958c8)
mActionBar = null
mActionModeTypeStarting = 0
mActivityInfo = android.content.pm.ActivityInfo@314890272 (0x12c4d820)
mActivityTransitionState = android.app.ActivityTransitionState@319133112 (0x130595b8)
mApplication = com.zxsd.shoppingguide.base.App@314610440 (0x12c09308)
mCalled = true
mChangeCanvasToTranslucent = false
mChangingConfigurations = false
mComponent = android.content.ComponentName@316292864 (0x12da3f00)
mConfigChangeFlags = 0
mCurrentConfig = android.content.res.Configuration@315840584 (0x12d35848)
mCustActivity = android.app.HwCustActivityImpl@320428280 (0x131958f8)
mDecor = null
mDefaultKeyMode = 0
mDefaultKeySsb = null
mDestroyed = true
mDoReportFullyDrawn = false
mEatKeyUpEvent = false
mEmbeddedID = null
mEnableDefaultActionBarUp = false
mEnterTransitionListener = android.app.SharedElementCallback$1@1903589792 (0x717679a0)
mExitTransitionListener = android.app.SharedElementCallback$1@1903589792 (0x717679a0)
mFinished = true
mFragments = android.app.FragmentController@315343056 (0x12cbc0d0)
mHandler = android.os.Handler@319517376 (0x130b72c0)
mHasCurrentPermissionsRequest = false
mIdent = 132658027
mInstanceTracker = android.os.StrictMode$InstanceTracker@315343040 (0x12cbc0c0)
mInstrumentation = android.app.Instrumentation@314812664 (0x12c3a8f8)
mIntent = android.content.Intent@316886976 (0x12e34fc0)
mIsFullFlag = false
mLastNonConfigurationInstances = null
mMainThread = android.app.ActivityThread@314720608 (0x12c24160)
mManagedCursors = java.util.ArrayList@320428448 (0x131959a0)
mManagedDialogs = null
mMenuInflater = null
mParent = null
mReferrer = java.lang.String@316886208 (0x12e34cc0)
mResultCode = 0
mResultData = null
mResumed = false
mSearchEvent = null
mSearchManager = null
mStartedActivity = false
mStopped = true
mTaskDescription = android.app.ActivityManager$TaskDescription@319517344 (0x130b72a0)
mTemporaryPause = false
mTitle = java.lang.String@1894097920 (0x70e5a400)
mTitleColor = 0
mTitleReady = true
mToken = android.os.BinderProxy@319722752 (0x130e9500)
mTranslucentCallback = null
mUiThread = java.lang.Thread@2021072336 (0x78771dd0)
mVisibleBehind = false
mVisibleFromClient = true
mVisibleFromServer = true
mVoiceInteractor = null
mWindow = com.android.internal.policy.HwPhoneWindow@316763360 (0x12e16ce0)
mWindowAdded = true
mWindowManager = android.view.WindowManagerImpl@319860576 (0x1310af60)
mInflater = com.android.internal.policy.HwPhoneLayoutInflater@317001248 (0x12e50e20)
mOverrideConfiguration = null
mResources = android.content.res.HwResources@316474560 (0x12dd04c0)
mTheme = android.content.res.Resources$Theme@316415648 (0x12dc1ea0)
mThemeResource = 2131361857
mBase = android.app.ContextImpl@314838816 (0x12c40f20)
shadow$_klass_ = com.zxsd.shoppingguide.activity.AggregationEntryActivity
shadow$_monitor_ = 1073743756
Excluded Refs:
Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
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)

leak

Most helpful comment

I have a workaround:

    static void fixLeakCanary696(Context context) {
        if (!isEmui()) {
            Log.w(TAG, "not emui");
            return;
        }
        try {
            Class clazz = Class.forName("android.gestureboost.GestureBoostManager");
            Log.w(TAG, "clazz " + clazz);

            Field _sGestureBoostManager = clazz.getDeclaredField("sGestureBoostManager");
            _sGestureBoostManager.setAccessible(true);
            Field _mContext = clazz.getDeclaredField("mContext");
            _mContext.setAccessible(true);

            Object sGestureBoostManager = _sGestureBoostManager.get(null);
            if (sGestureBoostManager != null) {
                _mContext.set(sGestureBoostManager, context);
            }
        } catch (Exception ignored) {
            ignored.printStackTrace();
        }
    }

Call fixLeakCanary696(getApplicationContext()) in Activity.onDestroy.

All 21 comments

Seems a bug of huawei(EmotionUI) OS. I can not find the source code of class GestureBoostManager.

GC ROOT static android.gestureboost.GestureBoostManager.sGestureBoostManager
* references android.gestureboost.GestureBoostManager.mContext
* references org.chromium.android_webview.ResourcesContextWrapperFactory$WebViewContextWrapper.mBase

Maybe you can

sGestureBoostManager. mContext =  AggregationEntryActivity.this.getApplicationContext() // reference a global context?

@zhangXiaolizi @gaoyan10 Did you find the answer?

@ruijun 没有,我在华为的论坛里面反馈过这个问题,也一直没得到回复呢。

@zhangXiaolizi 我也出现过这个问题,但找不到是哪里用到引起的,你有头绪吗?

@ruijun @zhangXiaolizi 在AggregationEntryActivity中有用自定义的webview吗?

@marekchen 我的是没有,你有遇到过类似的问题?

@ruijun

GC ROOT static android.gestureboost.GestureBoostManager.sGestureBoostManager
* references android.gestureboost.GestureBoostManager.mContext
* references org.chromium.android_webview.ResourcesContextWrapperFactory$WebViewContextWrapper.mBase

从leak信息看,应该是和webview 是有关的,我的页面中有webview。

@ruijun 应该是华为系统的一个漏洞。我的没有WebView的页面也会出现这种情况,我的之前是6.0的时候没有这个泄漏,在更新到EMUI5.0 android 7.0的时候出现的这个泄漏

我今天也遇到这个问题了

何止是 webview,输入法也有问题,坑死人了。

总之有几个华为的泄漏,

InputMehtodManager.mLastSrvView DecorView.mContentRoot LineLayout.mContext leaks MusicActivity instance

In co:2.0:9.

  • com..activity.MusicActivity has leaked:
  • GC ROOT android.view.inputmethod.InputMethodManager$1.this$0 (anonymous subclass of com.android.internal.view.IInputMethodClient$Stub)
  • references android.view.inputmethod.InputMethodManager.mLastSrvView
  • references com.android.internal.policy.DecorView.mContentRoot
  • references android.widget.LinearLayout.mContext
  • leaks com.buyao.tv.activity.MusicActivity instance
  • Retaining: 8.1 KB.
  • Reference Key: 7b8780b2-392c-43a8-bf73-a4295e04b1de
  • Device: HUAWEI honor FRD-AL10 FRD-AL10
  • Android Version: 7.0 API: 24 LeakCanary: 1.5 00f37f5
  • Durations: watch=5009ms, gc=166ms, heap dump=4478ms, analysis=97279ms

  • Details:

  • Instance of android.view.inputmethod.InputMethodManager$1
    | static $classOverhead = byte[776]@1886462817 (0x70712361)
    | this$0 = android.view.inputmethod.InputMethodManager@317596720 (0x12ee2430)
    | mDescriptor = java.lang.String@1876560216 (0x6fda0958)
    | mObject = 537637236080
    | mOwner = android.view.inputmethod.InputMethodManager$1@315134528 (0x12c89240)
    | shadow$_klass_ = android.view.inputmethod.InputMethodManager$1
    | shadow$_monitor_ = 0
  • Instance of android.view.inputmethod.InputMethodManager
    | static MSG_UNBIND = 3
    | static DISPATCH_HANDLED = 1
    | static SHOW_IM_PICKER_MODE_AUTO = 0
    | static SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_S

同款手机 同款漏洞

华为p9,Android7.0,也经常遇到这个问题。查了很久也没查到,7.1.1的sdk里都没有这个类,应该是华为自己加的类,EMUI5.0的bug。

HuaWei Honor 8, FRD-AL00
Android 7.0, level 24
HuaWei/EMOTION 5.0

I have a workaround:

    static void fixLeakCanary696(Context context) {
        if (!isEmui()) {
            Log.w(TAG, "not emui");
            return;
        }
        try {
            Class clazz = Class.forName("android.gestureboost.GestureBoostManager");
            Log.w(TAG, "clazz " + clazz);

            Field _sGestureBoostManager = clazz.getDeclaredField("sGestureBoostManager");
            _sGestureBoostManager.setAccessible(true);
            Field _mContext = clazz.getDeclaredField("mContext");
            _mContext.setAccessible(true);

            Object sGestureBoostManager = _sGestureBoostManager.get(null);
            if (sGestureBoostManager != null) {
                _mContext.set(sGestureBoostManager, context);
            }
        } catch (Exception ignored) {
            ignored.printStackTrace();
        }
    }

Call fixLeakCanary696(getApplicationContext()) in Activity.onDestroy.

@Piasy 能问下你这段代码
为什么给静态成员【sGestureBoostManager.mContext】 赋值ApplicationContext就不会泄露了?

@anyway-whatever 你不知道ApplicationContext跟普通activity context的区别?ApplicationContext全局唯一,生命周期跟app一样长,泄漏什么?

相同的问题。这个处理需要写在基类里把

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BraisGabin picture BraisGabin  ·  6Comments

willswinson picture willswinson  ·  6Comments

msfjarvis picture msfjarvis  ·  6Comments

peter1492 picture peter1492  ·  6Comments

edgelv34 picture edgelv34  ·  7Comments