-
Notifications
You must be signed in to change notification settings - Fork 637
Description
We are encountering an app crash on Android devices when a user is viewing a PDF using react-native-pdf and closes the page after scrolling through it. The issue is consistently reported in Firebase with an IllegalStateException: Already closed error in the stack trace.
Steps to Reproduce:
- Open a PDF with the react-native-pdf component.
- Scroll or slide through multiple pages.
- Close the PDF viewing page (e.g., by navigating away or closing the screen).
- The app crashes.
Stack Trace (Firebase Report):
E FATAL EXCEPTION: PDF renderer
Process: com.app, PID: [varies]
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)
Environment:
- Platform: Android
- Library: react-native-pdf
- react-native-pdf version: 7.0.0
- React Native Version: 0.81.4
- Affected on multiple Android device models
Expected Behavior:
Closing the PDF page should safely release resources without crashing the app.
Observed Behavior:
The app terminates with a fatal exception mentioning "Already closed" in the PDF renderer.
Additional Notes:
- The issue is critical as it affects the core PDF viewing functionality and is being observed frequently in production.
Request:
Please investigate the page closure and resource disposal logic to ensure the PDF component handles repeated or premature closures gracefully. A fix or guidance to mitigate these crashes would be highly appreciated.