React-native-image-picker: Delay between pick and showImagePicker callback

Created on 29 Sep 2016  路  4Comments  路  Source: react-native-image-picker/react-native-image-picker

Hi,

There is a 5 second delay between when I select an image to when the ImagePicker.showImagePicker callback is fired. Is this the expected behaviour?

If so, is there any way I can fire a method at the point the image is selected so that I can show a loading message?

Any help appreciated, thanks

Most helpful comment

You should set noData: true or lower the quality/maxWidth/maxHeight options to get better performance. The delay is due to sending a giant base64 encoded string over the React Native bridge.

All 4 comments

You should set noData: true or lower the quality/maxWidth/maxHeight options to get better performance. The delay is due to sending a giant base64 encoded string over the React Native bridge.

Thank you! That helped allot

Hi! Now there are like 2 sec delay after picture selection. Can we have event "beforeSelect" just right after user click?

Seeing the same delay, roughly 2 seconds, even with:

mediaType: 'photo',
maxWidth: 800,
maxHeight: 600,
quality: 0.5,

Dodgy hack someone may find useful was to fire our own "loading" overlay just before firing the imagepicker, but even that needs a tiny delay before firing it, otherwise there's not enough time for the overlay to display.

    const options = {
        mediaType: 'photo',
        maxWidth: 800,
        maxHeight: 600,
        quality: 0.5,
    }

    // this is a strange hack
    // need to have a tiny delay after showing the overlay, before firing the image-picker

    this.showOverlay(  // just sets state to then show an overlay/modal
        { loading: true },
        () => setTimeout( () => ImagePicker.launchImageLibrary( options, this.handleChosenPhoto ), 10)
    );
Was this page helpful?
0 / 5 - 0 ratings