Giter Club home page Giter Club logo

Comments (21)

AminDannak avatar AminDannak commented on July 19, 2024 4

I have downgrade version @6.7.2 its working fine

for me, it lead to a build issue. i used 6.7.3 and it seems fine. no crash

from react-native-pdf.

Kashifmub205 avatar Kashifmub205 commented on July 19, 2024 2

I was having the same issue. reinstalling the package with the latest one solved my crashing issue but then it was not crashing rather it was giving reactnativeblobutil error. by adding trustAllCerts={false} solved the not displaying pdf issue.

  <PDFView
          style={styles.pdfContainer}
          source={{uri: link}}
          onError={onError}
          trustAllCerts={false}
        />

from react-native-pdf.

Subiyel avatar Subiyel commented on July 19, 2024

same issue

from react-native-pdf.

mdalishanali avatar mdalishanali commented on July 19, 2024

do you find anything?

from react-native-pdf.

minh-dai avatar minh-dai commented on July 19, 2024

+1

from react-native-pdf.

kartavyaparekh96 avatar kartavyaparekh96 commented on July 19, 2024

+1

from react-native-pdf.

alex-strae avatar alex-strae commented on July 19, 2024

I have the same issue when browsing fast between different unloaded PDFs and download does not have time to finish before I start fetching new PDF.

This is due to this code introduced and merged about 2 weeks ago. In index.js, line 279, with declaration of this.lastRNBFTask.

BAD CODE:
.catch(async (error) => {
this._onError(error);
});

comment it out and problem solved.

I am not an very experienced dev, but my guess is that the catch intercepts the cancel call that is supposed to be sent to ReactNativeBlobUtil and run its course there as it should, so instead it doesn't, and the code asks where the hell is my cancel method? Crash.

Well we caught the error before the cancel could do it's thing...

There is another similar catch on line 323. That one is fine, let it be.

from react-native-pdf.

mdalishanali avatar mdalishanali commented on July 19, 2024

from react-native-pdf.

alex-strae avatar alex-strae commented on July 19, 2024

Well, what do you want to do? For me, I had to have the app stop crashing when browsing fast between PDFs. The better approach for me was to comment out the recently introduced code (that I specified in last post).

from react-native-pdf.

mdalishanali avatar mdalishanali commented on July 19, 2024

from react-native-pdf.

kartavyaparekh96 avatar kartavyaparekh96 commented on July 19, 2024

I have downgrade version @6.7.2 its working fine

from react-native-pdf.

alex-strae avatar alex-strae commented on July 19, 2024

from react-native-pdf.

shahid-0 avatar shahid-0 commented on July 19, 2024

I have the same issue when browsing fast between different unloaded PDFs and download does not have time to finish before I start fetching new PDF.

This is due to this code introduced and merged about 2 weeks ago. In index.js, line 279, with declaration of this.lastRNBFTask.

BAD CODE: .catch(async (error) => { this._onError(error); });

comment it out and problem solved.

I am not an very experienced dev, but my guess is that the catch intercepts the cancel call that is supposed to be sent to ReactNativeBlobUtil and run its course there as it should, so instead it doesn't, and the code asks where the hell is my cancel method? Crash.

Well we caught the error before the cancel could do it's thing...

There is another similar catch on line 323. That one is fine, let it be.

I also have the same issue, when I press back button it arise the same error, then I saw your comment and try to do the same thing as you mentioned. But still it arise error. It didn't crash the app but arise error on the onError props, but I don't want to arise any error on the cancel. Then I commented out the below code on the line 146, and it works for me.

// componentWillUnmount() {
//     this._mounted = false;
//     if (this.lastRNBFTask) {
//         this.lastRNBFTask.cancel(err => {
//         });
//         this.lastRNBFTask = null;
//     }
// }

from react-native-pdf.

abanobmikaeel avatar abanobmikaeel commented on July 19, 2024

Also happening to me any way to solve? Happening on latest also. @shahid-0 how does one deploy with commented out code? Is that possible?

from react-native-pdf.

alex-strae avatar alex-strae commented on July 19, 2024

from react-native-pdf.

UgurGumushan avatar UgurGumushan commented on July 19, 2024

+1
This is a blocker and I can't update this package anymore

from react-native-pdf.

IrfanVN avatar IrfanVN commented on July 19, 2024

I have the same issue when browsing fast between different unloaded PDFs and download does not have time to finish before I start fetching new PDF.

This is due to this code introduced and merged about 2 weeks ago. In index.js, line 279, with declaration of this.lastRNBFTask.

BAD CODE: .catch(async (error) => { this._onError(error); });

comment it out and problem solved.

I am not an very experienced dev, but my guess is that the catch intercepts the cancel call that is supposed to be sent to ReactNativeBlobUtil and run its course there as it should, so instead it doesn't, and the code asks where the hell is my cancel method? Crash.

Well we caught the error before the cancel could do it's thing...

There is another similar catch on line 323. That one is fine, let it be.

Wow this is working really well. Spend alot of time on this issue and thank god u have solved my issue

from react-native-pdf.

KarlosQ avatar KarlosQ commented on July 19, 2024

I created this patch (patch-package) for avoid this crash:

react-native-pdf+6.7.4.patch

diff --git a/node_modules/react-native-pdf/index.js b/node_modules/react-native-pdf/index.js
index c7c58d8..70a6057 100644
--- a/node_modules/react-native-pdf/index.js
+++ b/node_modules/react-native-pdf/index.js
@@ -127,7 +127,7 @@ export default class Pdf extends Component {
 
         if ((nextSource.uri !== curSource.uri)) {
             // if has download task, then cancel it.
-            if (this.lastRNBFTask) {
+            if (this.lastRNBFTask?.cancel) {
                 this.lastRNBFTask.cancel(err => {
                     this._loadFromSource(this.props.source);
                 });
@@ -145,7 +145,7 @@ export default class Pdf extends Component {
 
     componentWillUnmount() {
         this._mounted = false;
-        if (this.lastRNBFTask) {
+        if (this.lastRNBFTask?.cancel) {
             this.lastRNBFTask.cancel(err => {
             });
             this.lastRNBFTask = null;
@@ -250,7 +250,7 @@ export default class Pdf extends Component {
 
     _downloadFile = async (source, cacheFile) => {
 
-        if (this.lastRNBFTask) {
+        if (this.lastRNBFTask?.cancel) {
             this.lastRNBFTask.cancel(err => {
             });
             this.lastRNBFTask = null;

from react-native-pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.