Skip to content

[Android] Bug: App Crashes on - java.lang.IllegalStateException: Already closed #882

Open

Description

@anasvemmully

What react-native version are you using?
0.74.5

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. Steps to reproduce the issue or to explain in which case you get the issue
  2. Interesting logs

Join a screenshot or video of the problem on the simulator or device?
image

Show us the code you are using?

<Modal
  animationType="fade"
      transparent={false}
      visible
      onRequestClose={onSyllubusViewRequestClose}
      style={syllabusViewStyle.container}>
      {syllabusLink && (
        <Pdf
          trustAllCerts={false}
          source={{
            uri: syllabusLink,
            cache: true,
            cacheFileName: syllabusLink.split("/")[syllabusLink.split("/").length - 1],
          }}
          onLoadComplete={onLoadComplete}
          onError={onPDFError}
          style={{
            flex: 1,
            marginTop: 50,
            width: Dimensions.get("window").width,
            height: Dimensions.get("window").height - 50,
          }}
        />
      )}
</Modal>

Iam using ExpoSDK 51
this happens when immediately closing the pdf before its loaded while testing,

Is there any solution for this, i though this gets fixed in last version!

Activity

  1. changed the title [-][Android] Bug: java.lang.IllegalStateException: Already closed[/-] [+][Android] Bug: App Crashes on - java.lang.IllegalStateException: Already closed[/+] on Nov 8, 2024
  2. NJneeraj commented on Nov 9, 2024

    @NJneeraj

    Same issue

  3. keung7252 commented on Nov 14, 2024

    @keung7252

    Same issue

  4. BerkeAras-SMM commented on Dec 4, 2024

    @BerkeAras-SMM

    Same issue

  5. BerkeAras-SMM commented on Dec 4, 2024

    @BerkeAras-SMM

    @wonday Any ideas?

  6. vladimirivanoviliev commented on Dec 5, 2024

    @vladimirivanoviliev

    Seems the same as: #830

  7. vladimirivanoviliev commented on Dec 5, 2024

    @vladimirivanoviliev

    Also seems mentioned in latest version: #840

  8. Mallikarjuna-s commented on Dec 12, 2024

    @Mallikarjuna-s

    same issue "react-native-pdf": "6.7.5", any solution?. let me know here

    Screenshot 2024-12-12 at 3 17 35 PM Fatal Exception: java.lang.IllegalStateException: Already closed at io.legere.pdfiumandroid.util.ConfigKt.handleAlreadyClosed(Config.kt:20) at io.legere.pdfiumandroid.PdfPage.renderPageBitmap(PdfPage.kt:358) at io.legere.pdfiumandroid.PdfPage.renderPageBitmap$default(PdfPage.kt:349) at io.legere.pdfiumandroid.PdfiumCore.renderPageBitmap(PdfiumCore.kt:407) 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.loopOnce(Looper.java:257) at android.os.Looper.loop(Looper.java:368) at android.os.HandlerThread.run(HandlerThread.java:67)
  9. bjutkoski commented on Dec 27, 2024

    @bjutkoski

    any news? same issue here

  10. EwaGuziejko commented on Jan 27, 2025

    @EwaGuziejko

    Issue still persists for version 6.7.6

  11. Shasikhan commented on Jan 29, 2025

    @Shasikhan

    Same issue.

    Using
    react-native: 0.73.11
    react-native-pdf: 6.7.6

  12. augusthjerrild commented on Feb 21, 2025

    @augusthjerrild

    Same issue.

    "@config-plugins/react-native-pdf": "9.0.0",
    "react-native-pdf": "^6.7.7",
    "react-native": "0.77.0",

  13. husnaintahir commented on Mar 22, 2025

    @husnaintahir

    Same issue.

    "@config-plugins/react-native-pdf": "9.0.0", "react-native-pdf": "^6.7.7", "react-native": "0.77.0",

    +1

  14. gonca-gul commented on May 7, 2025

    @gonca-gul

    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.

  15. suresh-mojro commented on May 21, 2025

    @suresh-mojro

    I am facing the same issue on android
    "react-native": "^0.79.1",
    "react-native-pdf": "^6.7.7",

    if some one have any solutions please help here

  16. Shasikhan commented on May 21, 2025

    @Shasikhan

    @suresh-mojro Try to apply patch from here: #830 (comment)

  17. suresh-mojro commented on May 21, 2025

    @suresh-mojro

    @suresh-mojro Try to apply patch from here: #830 (comment)

    it was not working if I use url, it works only if i use cache file location

  18. Shasikhan commented on May 21, 2025

    @Shasikhan

    @suresh-mojro I am also using URL and cache disabled, in my case react-native version is "0.77.2" .

  19. suresh-mojro commented on May 23, 2025

    @suresh-mojro

    @suresh-mojro I am also using URL and cache disabled, in my case react-native version is "0.77.2" .

    from react-native-pdf version 6.7.4 onwards they have changed android native dependency for pdf rendering, so i think that was causing the issue, so i have made the changes and created patch for my usability in the latest version it self, this patch will work for both IOS and Android.

    react-native-pdf+6.7.7.patch

  20. SamiChab commented on May 28, 2025

    @SamiChab

    The patch of @suresh-mojro solved the problem for me

    react-native-pdf+6.7.7.patch

  21. jakhil232 commented on Jul 24, 2025

    @jakhil232

    The patch of @suresh-mojro solved the problem for me

    react-native-pdf+6.7.7.patch

    This is a very long patch, I don't want to add these much changes. Can you please suggest the bare minimum changes needed to fix this out of all the changes done.

  22. suresh-mojro commented on Jul 24, 2025

    @suresh-mojro

    The patch of @suresh-mojro solved the problem for me

    react-native-pdf+6.7.7.patch

    This is a very long patch, I don't want to add these much changes. Can you please suggest the bare minimum changes needed to fix this out of all the changes done.

    No i don't have ant other solution as of now, that has to come from their team, since it was causing due to native dependencies in android, we have to wait till the next upgrade.

  23. adarshlatiyan commented on Jul 28, 2025

    @adarshlatiyan

    The patch doesn't support 16kb page size.

    The patch of @suresh-mojro solved the problem for me

    react-native-pdf+6.7.7.patch

    This is a very long patch, I don't want to add these much changes. Can you please suggest the bare minimum changes needed to fix this out of all the changes done.

    No i don't have ant other solution as of now, that has to come from their team, since it was causing due to native dependencies in android, we have to wait till the next upgrade.

    @suresh-mojro This solution isn't compatible with 16kb page size.
    The following PR aims at resolving the same.
    zacharee/AndroidPdfViewer#1

  24. Natanaelvich commented on Dec 10, 2025

    @Natanaelvich

    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.

  25. eduardolbruno commented on Dec 12, 2025

    @eduardolbruno

    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.

    This library isn't compatible with Expo yet. Sharing for anyone interested in using it.

  26. iliascandis commented on Dec 17, 2025

    @iliascandis

    The following patch addressed the issue while having 16 kb page size compatibility

    react-native-pdf-npm-7.0.3-6313469aca.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions