angular2-img-cropper icon indicating copy to clipboard operation
angular2-img-cropper copied to clipboard

Firefox problem

Open eszakacs opened this issue 7 years ago • 13 comments

When I upload a large image (3-5 MB) whit Firefox the image doesn't appear. Whit Chrome is working fine. Has anybody experienced the same problem?

eszakacs avatar Jun 16 '17 18:06 eszakacs

I have seen the problem, but also on relatively smaller images.

i got this error in console when the image doesn't appear:


TypeError: Argument 1 of Node.contains does not implement interface Node.[Learn More]  vendor.bundle.js%20line%20309%20%3E%20eval:5576:13
	FocusOriginMonitor.prototype._onBlur webpack:///./~/@angular/material/@angular/material.es5.js?:5576:13
	FocusOriginMonitor.prototype.monitor/blurListener webpack:///./~/@angular/material/@angular/material.es5.js?:5396:71
	ZoneDelegate.prototype.invokeTask webpack:///./~/zone.js/dist/zone.js?:424:17
	Zone.prototype.runTask webpack:///./~/zone.js/dist/zone.js?:191:28
	ZoneTask/this.invoke webpack:///./~/zone.js/dist/zone.js?:486:28
	FocusTrap.prototype.focusFirstTabbableElement webpack:///./~/@angular/material/@angular/material.es5.js?:4609:13
	FocusTrap.prototype.focusInitialElement webpack:///./~/@angular/material/@angular/material.es5.js?:4599:13
	FocusTrap.prototype.focusInitialElementWhenReady/< webpack:///./~/@angular/material/@angular/material.es5.js?:4550:78
	SafeSubscriber.prototype.__tryOrUnsub webpack:///./~/rxjs/Subscriber.js?:238:13
	SafeSubscriber.prototype.next webpack:///./~/rxjs/Subscriber.js?:185:17
	Subscriber.prototype._next webpack:///./~/rxjs/Subscriber.js?:125:9
	Subscriber.prototype.next webpack:///./~/rxjs/Subscriber.js?:89:13
	FirstSubscriber.prototype._emitFinal webpack:///./~/rxjs/operator/first.js?:135:13
	FirstSubscriber.prototype._emit webpack:///./~/rxjs/operator/first.js?:118:9
	FirstSubscriber.prototype._next webpack:///./~/rxjs/operator/first.js?:97:13
	Subscriber.prototype.next webpack:///./~/rxjs/Subscriber.js?:89:13
	EventEmitter.prototype.subscribe/schedulerFn< webpack:///./~/@angular/core/@angular/core.es5.js?:3839:36
	SafeSubscriber.prototype.__tryOrUnsub webpack:///./~/rxjs/Subscriber.js?:238:13
	SafeSubscriber.prototype.next webpack:///./~/rxjs/Subscriber.js?:185:17
	Subscriber.prototype._next webpack:///./~/rxjs/Subscriber.js?:125:9
	Subscriber.prototype.next webpack:///./~/rxjs/Subscriber.js?:89:13
	Subject.prototype.next webpack:///./~/rxjs/Subject.js?:55:17
	EventEmitter.prototype.emit webpack:///./~/@angular/core/@angular/core.es5.js?:3825:54
	NgZone.prototype.checkStable webpack:///./~/@angular/core/@angular/core.es5.js?:4102:17
	NgZone.prototype.onLeave webpack:///./~/@angular/core/@angular/core.es5.js?:4178:9
	NgZone.prototype.forkInnerZoneWithAngularBehavior/this.inner<.onInvoke webpack:///./~/@angular/core/@angular/core.es5.js?:4140:21
	ZoneDelegate.prototype.invoke webpack:///./~/zone.js/dist/zone.js?:390:17
	Zone.prototype.run webpack:///./~/zone.js/dist/zone.js?:141:24
	NgZone.prototype.run webpack:///./~/@angular/core/@angular/core.es5.js?:4005:51
	AnimationRendererFactory.prototype.scheduleListenerCallback webpack:///./~/@angular/platform-browser/@angular/platform-browser/animations.es5.js?:288:13
	AnimationRenderer.prototype.listen/< webpack:///./~/@angular/platform-browser/@angular/platform-browser/animations.es5.js?:543:17
	listenOnPlayer/< webpack:///./~/@angular/animations/@angular/animations/browser.es5.js?:81:48
	listenOnPlayer/< webpack:///./~/@angular/animations/@angular/animations/browser.es5.js?:81:48
	WebAnimationsPlayer.prototype._onFinish/< webpack:///./~/@angular/animations/@angular/animations/browser.es5.js?:4655:60
	forEach self-hosted:251:13
	WebAnimationsPlayer.prototype._onFinish webpack:///./~/@angular/animations/@angular/animations/browser.es5.js?:4655:13
	WebAnimationsPlayer.prototype._buildPlayer/< webpack:///./~/@angular/animations/@angular/animations/browser.es5.js?:4701:70
	ZoneDelegate.prototype.invokeTask webpack:///./~/zone.js/dist/zone.js?:424:17
	Zone.prototype.runTask webpack:///./~/zone.js/dist/zone.js?:191:28
	ZoneTask/this.invoke webpack:///./~/zone.js/dist/zone.js?:486:28

are you using angular material with the cropper?

polo2ro avatar Jun 20 '17 07:06 polo2ro

I'm not using angular material and there is no error message in the console. When I upload an image, the grey canvas appears, but not the image. I have seen this problem with smaller images too. The smaller images sometimes appears, sometimes doesn't. It is strange. I tried with the latest Firefox and with older ones too in different OSs.

eszakacs avatar Jun 20 '17 07:06 eszakacs

The plunker demo works fine in Firefox, but it uses the 0.7.7 version. I use Angular 4, so I need a newer version.

eszakacs avatar Jun 20 '17 07:06 eszakacs

I also use angular4, i will do some tests in chrome to see if the trace appear, this is probably unrelated

polo2ro avatar Jun 20 '17 07:06 polo2ro

on chrome, there is no bug and the trace does not appear. on firefox, the trace appear for every image whatever it is visible or not

polo2ro avatar Jun 20 '17 08:06 polo2ro

Yes, on Chrome is working fine. Also on Edge, Safari. Only on Firefox exists this problem.

eszakacs avatar Jun 20 '17 08:06 eszakacs

Have the same problem, only in FF. same image cannot be loaded in the first time, but loaded in the second time. there is no error message in the console.

Mage111 avatar Jul 11 '17 12:07 Mage111

Somehow Firefox is slower loading images, I was having the problem and was able to fix it only by adding an onload callback on my image and after the image was fully loaded then setting it in the component.

juank11memphis avatar Jul 28 '17 19:07 juank11memphis

thanks for the tip @juank11memphis

polo2ro avatar Jul 28 '17 21:07 polo2ro

@juank11memphis Thank you, i tried and it is working for me too.

eszakacs avatar Jul 30 '17 08:07 eszakacs

This work around brings some performance issues, specially on Edge and IE.

I made it work on firefox using a setTimeout with 0s.

`public ngOnInit() { this.initCropperSettings(); this.cropper.settings = this.cropperSettings; let image: any = new Image(); image.src = this.data.image.src;

setTimeout(() => {
  this.cropper.setImage(image);
}, 0);

}`

ZeroCR avatar Aug 27 '17 17:08 ZeroCR

thx @ZeroCR, for firefox 0 timeout didn't help me with big images, but 1000 timeout works well.

cravter avatar Sep 06 '17 07:09 cravter

The solution of @ZeroCR will only work when the timeout is higher than the time it takes to load the image. As @juank11memphis pointed out, you should wait for the image to be loaded and then call setImage

Like this:

public ngOnInit() {
  let image: any = new Image();
  image.onload = () => {
    this.cropper.setImage(image);
  };
  image.src = this.data.image.src;
}

SteveVanOpstal avatar Jan 30 '18 11:01 SteveVanOpstal