Skip to content

KitePDF 0.9.0

Choose a tag to compare

@yuroyami yuroyami released this 08 Sep 03:28

Reading an EPUB on Android ran the app out of memory within seconds and killed it. Reported, along with the flickering next to it.

implementation("io.github.yuroyami:kitepdf:0.9.0")

Requirements

  • Kotlin 2.4.10+ (older compilers cannot read these artifacts)
  • JDK 21
  • Android SDK 37 / minSdk 21 (compose-viewer 24, native-renderer 29)
  • Compose Multiplatform 1.12.0-beta02 for kitepdf-compose-viewer
  • Pulls in KiteImage 0.1.0, Ktor 3.5.2 (kitepdf-net), Skiko 0.148.2 (renderers)
  • Targets: Android, JVM, iOS, tvOS, watchOS, macOS, Linux, Windows, Android Native, JS, Wasm

Fixed

Fixed a long EPUB running the app out of memory (fixes #218, reported by @Tulis12 in #217).

The viewer laid every chapter out behind the reader and kept all of them, roughly 165 bytes per character of text. Android gives a normal app 192 MB, so a novel filled the heap before you finished the first page. Heap retained after laying a whole book out:

791k-character novel:        124 MB  ->  39 MB
698k-character illustrated:  204 MB  ->  54 MB

Chapters now drop least-recently-used to fit layoutCacheBytes, and lay out again in about a tenth of a second when you come back. Page counts, bookmarks and links keep working while a chapter is dropped, so navigation never waits on one. Glyphs for the same character also share one String now (#220).

Fixed visible pages redrawing on every chapter load (fixes #221).

The document built a new page object per lookup, and the viewer keys its bitmap cache on that object, so every chapter landing was a total cache miss. On a 40-chapter book the two pages on screen rasterized 30 times each, crossfading back in every time. A location now answers the same object for the life of the document.

Fixed an out-of-memory page killing the app (fixes #219).

The rasterizer's guard caught Exception, and OutOfMemoryError is an Error, so the one failure the guard existed for walked straight past it. It catches Throwable now: the page keeps its placeholder and the app survives.

Fixed blank Standard-14 text on Linux.

Skia was asked for Helvetica, Times New Roman and Courier New by name. Linux ships metric-compatible clones under other names, and Skia answers a family it cannot find with a font that paints nothing and reports no error. Each family now lists the stand-ins other systems do ship.

Added

EpubSettings.layoutCacheBytes, the budget above, 48 MB by default.

EpubDocument.open(bytes, EpubSettings(layoutCacheBytes = 24L * 1024 * 1024))

EpubSettings gained a parameter, so source stays compatible but anything compiled against 0.8.2 needs recompiling.

Full changelog: v0.8.2...v0.9.0