Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When sliding through the PDF file, closing the current page causes the app to crash. #830

Open
LJW123 opened this issue Apr 26, 2024 · 21 comments

Comments

@LJW123
Copy link

LJW123 commented Apr 26, 2024

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 :

  1. 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)

image

Show us the code you are using?
return (

{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);
}}
/>
)}

);

@nguyentitan
Copy link

I'm facing the same issue, any suggestion?

@dipteshdx
Copy link

I am facing the same issue any solution?

@tsalama
Copy link

tsalama commented May 15, 2024

Also facing this, but a different error:

java.lang.RuntimeException: Loaded page is null
  io.legere.pdfiumandroid.PdfDocument.nativeLoadPage(Native Method)
  io.legere.pdfiumandroid.PdfDocument.openPage(PdfDocument.kt:83)
  io.legere.pdfiumandroid.PdfiumCore.renderPageBitmap(PdfiumCore.kt:406)
  com.github.barteksc.pdfviewer.PdfFile.renderPageBitmap(PdfFile.java:301)
  com.github.barteksc.pdfviewer.RenderingHandler.proceed(RenderingHandler.java:109)
  com.github.barteksc.pdfviewer.RenderingHandler.handleMessage(RenderingHandler.java:66)
  android.os.Handler.dispatchMessage(Handler.java:106)
  android.os.Looper.loopOnce(Looper.java:201)
  android.os.Looper.loop(Looper.java:288)
  android.os.HandlerThread.run(HandlerThread.java:67)

@huanguolin
Copy link

same issue here.

@huanguolin
Copy link

my workaround: downgrade from 6.7.5 to 6.6.2.

@nguyentitan
Copy link

I have temporary solution to fix it, hope this issue will be fixed ASAP.

  1. Downgrade to 6.7.4
  2. Create patch file from our project and apply the fix from this PR: Fix app crash with this.lastRNBFTask.cancel is not a function #827
  3. re-run npm install to apply the patch, crash issue resolved.

@jlopezdominguez
Copy link

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
Copy link

agungjk commented May 29, 2024

my workaround: downgrade from 6.7.5 to 6.6.2.

tested, working on my project

@TraFost
Copy link

TraFost commented 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
Copy link

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
Copy link

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
Copy link

downgrade to 6.6.2 works for me

@irmakcosarsahna
Copy link

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
Copy link

jay4008 commented Sep 28, 2024

Hi @tsalama
are you able to solve the issue

@tsalama
Copy link

tsalama commented Sep 28, 2024

@jay4008 Yes but only by downgrading to 6.7.3

@jay4008
Copy link

jay4008 commented Sep 28, 2024

@tsalama actually i am using react-native 0.73 and react native pdf as 6.7.5 , and the main problem is that i am getting both io.legere.pdfiumandroid.util.ConfigKt.handleAlreadyClosed and io.legere.pdfiumandroid.PdfDocument.nativeLoadPage,

Will i change with 6.6.2 or 6.7.3

@radiorapstech
Copy link

Same error (Android), fixed on 6.6.2

@steffenkleinle
Copy link

steffenkleinle commented Oct 25, 2024

Can also reproduce this if opening and closing pdfs quickly multiple times on v6.7.5.

@pavel-roj
Copy link

pavel-roj commented Nov 4, 2024

Can also reproduce this while using this library in conjunction with react navigation material-top-tabs, where I have a single PDF for each of the tabs. Quickly switching between the tabs crashes the application with the same fatal exception.

using
react-native-pdf: 6.7.5
react-native: 0.73.6
react: 18.2.0

@jay4008
Copy link

jay4008 commented Nov 4, 2024

the pdf viewer is good to use but some issues are here from native side .

@GabrielDierks
Copy link

+1 here happening on various devices, reported via sentry.

react-native: 0.74.5

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

No branches or pull requests