-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Android Performance: readStream takes too long #321
Comments
@latusaki , thanks for the feedback, will look into this issue. Besides, have you tried an interval like - 1 second and 1MB buffer size ? |
Have not tried so large interval, will check it today. Although, readFile also takes 15sec, so I guess the bottleneck is the bridge. On 15 Apr 2017 10:14 a.m., Ben Hsieh <notifications@github.com> wrote:@latusaki , thanks for the feedback, will look into this issue. Besides, have you tried an interval like 1 second and 1MB buffer size ?
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@latusaki , after some investigation I noticed that the RNFetchBlob.config({ path : dirs.DCIMDir + '/readStreamtest'})
.fetch('GET', `${TEST_SERVER_URL}/public/9mb-5987598452-dummy`)
.then((res) => {
return fs.readStream(res.path(), 'utf8', 1024000, 250)
})
.then((stream) => {
let begin = Date.now()
let data = ''
stream.open()
stream.onData((chunk) => {
console.log('read chunk', chunk.length)
data += chunk
})
stream.onEnd(() => {
console.log('size of 9mb dummy', data.length)
console.log(Date.now() - begin, 'ms elapsed')
done()
})
}) The process can be done in less than 4 seconds, the test device I'm using is Sony Experia XA (Android 6) Not sure if it's helpful? Perhaps you can upgrade the package from branch |
Thank you for looking into this. I tried with the issue-321 branch, and changed the buffer/interval to the above specifications, but still same performance. Although checking at the committed code on the branch, only the error handling has changed, is that correct ? |
@latusaki , what's the device and OS version you're using? Have you tried using release mode ? |
using Moto X 2014, android 6, release mode (./gradlew assembleRelease, installed app-release.apk) :/ |
i have the problem too but it not take long time to read file but for check if file exist (~ 1s) |
Library version: 0.10.4
RN Version: 0.41.1
I have a JSON file, inside my assets directory in the android version.
The file is 8MB. I am reading the file using the following function:
The above function takes about 15 seconds to execute on Android, and about 2 seconds on iOS.
Is there any obvious reason why this is happening ? Any optimisations I can make ? Should I increase the buffer, or make changes to the way the file is stored?
The file is loaded once when the application launches, there are no animations or anything interactive while this process takes place, just a loading screen with a gif image
readFile is also taking about the same amount of time.
I have tried tinkering with interval / buffer size, but the loading time does not appear to be affected.. Also the JSON.parse does not appear to add any additional overhead.
By changing the buffer size / interval, the loading time either stays the same, or can get worse, but no improvements.
iOS goes through the same loading screen in about 0.5 sec..
The delay is between promise.resolve(data) being called from Android, and the data reaching my code.
The text was updated successfully, but these errors were encountered: