Skip to content

Honor AlreadyClosedBehavior in openPage/openTextPage (v1.0.35-based, for the Expensify JitPack pin)#2

Open
wildan-m wants to merge 3 commits into
Expensify:mainfrom
wildan-m:already-closed-fix
Open

Honor AlreadyClosedBehavior in openPage/openTextPage (v1.0.35-based, for the Expensify JitPack pin)#2
wildan-m wants to merge 3 commits into
Expensify:mainfrom
wildan-m:already-closed-fix

Conversation

@wildan-m

@wildan-m wildan-m commented Jul 7, 2026

Copy link
Copy Markdown

Brings the "Already closed" fix into Expensify/PdfiumAndroidKt so JitPack can build com.github.Expensify:PdfiumAndroidKt:1.0.35-already-closed-fix.3 — the coordinate that Expensify/App's react-native-pdf patch pins (Expensify/App#94894).

What it fixes: on Android, PdfDocument.openPage()/openTextPage() throw IllegalStateException("Already closed") when a render lands on a just-closed document. They're the only two methods that don't route through handleAlreadyClosed(), so they ignore the app's configured AlreadyClosedBehavior.IGNORE. That's the crash behind Sentry APP-1VG. This change makes both honor the config (returning a no-op page bound to the closed document, guarded like every other method) instead of throwing on the renderer thread.

3 commits on top of the v1.0.35 release:

  • Honor AlreadyClosedBehavior in openPage/openTextPage — the fix (one file, PdfDocument.kt)
  • Add jitpack.yml + accept Android SDK/NDK licenses — so JitPack builds only the :pdfiumandroid module

⚠️ Base note: this branch is based on the v1.0.35 release, not main (which is the newer 3.x redesign with a different openPage API). The intended outcome is to tag this branch 1.0.35-already-closed-fix.3 so JitPack builds the coordinate above — it isn't meant to be merged into the 3.x main (it'll show a conflict there). Happy to retarget if you'd prefer a dedicated 1.0.35 base branch.

wildan-m added 3 commits June 17, 2026 23:54
These were the only PdfDocument methods using an unconditional
check(!isClosed) instead of handleAlreadyClosed(), so a configured
AlreadyClosedBehavior.IGNORE never reached them. A render that lands on
a just-closed document threw IllegalStateException on the renderer
thread (PdfiumCore.renderPageBitmap -> openPage), which the barteksc
RenderingHandler does not catch, crashing the app. Now they route
through handleAlreadyClosed() like every sibling method and, when IGNORE
is set, return a page bound to the closed document so all further ops
no-op via the existing doc.isClosed guards.
@wildan-m

wildan-m commented Jul 7, 2026

Copy link
Copy Markdown
Author

@mountiny @eVoloshchak

How to land this — approve + tag, don't merge. This fork only needs to host the pinned build, so this doesn't merge into main (which is the newer 3.x line — that's why it shows conflicting). Just:

  1. Review/approve — the diff is computed from the v1.0.35 merge-base, so it shows exactly the 3-commit fix and nothing 3.x-related.
  2. Tag this branch 1.0.35-already-closed-fix.3 so JitPack builds com.github.Expensify:PdfiumAndroidKt:1.0.35-already-closed-fix.3.

Then I'll repoint the App patch (Expensify/App#94894) from com.github.wildan-m to com.github.Expensify. No need to resolve the conflict or touch main.

@mountiny

mountiny commented Jul 7, 2026

Copy link
Copy Markdown

Looking into this, permissions need to be updated

@wildan-m

wildan-m commented Jul 7, 2026

Copy link
Copy Markdown
Author

Thanks @mountiny! Pull-only here, so the tag's on your side — could you tag e6c06c29 as 1.0.35-already-closed-fix.3? Then JitPack builds com.github.Expensify:PdfiumAndroidKt:1.0.35-already-closed-fix.3 and I'll repoint the App patch (Expensify/App#94894).

git fetch origin pull/2/head && git tag 1.0.35-already-closed-fix.3 e6c06c29 && git push origin 1.0.35-already-closed-fix.3

@eVoloshchak eVoloshchak mentioned this pull request Jul 8, 2026
2 tasks
Comment thread jitpack.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wildan-m, I don't think this should be needed, shouldn't this already be published to our local Maven repository?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eVoloshchak nothing's pre-published — com.github.Expensify:… is a JitPack coordinate, so JitPack builds this repo from source on demand, and without jitpack.yml it fails (its default JDK 11 can't run the Hilt plugin, which needs 17 — tag .1 errored with No build artifacts found).

@mountiny

mountiny commented Jul 9, 2026

Copy link
Copy Markdown

@wildan-m Can you check if this is right? com.github.Expensify:PdfiumAndroidKt:expensify-already-closed-fix-v1

The tag was created

@mountiny

mountiny commented Jul 9, 2026

Copy link
Copy Markdown

@wildan-m

Copy link
Copy Markdown
Author

Thanks @mountiny! 🙏 One snag: JitPack's build of expensify-already-closed-fix-v1 failed on a transient flake (UnknownHostException: services.gradle.org while fetching the Gradle wrapper), and JitPack caches failures per version — so com.github.Expensify:PdfiumAndroidKt:expensify-already-closed-fix-v1 currently 404s. It's not the code: the same commit builds green via its commit coordinate …:e6c06c2905d1adf8b76f28c7440a2006033ca4c8 (pom + aar 200).

Could you hit Rebuild on the expensify-already-closed-fix-v1 build at jitpack.io (Expensify/PdfiumAndroidKt), or re-publish the release? Once it's green I'll repoint patch 004 at the tag and take PR #94894 out of draft. 🙏

@wildan-m

Copy link
Copy Markdown
Author

Update: to unblock in the meantime I've pointed patch 004 at the commit coordinate (com.github.Expensify:PdfiumAndroidKt:e6c06c2905d1adf8b76f28c7440a2006033ca4c8), which builds fine — so this is no longer blocking the App PR. A rebuild of the expensify-already-closed-fix-v1 tag is still welcome whenever convenient so we can switch to the cleaner named coordinate, but no rush. 🙏

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.

3 participants