react-native-blob-util icon indicating copy to clipboard operation
react-native-blob-util copied to clipboard

ANR on Downloading PDF on Android

Open cw-sanjeev opened this issue 1 year ago • 2 comments

Getting Few ANRs on Crashlytics on download PDF

Version Used: "react": "17.0.1", "react-native": "0.64.4", "react-native-blob-util": "^0.17.0"

Code:

downloadPDF(pdfUrl, pdfName) {
    const { dirs } = RNFetchBlob.fs;
    const android = RNFetchBlob.android;
    const iOS = RNFetchBlob.ios;
    const dirToSave = Platform.OS === 'android' ? dirs.DownloadDir : dirs.DocumentDir
    const configOptions = {
      fileCache: true,
    appendExt: 'pdf',
    path: destPath,
    addAndroidDownloads: {
      useDownloadManager: true,
      path: destPath,
      notification: true,
      title: pdfName + '.pdf',
      description: pdfName,
      mime: MIME_PDF,
      mediaScannable: true,
    },
    };

    RNFetchBlob.config(configOptions)
      .fetch("GET", pdfUrl, {})
      .then((res) => {
        if (res) {
          if (Platform.OS !== 'android' && res.data) {
            RNFetchBlob.fs.writeFile(configOptions.path, res.data, "base64");
            iOS.openDocument(configOptions.path);
          } else {
            if (res.path()) {
              android.actionViewIntent(res.path(), MIME_PDF);
            }
          }
        }
      })
      .catch((error) => {
        //Throw Exception
      });
  }

Few ANR screenshots from Crashlytics: image image Can anyone help here

cw-sanjeev avatar Mar 09 '23 23:03 cw-sanjeev

@cw-sanjeev At least there is a version compatibility issue here. image

SiberianJohnny avatar Mar 10 '23 02:03 SiberianJohnny

Downgraded lib version to 0.16.4, still facing this

cw-sanjeev avatar Apr 11 '23 11:04 cw-sanjeev