react-native-pdf: When sliding through the PDF file, closing the current page causes the app to crash.
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)
Show us the code you are using?
return (
<View style={styles.container}>
{fileUri && (
<Pdf
trustAllCerts={false}
style={styles.pdfStyle}
source={getFileSource()}
onLoadComplete={(numberOfPages, filePath) => {
console.log(Number of pages: ${numberOfPages});
}}
onPageChanged={(page, numberOfPages) => {
console.log(Current page: ${page});
}}
onError={error => {
console.error(error);
}}
/>
)}
</View>
);
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 14
- Comments: 34 (2 by maintainers)
It’s still crashing in 6.7.7
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? 😃
I have temporary solution to fix it, hope this issue will be fixed ASAP.
npm installto apply the patch, crash issue resolved.my workaround: downgrade from 6.7.5 to 6.6.2.
How come it is closed? we are still facing the issue.
@MaksymA26 Here is the PR https://github.com/zacharee/AndroidPdfViewer/pull/1
I will create another PR for this repository after above PR got merged. In the mean time, you can use above patch to workaround