Tell us which versions you are using:
Tell us to which platform this issue is related
No crash.
Illegal callback invocation from native module. This callback type only permists a single invocation from native code.
Call openPicker()
In the photo gallery, select a photo
Cancel (which takes you back to the photo gallery)
Cancel again (to go back to the calling app)
Instead it crashes.
function chooseFromLibrary(fireBaseLocation, maxDimensions, callback) {
ImagePicker.openPicker({
mediaType: "photo",
width: maxDimensions ? maxDimensions.x : 300,
height: maxDimensions ? maxDimensions.y : 300,
cropping: true,
})
.then((image) => ImageStorage.ProcessPhoto(fireBaseLocation, callback, image))
.catch((e) => {
console.log(e);
return callback(null);
});
}
function processPhoto(fireBaseLocation, callback, image) {
if ( image && image.path ) {
const firebaseManager = FirebaseManager.getInstance();
const source = {uri: image.path.replace('file://', ''), isStatic: true};
firebaseManager.storeImage(fireBaseLocation, source.uri, (fileURL) => {
if ( callback ) {
if ( fileURL ) {
callback({uri: fileURL, isStatic: true});
} else {
callback(null);
}
}
})
} else {
if ( callback ) {
callback (null);
}
}
}
Love react-native-image-crop-picker? Please consider supporting our collective:
馃憠 https://opencollective.com/react-native-image-crop-picker/donate
the same issue
the same issue
+1, wanna new version
same
same
I can confirm that this issue is still happening in RN 0.59.5 with 0.23.1.
Code:
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: true
}).then(image => {
console.log(image);
}).catch((error) => {
alert(error)
});
It ignores my catch and causes the red warning screen to appear, with the error: Illegal callback from native module. This callback type only permits a single invocation from native code.
Seems like the problem could be occurring because the original Promise is already called when the user cancels the image selection, so there should be another Promise to deal with cancelling the entire viewcontroller.
https://medium.com/nycdev/calling-a-callback-multiple-times-in-a-react-native-module-5c3c61f2fca4
Can someone implement this?
Possibly solved:
ImageCropPicker.m
// Crop image has been canceled.
I commented out the self.reject which will prevent the Promise from expiring too early. Is there a better way to solve this error?
@joyshion's commit fixed this issue well
Any update here? Can I resolve this issue without forking? It's a giant problem for this library. User can't use cropper in the main case:
@joyshion @howieyoung When can we expect this to be merged?
@cinnabarhorse very very thank you. i encountered this problem for three weeks. problem is solved. thank you for efforts.
For anyone coming here for a fix, one was released in 0.24.1 of this library!
amazing! thanks @simonmitchell
error is gone now, but it still throws a warning - 'unhandled promise rejection'
do you know how to get rid of that?
I am also facing the same issue when I launch image from Library and again try to crop the image. Here I need to click the choose twice and it shows the error as "Illegal callback invocation from the native module. This callback type only permits a single invocation from native code"
RN version is 0.58.4
I am using "react-native-image-crop-picker": "^0.22.0".
I have upgraded to the latest. Still facing the same issue
Most helpful comment
Possibly solved:
ImageCropPicker.m
// Crop image has been canceled.
(RSKImageCropViewController *)controller {
[self dismissCropper:controller selectionDone:NO completion:[self waitAnimationEnd:^{
if (self.currentSelectionMode == CROPPING || [[self.options objectForKey:@"cropping"] boolValue]) {
//self.reject(ERROR_PICKER_CANCEL_KEY, ERROR_PICKER_CANCEL_MSG, nil);
}
}]];
}
I commented out the self.reject which will prevent the Promise from expiring too early. Is there a better way to solve this error?