wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.6k stars 557 forks source link

Android: Native crash #868

Open Anusha-mathur opened 2 months ago

Anusha-mathur commented 2 months ago

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

updated the app from 0.71 to 0.74.5 and PDF is not working after that. The app crashes as soon as the PDF finishes loading.

2) Interesting logs

java.lang.IllegalStateException: Tried to access a JS module before the React instance was fully set up. Calls to ReactContext#getJSModule should only happen once initialize() has been called on your native module. at com.facebook.react.bridge.ReactContext.getJSModule(ReactContext.java:180) at org.wonday.pdf.PdfView.loadComplete(PdfView.java:139) at com.github.barteksc.pdfviewer.listener.Callbacks.callOnLoadComplete(Callbacks.java:83) at com.github.barteksc.pdfviewer.PDFView.loadComplete(PDFView.java:831) at com.github.barteksc.pdfviewer.DecodingAsyncTask.onPostExecute(DecodingAsyncTask.java:90) at com.github.barteksc.pdfviewer.DecodingAsyncTask.onPostExecute(DecodingAsyncTask.java:27) at android.os.AsyncTask.finish(AsyncTask.java:771) at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8177) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

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

Show us the code you are using?

<Pdf trustAllCerts={false} source={source} fitWidth activityIndicator={} onLoadComplete={(numberOfPages, filePath) => console.log(number of pages: ${numberOfPages})} onPageChanged={(page, numberOfPages) => console.log(current page: ${page})} onError={(error) => { console.log(error); this.setPdfError(); }} onPressLink={(uri) => console.log(Link press: ${uri})} style={this.styles.pdf} />

griffinshuth commented 2 months ago

Im seeing the same thing here

mahshid22 commented 1 month ago

Hi I have same problem here when I change page number very quick, it crashes Is there any solution?

ferasabufaresKabi commented 1 month ago

@Anusha-mathur Hi How are you did find any solution for this

rajivchaulagain commented 1 month ago
   <Pdf
          ref={pdfRef}
          trustAllCerts={false}
          source={{
            uri,
          }}
          onLoadProgress={(percent) => calculateLoadingProgress(percent)}
          style={{
            width,
            height,
          }}
          onPageSingleTap={(e, x, y) => handlePosition(e, x, y)}
          onLoadComplete={(numberOfPages, path, { height, width }) =>
            console.log(`height & width : ${height} ${width}`)
          }
        />

this is my implementation and I never got such error

ferasabufaresKabi commented 1 month ago

@rajivchaulagain thank you for your response i have figure out what is the problem and i have fix it

TechLead18 commented 1 week ago

@rajivchaulagain thank you for your response i have figure out what is the problem and i have fix it

what was the issue?