1
0
Fork 0

For #6464: Replace use of BuildConfig.DEBUG with ReleaseChannel.channel.isDebug.

This fixes performance issues where StrictMode would greatly slow down
startup in the forPerformanceTest variants.
master
Michael Comella 2019-12-20 13:27:05 -08:00 committed by Michael Comella
parent ac97dd72b1
commit cf143489e1
5 changed files with 19 additions and 16 deletions

View File

@ -6,7 +6,7 @@ import android.content.Context
import android.os.Bundle
import mozilla.components.browser.engine.gecko.glean.GeckoAdapter
import mozilla.components.lib.crash.handler.CrashHandlerService
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.utils.Settings
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoRuntimeSettings
@ -36,7 +36,7 @@ object GeckoProvider {
.crashHandler(CrashHandlerService::class.java)
.useContentProcessHint(true)
.telemetryDelegate(GeckoAdapter())
.debugLogging(BuildConfig.DEBUG)
.debugLogging(Config.channel.isDebug)
.build()
if (!Settings.getInstance(context).shouldUseAutoSize) {

View File

@ -6,7 +6,7 @@ import android.content.Context
import android.os.Bundle
import mozilla.components.browser.engine.gecko.glean.GeckoAdapter
import mozilla.components.lib.crash.handler.CrashHandlerService
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.utils.Settings
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoRuntimeSettings
@ -36,7 +36,7 @@ object GeckoProvider {
.crashHandler(CrashHandlerService::class.java)
.useContentProcessHint(true)
.telemetryDelegate(GeckoAdapter())
.debugLogging(BuildConfig.DEBUG)
.debugLogging(Config.channel.isDebug)
.aboutConfigEnabled(true)
.build()

View File

@ -278,7 +278,7 @@ open class FenixApplication : Application() {
}
private fun enableStrictMode() {
if (BuildConfig.DEBUG) {
if (Config.channel.isDebug) {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectAll()

View File

@ -5,44 +5,44 @@
package org.mozilla.fenix.ext
import android.util.Log
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
/**
* Will print to `Log.d()` only when [BuildConfig.DEBUG] is enabled.
* Will print to `Log.d()` only for debug release channels.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logDebug(tag: String, message: String) {
if (BuildConfig.DEBUG) Log.d(tag, message)
if (Config.channel.isDebug) Log.d(tag, message)
}
/**
* Will print to `Log.w()` only when [BuildConfig.DEBUG] is enabled.
* Will print to `Log.w()` only for debug release channels.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logWarn(tag: String, message: String) {
if (BuildConfig.DEBUG) Log.w(tag, message)
if (Config.channel.isDebug) Log.w(tag, message)
}
/**
* Will print to `Log.w()` only when [BuildConfig.DEBUG] is enabled.
* Will print to `Log.w()` only for debug release channels.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logWarn(tag: String, message: String, err: Throwable) {
if (BuildConfig.DEBUG) Log.w(tag, message, err)
if (Config.channel.isDebug) Log.w(tag, message, err)
}
/**
* Will print to `Log.e()` only when [BuildConfig.DEBUG] is enabled.
* Will print to `Log.e()` only for debug release channels.
*
* Meant to be used for logs that should not be visible in the production app.
*/
@Suppress("NOTHING_TO_INLINE")
inline fun logErr(tag: String, message: String, err: Throwable) {
if (BuildConfig.DEBUG) Log.e(tag, message, err)
if (Config.channel.isDebug) Log.e(tag, message, err)
}

View File

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ext
import org.mozilla.fenix.TestApplication
@ -10,14 +14,13 @@ import io.mockk.mockkStatic
import io.mockk.verify
import android.util.Log
import org.junit.Before
import org.mozilla.fenix.BuildConfig
@RunWith(RobolectricTestRunner::class)
@Config(application = TestApplication::class)
class LogTest {
val numCalls = if (BuildConfig.DEBUG) 1 else 0
val numCalls = if (org.mozilla.fenix.Config.channel.isDebug) 1 else 0
@Before
fun setup() {