No issue: Move PublicSuffixList to root component

With the PublicSuffixList class in Utilities, the first instantiation
of it (prefetching in onCreate), causes the Utilities to instantiate
and thus slowing down startup by needing the SearchEngineManager from
instantiating as well.

Moving this back to the root component fixes the immediate perf issue.

Co-authored-by: Will Hawkins <whh8b@obs.cr>
nightly-build-test
Jonathan Almeida 5 years ago committed by Jeff Boek
parent 59c0005979
commit 4922e5d09d

@ -75,7 +75,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
components.utils.publicSuffixList.prefetch() components.publicSuffixList.prefetch()
setupThemeAndBrowsingMode() setupThemeAndBrowsingMode()
setContentView(R.layout.activity_home) setContentView(R.layout.activity_home)

@ -5,6 +5,7 @@
package org.mozilla.fenix.components package org.mozilla.fenix.components
import android.content.Context import android.content.Context
import mozilla.components.lib.publicsuffixlist.PublicSuffixList
import org.mozilla.fenix.test.Mockable import org.mozilla.fenix.test.Mockable
/** /**
@ -21,4 +22,5 @@ class Components(private val context: Context) {
val useCases by lazy { UseCases(context, core.sessionManager, core.engine.settings, search.searchEngineManager) } val useCases by lazy { UseCases(context, core.sessionManager, core.engine.settings, search.searchEngineManager) }
val utils by lazy { Utilities(context, core.sessionManager, useCases.sessionUseCases, useCases.searchUseCases) } val utils by lazy { Utilities(context, core.sessionManager, useCases.sessionUseCases, useCases.searchUseCases) }
val analytics by lazy { Analytics(context) } val analytics by lazy { Analytics(context) }
val publicSuffixList by lazy { PublicSuffixList(context) }
} }

@ -10,7 +10,6 @@ import mozilla.components.feature.customtabs.CustomTabIntentProcessor
import mozilla.components.feature.intent.TabIntentProcessor import mozilla.components.feature.intent.TabIntentProcessor
import mozilla.components.feature.search.SearchUseCases import mozilla.components.feature.search.SearchUseCases
import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.session.SessionUseCases
import mozilla.components.lib.publicsuffixlist.PublicSuffixList
import org.mozilla.fenix.test.Mockable import org.mozilla.fenix.test.Mockable
/** /**
@ -38,6 +37,4 @@ class Utilities(
val customTabIntentProcessor by lazy { val customTabIntentProcessor by lazy {
CustomTabIntentProcessor(sessionManager, sessionUseCases.loadUrl, context.resources) CustomTabIntentProcessor(sessionManager, sessionUseCases.loadUrl, context.resources)
} }
val publicSuffixList by lazy { PublicSuffixList(context) }
} }

@ -37,7 +37,7 @@ fun String.urlToTrimmedHost(context: Context): String {
return try { return try {
val host = toUri().hostWithoutCommonPrefixes ?: return this val host = toUri().hostWithoutCommonPrefixes ?: return this
runBlocking { runBlocking {
context.components.utils.publicSuffixList.stripPublicSuffix(host).await() context.components.publicSuffixList.stripPublicSuffix(host).await()
} }
} catch (e: MalformedURLException) { } catch (e: MalformedURLException) {
this this

Loading…
Cancel
Save