You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When sliding through the PDF file, closing the current page causes the app to crash. #830
What react-native version are you using?
0.72.4
What react-native-pdf version are you using?
6.7.5
What platform does your issue occur on? (android/ios/both)
android
Describe your issue as precisely as possible :
When sliding through the PDF file, closing the current page causes the app to crash. The crash details are as follows:
E FATAL EXCEPTION: PDF renderer
Process: com.sssss, PID: 12594
java.lang.IllegalStateException: Already closed
at io.legere.pdfiumandroid.util.ConfigKt.handleAlreadyClosed(Config.kt:20)
at io.legere.pdfiumandroid.PdfPage.close(PdfPage.kt:582)
at kotlin.io.CloseableKt.closeFinally(Closeable.kt:56)
at io.legere.pdfiumandroid.PdfiumCore.renderPageBitmap(PdfiumCore.kt:406)
at com.github.barteksc.pdfviewer.PdfFile.renderPageBitmap(PdfFile.java:301)
at com.github.barteksc.pdfviewer.RenderingHandler.proceed(RenderingHandler.java:109)
at com.github.barteksc.pdfviewer.RenderingHandler.handleMessage(RenderingHandler.java:66)
at android.os.Handler.dispatchMessage(Handler.java:117)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:293)
at android.os.HandlerThread.run(HandlerThread.java:110)
Fatal Exception: java.lang.RuntimeException: Get page pdf document null
at io.legere.pdfiumandroid.PdfDocument.nativeLoadPage(PdfDocument.kt)
at io.legere.pdfiumandroid.PdfDocument.openPage(PdfDocument.kt:83)
at io.legere.pdfiumandroid.PdfiumCore.renderPageBitmap(PdfiumCore.kt:406)
at com.github.barteksc.pdfviewer.PdfFile.renderPageBitmap(PdfFile.java:301)
at com.github.barteksc.pdfviewer.RenderingHandler.proceed(RenderingHandler.java:109)
at com.github.barteksc.pdfviewer.RenderingHandler.handleMessage(RenderingHandler.java:66)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:65)
Any idea how to fix this one? For me the "already closed" issue is raised when user enters pdf screen and then goes to other place in the app - when he comes back to pdf the app crashes with this error.
Is their any solution available for this? I cannot see any potential fix to this currently. Also, downgrading the version does not seems like a fix to this error.
Reacted by Muhammad Husnain Tahir, Tomoya Kawamura, VijayAnand, Guilherme Dias, Francis Auwerda, Angga Pradipta, Tom Hohler, Yoel Naki, Abhimanyu Pathania and Egli Malaj
Unfortunately, if I downgrade to 6.7.2, I cannot open iOS links. I applied a patch to open links on 6.7.6. But I am having an Android crash problem with 6.7.6.
So this react-native-pdf library is simply 1 version behind the fix. A single line of code and a re-release is needed to help out these devs (nobody wants to contribute a PR apparently).
In the meantime:
If you don't want to bother, just fork/patch the repo for now, or you could probably just hack this in your Android Application class as well by ignoring the crash with a global uncaught exception handler.
So this react-native-pdf library is simply 1 version behind the fix. A single line of code and a re-release is needed to help out these devs (nobody wants to contribute a PR apparently).
In the meantime:
If you don't want to bother, just fork/patch the repo for now, or you could probably just hack this in your Android Application class as well by ignoring the crash with a global uncaught exception handler.
override fun onCreate() {
super.onCreate()
val defaultHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { thread, throwable ->
if (throwable is IllegalStateException && throwable.message?.contains("Already closed") == true) {
// Do nothing
} else {
defaultHandler?.uncaughtException(thread, throwable)
}
}
}
Don't copy paste the above code, just wondering if it works in this case.
Activity
nguyentitan commentedon May 9, 2024
I'm facing the same issue, any suggestion?
dipteshdx commentedon May 9, 2024
I am facing the same issue any solution?
tsalama commentedon May 15, 2024
Also facing this, but a different error:
huanguolin commentedon May 27, 2024
same issue here.
huanguolin commentedon May 27, 2024
my workaround: downgrade from 6.7.5 to 6.6.2.
nguyentitan commentedon May 27, 2024
I have temporary solution to fix it, hope this issue will be fixed ASAP.
npm installto apply the patch, crash issue resolved.jlopezdominguez commentedon May 29, 2024
Having the same problem here, and also this one :
Fatal Exception: java.lang.RuntimeException: Get page pdf document null
at io.legere.pdfiumandroid.PdfDocument.nativeLoadPage(PdfDocument.kt)
at io.legere.pdfiumandroid.PdfDocument.openPage(PdfDocument.kt:83)
at io.legere.pdfiumandroid.PdfiumCore.renderPageBitmap(PdfiumCore.kt:406)
at com.github.barteksc.pdfviewer.PdfFile.renderPageBitmap(PdfFile.java:301)
at com.github.barteksc.pdfviewer.RenderingHandler.proceed(RenderingHandler.java:109)
at com.github.barteksc.pdfviewer.RenderingHandler.handleMessage(RenderingHandler.java:66)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:65)
Any clue on how to fix this ?
agungjk commentedon May 29, 2024
tested, working on my project
TraFost commentedon Jun 24, 2024
does u guys facing an error while the component finished loading and then the app suddenly crashed? i've been searching for this and got no answer
EwaGuziejko commentedon Aug 6, 2024
Any idea how to fix this one? For me the "already closed" issue is raised when user enters pdf screen and then goes to other place in the app - when he comes back to pdf the app crashes with this error.
basit-nbs commentedon Aug 19, 2024
Is their any solution available for this? I cannot see any potential fix to this currently. Also, downgrading the version does not seems like a fix to this error.
Dzmitry-Klokau commentedon Sep 5, 2024
downgrade to 6.6.2 works for me
irmakcosarsahna commentedon Sep 24, 2024
I have the same problem. It started happening on Android devices after updating the React Native version and the package.
"react-native": "^0.75.2",
"react-native-pdf": "^6.7.5",
jay4008 commentedon Sep 28, 2024
Hi @tsalama
are you able to solve the issue
tsalama commentedon Sep 28, 2024
@jay4008 Yes but only by downgrading to 6.7.3
13 remaining items
augusthjerrild commentedon Feb 28, 2025
It's still crashing in 6.7.7, so no need to close this yet. It's still an ongoing issue that hopefully should be fixed asap? :-)
my-srd commentedon Mar 6, 2025
me too.
skbaji6 commentedon Mar 17, 2025
How come it is closed? we are still facing the issue.
VimukthiShohan commentedon Mar 19, 2025
It's still crashing in 6.7.7
guihendias commentedon May 6, 2025
We have over 20 crashes daily due to this error
gonca-gul commentedon May 7, 2025
Unfortunately, if I downgrade to 6.7.2, I cannot open iOS links. I applied a patch to open links on 6.7.6. But I am having an Android crash problem with 6.7.6.
pallav110 commentedon Jul 24, 2025
We would need a solution , because of this i can't build my enterprise app , which has a core functionality of showing pdf.
EdwardvanRaak commentedon Aug 19, 2025
@wonday
This library is currently using
com.github.zacharee:AndroidPdfViewer:4.0.1react-native-pdf/android/build.gradle
Line 127 in d49cb92
The fix from r0b0t3d is in
4.0.2https://github.com/zacharee/AndroidPdfViewer/blob/master/CHANGELOG.md#402
So this
react-native-pdflibrary is simply 1 version behind the fix. A single line of code and a re-release is needed to help out these devs (nobody wants to contribute a PR apparently).In the meantime:
If you don't want to bother, just fork/patch the repo for now, or you could probably just hack this in your Android Application class as well by ignoring the crash with a global uncaught exception handler.
Don't copy paste the above code, just wondering if it works in this case.
YOEL311 commentedon Sep 17, 2025
I can't use the
4.0.2versionis not exist in nvm
https://mvnrepository.com/artifact/com.github.zacharee/AndroidPdfViewer
I see only the 4.0.1 version
How can we use the
4.0.2version?Prajwaltechversant commentedon Oct 8, 2025
+1
maneesh-techversant commentedon Oct 9, 2025
In the latest version 7.0.0, the same issue is still reproducing.
DragomirAndrei19 commentedon Oct 9, 2025
Sentry reports the same error for me.
yakupozbaydar commentedon Nov 17, 2025
experiencing on production.any updates?
Natanaelvich commentedon Dec 10, 2025
I migrated the PDF viewing implementation to https://github.com/126punith/react-native-pdf-jsi, and since then I have not encountered this crash anymore. It seems the issue is resolved with this library.