Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS - App crashes when load full image size #209

Closed
LSmint opened this issue Aug 24, 2018 · 4 comments
Closed

iOS - App crashes when load full image size #209

LSmint opened this issue Aug 24, 2018 · 4 comments
Labels

Comments

@LSmint
Copy link

LSmint commented Aug 24, 2018

I was encountered an issue after loaded the image while using ImageSource module. The trace log shows 'Unable to load image data, ' when selected a large image size such as 3000 width x 2000 height.

Here is how i called the imagepicker and convert it to imagesource:

let context = imagepicker.create({
                mode:"single",
                mediaType:1
            });
            context.authorize().then(() => {
                return context.present();
            })
            .then((selection)=>{
                selection.forEach(function(selected){
                    let source = new ImageSourceModule.ImageSource();
                    source.fromAsset(selected).then((source) => {
                           console.log(source.width+"x"+source.height); <-- 3000 x 3000
                    })
                })
            },(error) => {
                console.log("Error: " + error);
                that.router.back();
            });

After tried a few times to reselect the image, i get another error and app was crashed due to memory leaked. "Connection to assetsd was interrupted or assetsd die. Unbalanced calls to begin/end appearance transitions for <UIViewControllerImpl: 0x12bd13230>. Received memory warning."

Any proper way to get the image source or resize the image before load the image source? I'm using the latest version of nativescript-imagepicker.

@NickIliev
Copy link
Contributor

NickIliev commented Aug 31, 2018

@LSmint 300 x 2000 is not an extremely large image and should not lead to OOM. However, please do let me know what is the device you are using in this scenario - I've tested on several iPhones but was not able to reproduce anything close to a memory exception. Apart from that, you can't modify the ImageAsset size but only the size of the created ImageSource.

@LSmint
Copy link
Author

LSmint commented Sep 18, 2018

Hi @NickIliev,

I'm using iPhoneX version 11.2.6. I found that the error exception occur only if i apply nativescript-imagecropper after the return image from imagepicker. For temporary solution, i resize the image size as following:

let context = imagepicker.create({
                mode:"single",
                mediaType:1
            });
            context.authorize().then(() => {
                return context.present();
            })
            .then((selection)=>{
                selection.forEach(function(selected){
               // resize image
                selected.options = {
                       width: 600,
                       height: 600,
                       keepAspectRatio: true
                    };
                    let source = new ImageSourceModule.ImageSource();
                    source.fromAsset(selected).then((source) => {
                          // pass resized image to image cropper 
                           let cropper = new ImageCropper(); 
                           cropper.show(source, { lockSquare: true}).then((args) => {
                          })
                    })
                })
            },(error) => {
                console.log("Error: " + error);
                that.router.back();
            });

@NickIliev
Copy link
Contributor

Closing this one as the issue seems related to the image cropper and not to nativescript-imagepicker.

@ghost ghost removed the question label Sep 18, 2018
@NatanijelVasic
Copy link

NatanijelVasic commented Oct 30, 2018

@NickIliev @LSmint Actually I get a similar memory problem when using the image-picker plugin by itself. In fact, even on the demo app, the memory usage is way higher than expected.

I posted about it here:
#222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants