Skip to content

Load the later parts of a view on demand - #738

Merged
andiwand merged 1 commit into
mainfrom
lazy-loading
Oct 25, 2026
Merged

andiwand merged 1 commit into
mainfrom
lazy-loading

Conversation

@andiwand

@andiwand andiwand commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Core 7.6 can write the parts of a view after the first as scripts beside the page. The page loads a script when the reader comes near its part. CoreLoader now sets lazyLoading = true and states lazyLayout = true. An editable render stays whole (level 1), so in the app this applies mostly to a pdf: core renders a page only when the reader comes near it.

Changes

The app reads the DOM in two places, so both now load what they need:

  • Read aloud reads a pdf page by page (.p[data-odr-page]). If a page has not loaded, the app calls odr.chunks.show and reads the page when odr-chunk-filled arrives. If the script of the page never arrives, read aloud skips the page after 30 s, so it does not stop.
  • Print from the page (a pdf with a password or unsaved marks) shows a part that has not loaded as empty space. PageView.loadAllChunks loads every part first, and gives up after 30 s. A second print while it loads is ignored.

The page search counts the hits in the parts that have not loaded from the search index of core, so find needs no change.

Testing (Pixel_6_Pro emulator, Android 12, WebView Chrome 91)

Built against core 7.6.0 locally, because 7.6.1 is not on Maven Central yet. spotlessApply assembleProDebug assembleLiteDebug testProDebugUnitTest pass.

  • A pdf of 208 pages opens with 205 pages not loaded. Find finds hits on every page, and a step to page 208 loads and shows it.
  • The read-aloud script, run in the page with a spy for the bridge:
    • page 101, not loaded: loads, then reads its text (244 ms)
    • page 151, with a script that does not exist: skips the page after the timeout (3 s in the test)
    • page 2, loaded: reads at once
  • Print of a 40-page pdf with a password: 37 pages were not loaded. loadAllChunks loads them, one print dialog opens, and the preview shows pages 39 and 40 with their content.
  • Print of a 208-page pdf with a password: all pages load in about 6 s, then the preview runs out of renderer memory (about 1 GB). The same print fails the same way without lazy loading, so this is not new.

@andiwand
andiwand force-pushed the fix/732-page-search branch from a0a4241 to f7f789d Compare October 25, 2026 13:05
@andiwand
andiwand force-pushed the fix/732-page-search branch from f7f789d to 1ab6bb0 Compare October 25, 2026 13:22
Base automatically changed from fix/732-page-search to main October 25, 2026 13:24
Core 7.6 can write the parts of a view after the first as scripts
beside the page, which the page loads when the reader comes near.
CoreLoader now turns this on with lazyLoading, and states lazyLayout.
An editable render stays whole, so in the app this applies mostly to
a pdf: core renders a page only when the reader comes near it.

The app reads the DOM in two places, so both now load what they need:

- Read aloud reads a pdf page by page. A page that has not loaded is
  loaded with odr.chunks.show, and read when odr-chunk-filled arrives.
  If its script never arrives, read aloud skips the page after 30 s.
- A print from the page shows a part that has not loaded as empty
  space. PageView.loadAllChunks loads every part first, and gives up
  after 30 s. A second print while it loads is ignored.

The page search counts the parts that have not loaded from the search
index of core, so find needs no change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JuNa2W75khbpynkiG9iDqF
@andiwand
andiwand merged commit 49bbac8 into main Oct 25, 2026
2 of 3 checks passed
@andiwand
andiwand deleted the lazy-loading branch October 25, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant