Skip to content

Native crash (SIGILL) when two PdfReaderStates render concurrently on Android #15

Open

Description

@gazseatfrog

Version: dev.nucleusframework:pdfium-android 156.0.8066.0

Setup: Two PdfReaderStates open at the same time, each with a different document, both rendering via PdfPage. In our case that's a HorizontalPager where each page hosts its own reader, so while swiping two pages are composed and rendering at once.

Result: Native crash after a few back-and-forth swipes:

Fatal signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0x798d366cb8 in tid 17098 (pdfium-worker-2)

Likely cause: openPdfDocument creates a dedicated pdfium-worker-N executor per document (PdfDocument.android.kt), so each document is serialised on its own thread. But PDFium itself is process-wide and not thread-safe (the POOL_SIZE = 1 comment already notes the shared FreeType FT_Library). With two documents open, two worker threads call into PDFium concurrently, which is a different problem from the intra-document case that POOL_SIZE guards against.

Suggested fix: Serialise all PDFium calls across documents, e.g. route render/pageSize/close through the single Pdfium.sharedDispatcher (or a global mutex) rather than a per-document executor.

Repro: Two PdfPages from two rememberPdfReaderState()s in a HorizontalPager, swipe back and forth repeatedly.

Activity

  1. gazseatfrog commented on Oct 12, 2026

    @gazseatfrog
    Author

    Opened a fix for this in #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions