@@ -37,6 +37,7 @@ import org.librarysimplified.r2.api.SR2Locator.SR2LocatorChapterEnd
3737import org.librarysimplified.r2.api.SR2Locator.SR2LocatorPercent
3838import org.librarysimplified.r2.api.SR2PageNumberingMode
3939import org.librarysimplified.r2.api.SR2Theme
40+ import org.librarysimplified.r2.ui_thread.SR2UIThread
4041import org.librarysimplified.r2.vanilla.BuildConfig
4142import org.readium.r2.shared.ExperimentalReadiumApi
4243import org.readium.r2.shared.publication.Href
@@ -141,8 +142,7 @@ internal class SR2Controller private constructor(
141142 val publicationOpener =
142143 PublicationOpener (
143144 publicationParser = publicationParser,
144- contentProtections =
145- configuration.contentProtections,
145+ contentProtections = configuration.contentProtections,
146146 onCreatePublication = {
147147 },
148148 )
@@ -723,7 +723,7 @@ internal class SR2Controller private constructor(
723723 this .logger.debug(" {} Failed to set scroll mode: " , this .name(), exception)
724724 }
725725 }.thenCompose {
726- this .executeThemeSet(this .waitForWebViewAvailability() , this .themeNow())
726+ this .executeThemeSet(connection , this .themeNow())
727727 }.handle { _, exception ->
728728 if (exception != null ) {
729729 this .logger.debug(" {} Failed to set theme: " , this .name(), exception)
@@ -1193,6 +1193,10 @@ internal class SR2Controller private constructor(
11931193 */
11941194
11951195 private fun waitForWebViewAvailability (): SR2WebViewConnectionType {
1196+ check(! SR2UIThread .isUIThread()) {
1197+ " Waiting for the web view on the UI thread is not permitted."
1198+ }
1199+
11961200 while (true ) {
11971201 synchronized(this .webViewConnectionLock) {
11981202 val webView = this .webViewConnection
0 commit comments