Closed Bug 1807353 Opened 3 years ago Closed 2 years ago

AccountManager memory leak in AuthCustomTabActivity

Categories

(Firefox for Android :: Performance, defect)

All
Android
defect

Tracking

()

RESOLVED FIXED
131 Branch
Performance Impact none
Tracking Status
firefox131 --- fixed

People

(Reporter: cpeterson, Assigned: jonalmeida)

Details

Attachments

(1 file)

From github: https://github.com/mozilla-mobile/fenix/issues/27765.

We register an accountManager observer but never unregister:

There are three autoPause observers that we need to manually unregister (or we disable auto pause - why is it true to begin with?):

  • accountStateObserver
  • syncStatusObserver
  • deviceConstellationObserver

This trace below is just one example of the traces from all three observers above:

  ┬───
  │ GC Root: System class
  │
  ├─ android.provider.FontsContract class
  │    Leaking: NO (DebugFenixApplication↓ is not leaking and a class is never leaking)
  │    ↓ static FontsContract.sContext
  ├─ org.mozilla.fenix.DebugFenixApplication instance
  │    Leaking: NO (Application is a singleton)
  │    mBase instance of android.app.ContextImpl
  │    ↓ FenixApplication.components$delegate
  │                       ~~~~~~~~~~~~~~~~~~~
  ├─ kotlin.SynchronizedLazyImpl instance
  │    Leaking: UNKNOWN
  │    Retaining 20 B in 1 objects
  │    ↓ SynchronizedLazyImpl._value
  │                           ~~~~~~
  ├─ org.mozilla.fenix.components.Components instance
  │    Leaking: UNKNOWN
  │    Retaining 173.4 kB in 1266 objects
  │    context instance of org.mozilla.fenix.DebugFenixApplication
  │    ↓ Components.services$delegate
  │                 ~~~~~~~~~~~~~~~~~
  ├─ kotlin.SynchronizedLazyImpl instance
  │    Leaking: UNKNOWN
  │    Retaining 350 B in 17 objects
  │    ↓ SynchronizedLazyImpl._value
  │                           ~~~~~~
  ├─ org.mozilla.fenix.components.Services instance
  │    Leaking: UNKNOWN
  │    Retaining 330 B in 16 objects
  │    context instance of org.mozilla.fenix.DebugFenixApplication
  │    ↓ Services.accountManager
  │               ~~~~~~~~~~~~~~
  ├─ mozilla.components.service.fxa.manager.FxaAccountManager instance
  │    Leaking: UNKNOWN
  │    Retaining 2.9 kB in 108 objects
  │    context instance of org.mozilla.fenix.DebugFenixApplication
  │    ↓ FxaAccountManager.$$delegate_0
  │                        ~~~~~~~~~~~~
  ├─ mozilla.components.support.base.observer.ObserverRegistry instance
  │    Leaking: UNKNOWN
  │    Retaining 283.2 kB in 6353 objects
  │    ↓ ObserverRegistry.observers
  │                       ~~~~~~~~~
  ├─ java.util.LinkedHashSet instance
  │    Leaking: UNKNOWN
  │    Retaining 449 B in 15 objects
  │    ↓ LinkedHashSet[element()]
  │                   ~~~~~~~~~~~
  ├─ org.mozilla.fenix.settings.account.AuthCustomTabActivity$accountStateObserver$1 instance
  │    Leaking: UNKNOWN
  │    Retaining 145.9 kB in 3262 objects
  │    Anonymous class implementing mozilla.components.concept.sync.AccountObserver
  │    this$0 instance of org.mozilla.fenix.settings.account.AuthCustomTabActivity with mDestroyed = true
  │    ↓ AuthCustomTabActivity$accountStateObserver$1.this$0
  │                                                   ~~~~~~
  ╰→ org.mozilla.fenix.settings.account.AuthCustomTabActivity instance
  ​     Leaking: YES (ObjectWatcher was watching this because org.mozilla.fenix.settings.account.AuthCustomTabActivity
  ​     received Activity#onDestroy() callback and Activity#mDestroyed is true)
  ​     Retaining 145.9 kB in 3261 objects
  ​     key = 9d290053-4f0b-4b61-9293-7be627a0aa8c
  ​     watchDurationMillis = 5703
  ​     retainedDurationMillis = 703
  ​     mApplication instance of org.mozilla.fenix.DebugFenixApplication
  ​     mBase instance of androidx.appcompat.view.ContextThemeWrapper
  
  METADATA
  
  Build.VERSION.SDK_INT: 29
  Build.MANUFACTURER: samsung
  LeakCanary version: 2.9.1
  App process name: org.mozilla.fenix.debug
  Class count: 24767
  Instance count: 158649
  Primitive array count: 125420
  Object array count: 22760
  Thread count: 65
  Heap total bytes: 23958770
  Bitmap count: 11
  Bitmap total bytes: 189075
  Large bitmap count: 0
  Large bitmap total bytes: 0
  Db 1: open /data/user/0/org.mozilla.fenix.debug/databases/mozac_downloads_database
  Db 2: open /data/user/0/org.mozilla.fenix.debug/databases/recently_closed_tabs
  Db 3: open /data/user/0/org.mozilla.fenix.debug/databases/tab_collections
  Db 4: open /data/user/0/org.mozilla.fenix.debug/databases/top_sites
  Db 5: open /data/user/0/org.mozilla.fenix.debug/databases/manifests
  Db 6: open /data/user/0/org.mozilla.fenix.debug/no_backup/androidx.work.workdb
  Db 7: open /data/user/0/org.mozilla.fenix.debug/databases/com.google.android.datatransport.events
  Db 8: open /data/user/0/org.mozilla.fenix.debug/databases/pocket_recommendations
  Stats: LruCache[maxSize=3000,hits=43932,misses=99121,hitRate=30%]
  RandomAccess[bytes=5024006,reads=99121,travel=44159775593,range=28672791,size=36462872]
  Analysis duration: 19027 ms
  • Android device: ?
  • Fenix version: ?

┆Issue is synchronized with this Jira Task
┆Link To Issue: https://mozilla-hub.atlassian.net/browse/FNXV2-21957

Change performed by the Move to Bugzilla add-on.

The severity field is not set for this bug.
:cpeterson, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(cpeterson)
Flags: needinfo?(cpeterson)
Performance Impact: --- → none

Performance calculator says none since no effect is seen on the browser but this should still get fix.

Severity: -- → S3
Assignee: nobody → jonalmeida942
Status: NEW → ASSIGNED
Pushed by jonalmeida942@gmail.com: https://hg.mozilla.org/integration/autoland/rev/b5035c15b15f Unregister account observer in AuthCustomTabActivity#onDestroy r=android-reviewers,mcarare
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 131 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: