Skip to content

Read/write extremely slow on IOS  #474

Open
@alainib

Description

@alainib

I'm writing a 5mo json in a file with utf8 encoding.

  1. it's very slow on IOS

it take +-50ms with android
it take +-6000ms with ios iphone 5

reading the file take
250ms with android
13000ms with ios.

  1. i get empty return when using base64 option on Ios only

  2. my code :

       var RNFS = require('react-native-fs');
       const rootPath = RNFS.DocumentDirectoryPath; //= (os == "android") ? RNFS.DocumentDirectoryPath :RNFS.MainBundlePath
    
       export function writeFile(filename, content) {
         var path = rootPath + '/' + filename;
         return RNFS.writeFile(path, content, 'base64').then(() => {
           console.log('FILE WRITTEN!');
           return true;
         }).catch((err) => {
           console.log(err.message);
           return false;
         });
       }
    
       export async function readFile(filename) {
         var path = rootPath + '/' + filename;
         var content = await RNFS.readFile(path, 'base64');
         console.log("content before return", content );
         return content;
       }
    

and how i made the calls

      async readFile() {
        const content = await tools.readFile("en-test.js");
        console.log("content", content);
      }

  
      async writeFile() {
        const res = await tools.writeFile(
          "en-test.js",
          'Lorem ipsum dolor sit ametLorem ipsum dolor sit ametLorem ipsum dolor sit ametLorem ipsum dolor'  
         );
        console.log("res", res);
      }

I need to keep utf8, any advice ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions