react-native-pdf icon indicating copy to clipboard operation
react-native-pdf copied to clipboard

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

Open anasvemmully opened this issue 2 years ago • 25 comments

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!

anasvemmully avatar Nov 08 '24 03:11 anasvemmully

Same issue

NJneeraj avatar Nov 09 '24 14:11 NJneeraj

Same issue

keung7252 avatar Nov 14 '24 08:11 keung7252

Same issue

BerkeAras-SMM avatar Dec 04 '24 15:12 BerkeAras-SMM

@wonday Any ideas?

BerkeAras-SMM avatar Dec 04 '24 15:12 BerkeAras-SMM

Seems the same as: https://github.com/wonday/react-native-pdf/issues/830

vladimirivanoviliev avatar Dec 05 '24 14:12 vladimirivanoviliev

Also seems mentioned in latest version: https://github.com/wonday/react-native-pdf/pull/840

vladimirivanoviliev avatar Dec 05 '24 14:12 vladimirivanoviliev

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)

Mallikarjuna-s avatar Dec 12 '24 09:12 Mallikarjuna-s

any news? same issue here

bjutkoski avatar Dec 27 '24 10:12 bjutkoski

Issue still persists for version 6.7.6

EwaGuziejko avatar Jan 27 '25 11:01 EwaGuziejko

Same issue.

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

Shasikhan avatar Jan 29 '25 09:01 Shasikhan

Same issue.

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

augusthjerrild avatar Feb 21 '25 16:02 augusthjerrild

Same issue.

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

+1

husnaintahir avatar Mar 22 '25 11:03 husnaintahir

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.

gonca-gul avatar May 07 '25 13:05 gonca-gul

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

suresh-mojro avatar May 21 '25 05:05 suresh-mojro

@suresh-mojro Try to apply patch from here: https://github.com/wonday/react-native-pdf/issues/830#issuecomment-2641958482

Shasikhan avatar May 21 '25 06:05 Shasikhan

@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

suresh-mojro avatar May 21 '25 06:05 suresh-mojro

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

Shasikhan avatar May 21 '25 06:05 Shasikhan

@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

suresh-mojro avatar May 23 '25 05:05 suresh-mojro

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

react-native-pdf+6.7.7.patch

SamiChab avatar May 28 '25 12:05 SamiChab

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.

jakhil232 avatar Jul 24 '25 06:07 jakhil232