Skip to content

Commit

Permalink
Issue mozilla-mobile#12731: Log and record breadcrumb when onTrimMemo…
Browse files Browse the repository at this point in the history
…ry() gets invoked.
  • Loading branch information
pocmo committed Nov 30, 2020
1 parent e8fa1a6 commit d84b8eb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/org/mozilla/fenix/FenixApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.launch
import mozilla.appservices.Megazord
import mozilla.components.browser.session.Session
import mozilla.components.browser.state.action.SystemAction
import mozilla.components.concept.base.crash.Breadcrumb
import mozilla.components.concept.push.PushProcessor
import mozilla.components.feature.addons.update.GlobalAddonDependencyProvider
import mozilla.components.lib.crash.CrashReporter
Expand Down Expand Up @@ -296,6 +297,21 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)

// Additional logging and breadcrumb to debug memory issues:
// https://github.com/mozilla-mobile/fenix/issues/12731

logger.info("onTrimMemory(), level=$level, main=${isMainProcess()}")

components.analytics.crashReporter.recordCrashBreadcrumb(Breadcrumb(
category = "Memory",
message = "onTrimMemory()",
data = mapOf(
"level" to level.toString(),
"main" to isMainProcess().toString()
),
level = Breadcrumb.Level.INFO
))

runOnlyInMainProcess {
components.core.icons.onTrimMemory(level)
components.core.store.dispatch(SystemAction.LowMemoryAction(level))
Expand Down

0 comments on commit d84b8eb

Please sign in to comment.