Closed Bug 1407835 Opened 7 years ago Closed 7 years ago

Memory leak: GeckoAppShell.sScreenOrientationDelegate

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(firefox58 fixed)

RESOLVED FIXED
Firefox 58
Tracking Status
firefox58 --- fixed

People

(Reporter: mcomella, Assigned: JanH)

References

Details

Attachments

(1 file)

I got this from LeakCanary on my local build:

In org.mozilla.fennec_mcomella:58.0a1:2015517169.
* org.mozilla.gecko.BrowserApp has leaked:
* GC ROOT static org.mozilla.gecko.GeckoAppShell.sScreenOrientationDelegate
* leaks org.mozilla.gecko.BrowserApp instance

* Retaining: 1,0 MB.
* Reference Key: fcd896a0-b8df-401e-b202-64ac7207881e
* Device: LGE google Nexus 5 hammerhead
* Android Version: 6.0.1 API: 23 LeakCanary: 1.4-beta1 02804f3
* Durations: watch=5053ms, gc=162ms, heap dump=5741ms, analysis=33013ms

* Details:
* Class org.mozilla.gecko.GeckoAppShell
|   static sScreenOrientationDelegate = org.mozilla.gecko.BrowserApp@853501472 (0x32df6620)
|   static sWakeLockDelegate = org.mozilla.gecko.GeckoAppShell$DefaultListeners@855960848 (0x3304ed10)
|   static sScreenSize = android.graphics.Rect@856008992 (0x3305a920)
|   static LINK_TYPE_ETHERNET = 1
|   static gLinearAccelerometerSensor = null
|   static gOrientationSensor = null
|   static LINK_TYPE_UNKNOWN = 0
|   static kPreferredFPS = 25
|   static gAccelerometerSensor = null
|   static sDensityDpi = 480
|   static LINK_TYPE_4G = 7
|   static DEFAULT_LISTENERS = org.mozilla.gecko.GeckoAppShell$DefaultListeners@855960848 (0x3304ed10)
|   static sNotificationListener = org.mozilla.gecko.notifications.NotificationClient@856008960 (0x3305a900)
|   static sVibrationEndTime = 0
|   static sCameraBuffer = null
|   static sScreenDepth = 24
|   static gGyroscopeSensor = null
|   static gGameRotationVectorSensor = null
|   static LINK_TYPE_USB = 2
|   static CRASH_HANDLER = org.mozilla.gecko.GeckoAppShell$1@853603456 (0x32e0f480)
|   static PREFS_OOM_EXCEPTION = java.lang.String@852185248 (0x32cb50a0)
|   static sLocationListener = org.mozilla.gecko.GeckoAppShell$DefaultListeners@855960848 (0x3304ed10)
|   static sApplicationContext = org.mozilla.gecko.GeckoApplication@853772416 (0x32e38880)
|   static LINK_TYPE_WIMAX = 4
|   static LINK_TYPE_2G = 5
|   static gRotationVectorSensor = null
|   static $staticOverhead = byte[336]@851540993 (0x32c17c01)
|   static gLightSensor = null
|   static WPL_STATE_START = 1
|   static WPL_STATE_IS_NETWORK = 262144
|   static sCamera = null
|   static HIGH_MEMORY_DEVICE_THRESHOLD_MB = 768
|   static sVibrationMaybePlaying = false
|   static LINK_TYPE_3G = 6
|   static sGeckoInterface = org.mozilla.gecko.GeckoApplication$2@855960864 (0x3304ed20)
|   static sHapticFeedbackDelegate = org.mozilla.gecko.GeckoApplication@853772416 (0x32e38880)
|   static locationHighAccuracyEnabled = false
|   static LOGTAG = java.lang.String@851758192 (0x32c4cc70)
|   static gProximitySensor = null
|   static LINK_TYPE_WIFI = 3
|   static WPL_STATE_STOP = 16
|   static WPL_STATE_IS_DOCUMENT = 131072
|   static sSensorListener = org.mozilla.gecko.GeckoAppShell$DefaultListeners@855960848 (0x3304ed10)
* Instance of org.mozilla.gecko.BrowserApp
|   static sTabsInterpolator = org.mozilla.gecko.BrowserApp$1@855897568 (0x3303f5e0)
|   static ACTIVITY_RESULT_FIRST_READERVIEW_BOOKMARKS_GOTO_BOOKMARKS = 3002
|   static ACTIVITY_REQUEST_TAB_QUEUE = 2001
|   static EOL_NOTIFIED = java.lang.String@851755264 (0x32c4c100)
|   static TAB_HISTORY_FRAGMENT_TAG = java.lang.String@852197504 (0x32cb8080)
|   static ACTIVITY_REQUEST_TRIPLE_READERVIEW = 4001
|   static ACTION_VIEW_MULTIPLE = java.lang.String@851979616 (0x32c82d60)
|   static INTENT_KEY_SWITCHBOARD_SERVER = java.lang.String@851738048 (0x32c47dc0)
|   static ACTIVITY_RESULT_TRIPLE_READERVIEW_ADD_BOOKMARK = 4002
|   static TABS_ANIMATION_DURATION = 450
|   static STATE_ABOUT_HOME_TOP_PADDING = java.lang.String@852155200 (0x32cadb40)
|   static GECKO_TOOLS_MENU = -1
|   static ACTIVITY_RESULT_TRIPLE_READERVIEW_IGNORE = 4003
|   static ACTIVITY_RESULT_FIRST_READERVIEW_BOOKMARKS_IGNORE = 3003
|   static ACTIVITY_REQUEST_FIRST_READERVIEW_BOOKMARK = 3001
|   static $staticOverhead = byte[184]@852635649 (0x32d23001)
|   static FEEDBACK_LAUNCH_COUNT = 15
|   static ADDON_MENU_OFFSET = 1000
|   static BROWSER_SEARCH_TAG = java.lang.String@852187936 (0x32cb5b20)
|   static EXTRA_SKIP_STARTPANE = java.lang.String@851949936 (0x32c7b970)
|   static BROWSER_ACTION_MENU_OFFSET = 10000
|   static SWITCHBOARD_SERVER = java.lang.String@851952192 (0x32c7c240)
|   static LOGTAG = java.lang.String@852205184 (0x32cb9e80)
|   static ACTIVITY_REQUEST_PREFERENCES = 1001
|   delegates = java.util.Collections$UnmodifiableRandomAccessList@854029728 (0x32e775a0)
|   doorhangerOverlay = android.view.View@852206736 (0x32cba490)
|   mAccountsHelper = null
|   mActionBar = org.mozilla.gecko.ActionModeCompatView@853553152 (0x32e03000)
|   mActionBarFlipper = android.widget.ViewFlipper@853554176 (0x32e03400)
|   mActionMode = null
|   mAddonMenuItemsCache = java.util.ArrayList@854130176 (0x32e8fe00)
|   mBrowserActionItemsCache = null
|   mBrowserChrome = android.widget.LinearLayout@853555200 (0x32e03800)
|   mBrowserSearch = org.mozilla.gecko.home.BrowserSearch@851884288 (0x32c6b900)
|   mBrowserSearchContainer = android.widget.FrameLayout@853556224 (0x32e03c00)
|   mBrowserToolbar = org.mozilla.gecko.toolbar.BrowserToolbarPhone@853557248 (0x32e04000)
|   mCachedRecentTabsCount = 0
|   mCheckLongPress = null
|   mDynamicToolbar = org.mozilla.gecko.DynamicToolbar@854130208 (0x32e8fe20)
|   mExtensionPermissionsHelper = null
|   mFindInPageBar = null
|   mFirstrunAnimationContainer = null
|   mHasResumed = false
|   mHideWebContentOnAnimationEnd = false
|   mHomeScreen = org.mozilla.gecko.home.HomePager@853558272 (0x32e04400)
|   mHomeScreenContainer = android.widget.FrameLayout@853559296 (0x32e04800)
|   mLastTabEditingState = org.mozilla.gecko.toolbar.BrowserToolbar$TabEditingState@854130240 (0x32e8fe40)
|   mMainLayoutAnimator = null
|   mMediaCastingBar = null
|   mProgressView = org.mozilla.gecko.widget.AnimatedProgressBar@853560320 (0x32e04c00)
|   mReadingListHelper = null
|   mSearchEngineManager = org.mozilla.gecko.search.SearchEngineManager@854124912 (0x32e8e970)
|   mSharedPreferencesHelper = null
|   mShowingToolbarChromeForActionBar = false
|   mTabStrip = null
|   mTabsPanel = org.mozilla.gecko.tabs.TabsPanel@853561344 (0x32e05000)
|   mTargetTabForEditingMode = null
|   mTelemetryCorePingDelegate = org.mozilla.gecko.telemetry.TelemetryCorePingDelegate@854130272 (0x32e8fe60)
|   mToolbarHeight = 168
|   mVideoPlayer = org.mozilla.gecko.media.VideoPlayer@853562368 (0x32e05400)
|   showSplashScreen = false
|   splashScreen = null
|   tabHistoryController = org.mozilla.gecko.tabs.TabHistoryController@854029744 (0x32e775b0)
|   foregrounded = false
|   mCameraOrientationEventListener = null
|   mDoorHangerPopup = null
|   mFormAssistPopup = null
|   mGeckoLayout = android.widget.RelativeLayout@853563392 (0x32e05800)
|   mGeckoReadyStartupTimer = org.mozilla.gecko.Telemetry$UptimeTimer@854130304 (0x32e8fe80)
|   mHealthRecorder = null
|   mInitialized = true
|   mIsAbortingAppLaunch = false
|   mIsRestoringActivity = false
|   mJavaUiStartupTimer = org.mozilla.gecko.Telemetry$UptimeTimer@854130336 (0x32e8fea0)
|   mLastLocale = java.util.Locale@853817216 (0x32e43780)
|   mLastSessionCrashed = false
|   mLayerView = org.mozilla.gecko.GeckoView@853564416 (0x32e05c00)
|   mMainLayout = org.mozilla.gecko.GeckoApp$MainLayout@853565440 (0x32e06000)
|   mMenu = org.mozilla.gecko.menu.GeckoMenu@852361216 (0x32ce0000)
|   mMenuPanel = org.mozilla.gecko.menu.MenuPanel@853566464 (0x32e06400)
|   mPrivateBrowsingSession = null
|   mPromptService = null
|   mRestartOnShutdown = false
|   mRootLayout = android.widget.RelativeLayout@853567488 (0x32e06800)
|   mSessionRestoreParsingFinished = true
|   mShouldRestore = false
|   mShutdownOnDestroy = false
|   mTextSelection = null
|   mWasFirstTabShownAfterActivityUnhidden = false
|   mWindowFocusInitialized = true
|   mDelegate = android.support.v7.app.AppCompatDelegateImplV23@853826048 (0x32e45a00)
|   mEatKeyUpEvent = false
|   mResources = null
|   mThemeId = 2131427648
|   mCreated = true
|   mFragments = android.support.v4.app.FragmentController@854029760 (0x32e775c0)
|   mHandler = android.support.v4.app.FragmentActivity$1@854130368 (0x32e8fec0)
|   mMediaController = null
|   mNextCandidateRequestIndex = 0
|   mOptionsMenuInvalidated = false
|   mPendingFragmentActivityResults = android.support.v4.util.SparseArrayCompat@854130400 (0x32e8fee0)
|   mReallyStopped = true
|   mRequestedPermissionsFromFragment = false
|   mResumed = false
|   mRetaining = false
|   mStartedActivityFromFragment = false
|   mStopped = true
|   mActionBar = null
|   mActionModeTypeStarting = 0
|   mActivityInfo = android.content.pm.ActivityInfo@853927808 (0x32e5e780)
|   mActivityTransitionState = android.app.ActivityTransitionState@854115072 (0x32e8c300)
|   mApplication = org.mozilla.gecko.GeckoApplication@853772416 (0x32e38880)
|   mCalled = true
|   mChangeCanvasToTranslucent = false
|   mChangingConfigurations = false
|   mComponent = android.content.ComponentName@854029776 (0x32e775d0)
|   mConfigChangeFlags = 0
|   mCurrentConfig = android.content.res.Configuration@853937888 (0x32e60ee0)
|   mDecor = null
|   mDefaultKeyMode = 0
|   mDefaultKeySsb = null
|   mDestroyed = true
|   mDoReportFullyDrawn = false
|   mEmbeddedID = null
|   mEnableDefaultActionBarUp = false
|   mEnterTransitionListener = android.app.SharedElementCallback$1@1868706608 (0x6f623330)
|   mExitTransitionListener = android.app.SharedElementCallback$1@1868706608 (0x6f623330)
|   mFinished = false
|   mFragments = android.app.FragmentController@854029792 (0x32e775e0)
|   mHandler = android.os.Handler@854130432 (0x32e8ff00)
|   mHasCurrentPermissionsRequest = false
|   mIdent = 40450512
|   mInstanceTracker = android.os.StrictMode$InstanceTracker@854029808 (0x32e775f0)
|   mInstrumentation = android.app.Instrumentation@853803184 (0x32e400b0)
|   mIntent = android.content.Intent@854115136 (0x32e8c340)
|   mLastNonConfigurationInstances = null
|   mMainThread = android.app.ActivityThread@851456256 (0x32c03100)
|   mManagedCursors = java.util.ArrayList@854130464 (0x32e8ff20)
|   mManagedDialogs = null
|   mMenuInflater = null
|   mParent = null
|   mReferrer = java.lang.String@854119056 (0x32e8d290)
|   mResultCode = 0
|   mResultData = null
|   mResumed = false
|   mSearchEvent = null
|   mSearchManager = null
|   mStartedActivity = false
|   mStopped = true
|   mTemporaryPause = false
|   mTitle = java.lang.String@853773856 (0x32e38e20)
|   mTitleColor = 0
|   mTitleReady = true
|   mToken = android.os.BinderProxy@854130496 (0x32e8ff40)
|   mTranslucentCallback = null
|   mUiThread = java.lang.Thread@1930179232 (0x730c32a0)
|   mVisibleBehind = false
|   mVisibleFromClient = true
|   mVisibleFromServer = false
|   mVoiceInteractor = null
|   mWindow = com.android.internal.policy.PhoneWindow@851982080 (0x32c83700)
|   mWindowAdded = true
|   mWindowManager = android.view.WindowManagerImpl@854130528 (0x32e8ff60)
|   mInflater = com.android.internal.policy.PhoneLayoutInflater@854124960 (0x32e8e9a0)
|   mOverrideConfiguration = null
|   mResources = android.content.res.Resources@853803344 (0x32e40150)
|   mTheme = android.content.res.Resources$Theme@854130560 (0x32e8ff80)
|   mThemeResource = 2131427648
|   mBase = android.app.ContextImpl@853927936 (0x32e5e800)
|   shadow$_klass_ = org.mozilla.gecko.BrowserApp
|   shadow$_monitor_ = 1257170192
* Excluded Refs:
| Field: android.view.inputmethod.InputMethodManager.mNextServedView
| Field: android.view.inputmethod.InputMethodManager.mServedView
| Field: android.view.inputmethod.InputMethodManager.mServedInputConnection
| 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)
| Root Class:android.os.Binder (always)
Assignee: nobody → jh+bugzilla
Blocks: 1321638
Luckily this is implemented as GeckoAppShell.*set*ScreenOrientationDelegate, so while this keeps BrowserApp unnecessarily alive, the old reference will be overwritten the next time BrowserApp is recreated again.

I notice that we're calling GeckoAppShell.setScreenOrientationDelegate(this) both from onCreate and onResume - Nick, is my theory correct that this is because in theory somebody else (such as now the custom tabs/web apps GeckoView instances) could set a different ScreenOrientationDelegate while BrowserApp is paused?
Flags: needinfo?(nalexander)
(In reply to Jan Henning [:JanH] from comment #1)
> Luckily this is implemented as GeckoAppShell.*set*ScreenOrientationDelegate,
> so while this keeps BrowserApp unnecessarily alive, the old reference will
> be overwritten the next time BrowserApp is recreated again.
> 
> I notice that we're calling GeckoAppShell.setScreenOrientationDelegate(this)
> both from onCreate and onResume - Nick, is my theory correct that this is
> because in theory somebody else (such as now the custom tabs/web apps
> GeckoView instances) could set a different ScreenOrientationDelegate while
> BrowserApp is paused?

I'm really not sure at this point.  I'd usually redirect to jchen, who has this stuff -- including GeckoView and Custom Tabs -- swapped in to his head... but I see he's PTO.  So, Eugen?
Flags: needinfo?(nalexander) → needinfo?(esawin)
Comment on attachment 8917929 [details]
Bug 1407835 - Don't keep BrowserApp unnecessarily alive through sScreenOrientationDelegate.

https://reviewboard.mozilla.org/r/188840/#review194220

This looks sensible to me, but I'm not clear on the details -- hopefully Eugen will know more.
Attachment #8917929 - Flags: review?(nalexander) → review+
Currently, we only set the screen orientation delegate in GeckoApp and since there is no public GeckoView API for that, no other consumer should override the delegate.

Nonetheless, verifying that the delegate is always set to the foreground activity seems sensible and maybe we should also unset it in onPause for symmetry and to break wrong assumptions.
Flags: needinfo?(esawin)
Pushed by mozilla@buttercookie.de:
https://hg.mozilla.org/integration/autoland/rev/20c73eec1bd2
Don't keep BrowserApp unnecessarily alive through sScreenOrientationDelegate. r=nalexander
https://hg.mozilla.org/mozilla-central/rev/20c73eec1bd2
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: