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

Freezing App #58

Open
Sartori-RIA opened this issue Sep 30, 2019 · 16 comments
Open

Freezing App #58

Sartori-RIA opened this issue Sep 30, 2019 · 16 comments

Comments

@Sartori-RIA
Copy link

hi, i trying to use this plugin but when image editor is closed the app is freezing for some seconds

my config:

  • NativeScript 6
  • Angular 8
  • Android 9

my source:

const context = imagepicker.create({mode: 'single'});
        context.authorize()
            .then(() => {
                context.present()
                    .then((selection) => {
                        selection.forEach((selected) => {
                             selected.getImageAsync((source) => {
                                    const selectedImgSource = fromNativeSource(source);
                                    new ImageCropper().show(selectedImgSource, {height: 500, width: 500})
                                        .then((args) => {
                                            console.log('success')
                                        })
                                        .catch((e) => {
                                           console.error(e);
                                        })
                                  })
                           });
                    })
           });
@shiv19
Copy link
Collaborator

shiv19 commented Nov 5, 2019

@Sartori-RIA move the call to cropper inside a setTimeout and that should prevent your app from freezing

@ParthMaisheri
Copy link

setTimeout doesn't work for me i tried it , it freeze's for 2 seconds @shiv19 @Sartori-RIA @bthurlow

@shiv19
Copy link
Collaborator

shiv19 commented Dec 17, 2019

@ParthMaisheri can you share your implementation here so that I can take a look at how you are calling the cropper?

@ParthMaisheri
Copy link

ParthMaisheri commented Dec 17, 2019

SOURCE:

private startSelection(context) {
	var ms = (new Date).getMilliseconds;
	let that = this;
	this.uploadedImage = null;
	context
		.authorize()
		.then(() => {
			//  that.postImage = null;
			return context.present();
		})
		.then((selection) => {
			that.postImage = that.isSingleMode && selection.length > 0 ? selection[0] : null;
			selection.forEach((selected) => {
				const ios = selected.ios;
				setTimeout(() => {
					selected.getImageAsync(source => {
						const selectedImgSource = imageSource.fromNativeSource(source);
						imageCropper
							.show(selectedImgSource, {
								width: 350,
								height: 300
							})
							.then(args => {
								if (args.image !== null) {
									var localPath = null;
									localPath = this.savepic(args.image);
									console.log("IMAGE" + JSON.stringify(args.image.android));
									this.uploadedImage = localPath;
									this.postImage = localPath;
									this.picUploaded = "showIcon";
									this.imgHolder = "feedImg";
								} else {
									console.log("FAILED");
									this.removePicture();
								}
							})
							.catch(function (e) {
								console.log("inside catch" + e);
							});
					});
				}, 20);
			});
		});
}

@shiv19

@shiv19
Copy link
Collaborator

shiv19 commented Dec 17, 2019

@ParthMaisheri please move call to the cropper inside setTimeout.
And you'll need a timeout of atleast 250ms

You can remove the outer timeout of 20ms that you have.
That timeout is not required.

@ParthMaisheri
Copy link

ParthMaisheri commented Dec 17, 2019

tried the way too, doesn't work

private startSelection(context) {
	var ms = (new Date).getMilliseconds;
	let that = this;
	this.uploadedImage = null;


	context
		.authorize()
		.then(() => {
			//  that.postImage = null;
			return context.present();
		})
		.then((selection) => {


			that.postImage = that.isSingleMode && selection.length > 0 ? selection[0] : null;
			selection.forEach((selected) => {
				const ios = selected.ios;

				selected.getImageAsync(source => {
					const selectedImgSource = imageSource.fromNativeSource(source);
					setTimeout(() => {
						imageCropper
							.show(selectedImgSource, {
								width: 350,
								height: 300
							})
							.then(args => {
								if (args.image !== null) {


									var localPath = null;
									localPath = this.savepic(args.image);

									console.log("IMAGE" + JSON.stringify(args.image.android));
									this.uploadedImage = localPath;
									this.postImage = localPath;
									this.picUploaded = "showIcon";
									this.imgHolder = "feedImg";

								} else {
									console.log("FAILED");
									this.removePicture();


								}
							})
							.catch(function (e) {
								console.log("inside catch" + e);
							});
					}, 250);
				});


			});

		});

}

@shiv19

@shiv19
Copy link
Collaborator

shiv19 commented Dec 17, 2019

@ParthMaisheri which version of image cropper are you on?

@ParthMaisheri
Copy link

"nativescript-imagecropper": "1.0.7"
@shiv19

@shiv19
Copy link
Collaborator

shiv19 commented Dec 17, 2019

@ParthMaisheri can you try the latest version instead?

@ParthMaisheri
Copy link

ParthMaisheri commented Dec 17, 2019

even after updating it freeze's @shiv19 .
updated it to 2.0.0

@shiv19
Copy link
Collaborator

shiv19 commented Dec 17, 2019

Ok, please provide a demo app demonstrating the issue, I'll take a look at it tomorrow :)

@ParthMaisheri
Copy link

can you help me adding "loading message box", as i cant share the demo app. @shiv19

@shiv19
Copy link
Collaborator

shiv19 commented Dec 17, 2019

You can use nativescript-loading-indicator plugin to show loading indicator

@ParthMaisheri
Copy link

hey @shiv19 i am now facing image pixelation issue.
looking at the code do think the height width given to image cropper is causing image to pixelate.

@shiv19
Copy link
Collaborator

shiv19 commented Dec 18, 2019

@ParthMaisheri sorry I can't help you unless you send me a demo code base demonstrating the issue you are facing.
Simply complaining about the problem doesn't help in resolving your issue.
Don't get me wrong, I want to help you, but unless I have enough info about the issue, I can't do much about it.
I've been using this plugin in many projects without any issues.

@shiv19
Copy link
Collaborator

shiv19 commented Jan 5, 2020

#49 (comment)

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

No branches or pull requests

3 participants