From 8ed28832ad4c5661786eeb61e44f32b0ad90c7d9 Mon Sep 17 00:00:00 2001 From: Andreas Lymalm Date: Sun, 30 Aug 2026 10:49:23 +0200 Subject: [PATCH 1/2] fix(Android): don't block UI using ReadiumReaderWidget --- .../main/kotlin/dk/nota/flutterreadium/ReadiumReader.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/ReadiumReader.kt b/flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/ReadiumReader.kt index da8e9ebb..390006fb 100644 --- a/flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/ReadiumReader.kt +++ b/flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/ReadiumReader.kt @@ -54,6 +54,7 @@ import org.readium.r2.shared.publication.Locator import org.readium.r2.shared.publication.LocatorCollection import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.html.cssSelector +import org.readium.r2.shared.publication.services.positionsByReadingOrder import org.readium.r2.shared.publication.services.content.DefaultContentService import org.readium.r2.shared.publication.services.content.content import org.readium.r2.shared.publication.services.content.contentServiceFactory @@ -953,6 +954,14 @@ object ReadiumReader : // already disables synchronization, start in manual mode. narrationSyncEnabled = initialPreferences.disableSynchronization != true + // EpubNavigatorFragment 3.3.0 reads this position list with runBlocking from its + // constructor. For a streamed Web Publication that can be a network request, which would + // otherwise park Android's main thread for seconds or minutes. Populate the service cache + // first on the I/O dispatcher so the constructor's lookup is immediate. + withIOContext { + pub.positionsByReadingOrder() + } + withMainContext { epubNavigator?.let { attachEpubNavigator(fragmentManager, viewGroup) From b97073a79b87b9941a5d0fd9d0f31843019b6eef Mon Sep 17 00:00:00 2001 From: Andreas Lymalm Date: Sun, 30 Aug 2026 12:33:14 +0200 Subject: [PATCH 2/2] docs: add changelog notes --- flutter_readium/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flutter_readium/CHANGELOG.md b/flutter_readium/CHANGELOG.md index 53958f9d..d2bd2bb2 100644 --- a/flutter_readium/CHANGELOG.md +++ b/flutter_readium/CHANGELOG.md @@ -5,6 +5,12 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Fixed + +- **Creating `ReadiumReaderWidget` could freeze the Android UI while the native reader + initialized.** Publication positions, which Readium's EPUB fragment constructor reads with a + blocking call, are now fetched and cached on the I/O dispatcher first. + ## [0.4.2] - 2026-08-28 ### Fixed