Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Commit 793b37e

Browse files
committed
feature-customtabs: Execute warmup() on main thread.
1 parent ca79a54 commit 793b37e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

components/feature/customtabs/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626
implementation project(':support-base')
2727

2828
implementation Dependencies.kotlin_stdlib
29+
implementation Dependencies.kotlin_coroutines
2930

3031
api Dependencies.support_customtabs
3132

components/feature/customtabs/src/main/java/mozilla/components/feature/customtabs/AbstractCustomTabsService.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import android.net.Uri
99
import android.os.Bundle
1010
import android.support.customtabs.CustomTabsService
1111
import android.support.customtabs.CustomTabsSessionToken
12+
import kotlinx.coroutines.Dispatchers
13+
import kotlinx.coroutines.runBlocking
1214
import mozilla.components.concept.engine.Engine
1315
import mozilla.components.support.base.log.logger.Logger
1416

@@ -27,9 +29,12 @@ abstract class AbstractCustomTabsService : CustomTabsService() {
2729
abstract val engine: Engine
2830

2931
override fun warmup(flags: Long): Boolean {
30-
// Just accessing the engine here will make sure that it is created and initialized.
31-
logger.debug("Warm up for engine: ${engine.name()}")
32-
return true
32+
// We need to run this on the main thread since that's where GeckoRuntime expects to get initialized (if needed)
33+
return runBlocking(Dispatchers.Main) {
34+
// Just accessing the engine here will make sure that it is created and initialized.
35+
logger.debug("Warm up for engine: ${engine.name()}")
36+
true
37+
}
3338
}
3439

3540
override fun requestPostMessageChannel(sessionToken: CustomTabsSessionToken?, postMessageOrigin: Uri?): Boolean {

0 commit comments

Comments
 (0)