nativescript-imagecropper icon indicating copy to clipboard operation
nativescript-imagecropper copied to clipboard

Crashes on Android when Activity Closes

Open JWiseCoder opened this issue 6 years ago • 8 comments

Whenever the cropper finishes on Android, it returns everything properly. However, when the cropper activity closes, it causes the entire app to crash without any visible error. I've dug through the device logs, but the only thing I could see was something like InputDispatcher: Attempted to unregister already unregistered input channel

Is it possible I'm doing something wrong? Or is this a bug in the underlying code?

JWiseCoder avatar May 28 '19 13:05 JWiseCoder

Just run the things inside your .then block in a setTimeout @JWiseCoder

shiv19 avatar May 28 '19 19:05 shiv19

I did. It still crashes without writing out an error. I even put a delay on each setTimeout, and it still crashed.

JWiseCoder avatar May 29 '19 13:05 JWiseCoder

I still haven't found any way to keep it from crashing. It has something to do with how the Activity is being closed. Not sure if it's something inside the uCrop library or something this plugin is doing.

Or could it be something like the native image in the ImageSource is linked to the cached image file on disk, which is getting deleted before it returns? Maybe it's not entirely in memory or something?

JWiseCoder avatar Jun 10 '19 13:06 JWiseCoder

My app crashes when I take another picture with nativescript-camera, after cropping the previous picture. I also tried setTimeouts everywhere, no help there.

Update: It seems I mixed up the angular template with the normal usage, when using the proper angular template, it works fine.

Noppey avatar Dec 30 '19 11:12 Noppey

@Noppey Can you elaborate on that? Do you have an example?

JWiseCoder avatar Dec 30 '19 15:12 JWiseCoder

https://github.com/bthurlow/nativescript-imagecropper/blob/master/demo/app/main-view-model.ts

This demo-code broke when I used that in Angular (only changed some deprecated dependencies), after clicking the button for "takepicture" a second time.

When not cropping, taking the picture worked just fine. I don't have an exact reproduction example, as I kept trying to fix it.

Noppey avatar Dec 30 '19 16:12 Noppey

Ok, after I'm back from holidays, I'll release the pro plugins version of this plugin to this public version. That is stable and I did the support for {N} 6 on it.

In the current public version, it wasn't me who made the upgrade to {N} 6 and as such I haven't been offering support for it lately.

After I release the proplugins verison to public, I'll notify here and from then I'll start supporting this plugin once again.

I understand that this is an important plugin and needs better support.

Expect a stable version to be released on or before Jan 3rd 2020. :)

Cheers

shiv19 avatar Dec 30 '19 18:12 shiv19

Update: v3.0.0 was released now. It matches the Proplugins variant. Please check the demo app once again to see the proper implementation.

I'm actively using this plugin and have had no issues with it so far.

the setTimeout part here is crucial to make it work on iOS, because the asset won't be immediately ready to be read by the plugin. https://github.com/bthurlow/nativescript-imagecropper/blob/6a25cc459a099a9c89e7ff98fc6fbc17b48a7a40/demo/app/main-view-model.ts#L152

I've also added my service implementation to show you how to use it with proper loader and also support image uploading with compression.

hope this helps :)

Cheers! Shiva <3

shiv19 avatar Jan 05 '20 21:01 shiv19