question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOMException 'drawImage' on 'CanvasRenderingContext2D' in Chrome & Safari

See original GitHub issue

Expected Behavior

When using croppie.js in combination with ng-croppie.js together should be working in Chrome or Safari.

Actual Behavior

Croppie throws endless uncaught DOMException. Since new release of the Chrome 66 croppie.js throws constantly errors while working with ng-croppie library. In previous Chrome versions (tested on 65, 64 etc.) everything worked fine, but with the new Chrome release it hanging out on:

LOC 1179 for v2.6.2 ctx.drawImage(this.elements.preview, left, top, width, height, startX, startY, canvasWidth, canvasHeight);

LOC 1188 for v2.5.1 ctx.drawImage(this.elements.preview, left, top, Math.min(width, self._originalImageWidth), Math.min(height, self._originalImageHeight), startX, startY, outWidth, outHeight);

Error Description Uncaught (in promise) DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.

The same code running in other browsers (tested on Firefox v59.0.2 and Internet Explorer v11.0.56) does not throw above mentioned error.

Steps to Reproduce the Problem

  1. include croppie.js
  2. include ng-croppie (v1.2.2)
  3. instantiate angular 1.x app

Example Link

Specifications

  • Browser: Chrome 66.0.3359.139 or Safari 11.1.2
  • Version: either 2.5.1 or 2.6.2

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
j0u135commented, Jun 6, 2018

I have the same error usnig fabric.js, Chrome 67. Firefox does not present this problem.

1reaction
orifncommented, Nov 13, 2018

@thedustinsmith, console logs also show 0 for elements height and width at L1133 and L1172. Btw, I also have checked it with latest Chrome version (66.0.3359.181) and can confirm @lacek’s comment regarding error occurence in newest Chrome.

Update: 13.11.2018 The same applies to Chrome 70.0.3538.102 Update: 25.09.2018 The same applies to Chrome 69.0.3497.100 and Safari 12.0 (13606.2.11) Update: 02.08.2018 The same applies to Chrome 68.0.3440.84 and Safari 11.1.2 Update: 13.07.2018 The same applies to Chrome 67.0.3396.99 Update: 19.06.2018 The same applies to Chrome 67.0.3396.87 Update: 04.06.2018 The same applies to Chrome 67.0.3396.62

Read more comments on GitHub >

github_iconTop Results From Across the Web

CanvasRenderingContext2D.drawImage() - Web APIs | MDN
The CanvasRenderingContext2D.drawImage() method of the Canvas 2D API provides different ways to draw an image onto the canvas.
Read more >
Cropping with drawImage not working in Safari - Stack Overflow
The bug occurs when drawImage() is called out of the bounds of the sourceImage. You have to double check that the source width...
Read more >
Draw an image from Uploadcare on HTML Canvas - FAQ
One of the solutions is using the crossOrigin image property to ask the browser to request the image in a safe way. Live...
Read more >
755366 - Canvas .drawImage not drawing images that haven't ...
Draw this image element to a canvas with `.getContext('2d'). ... works in Chrome 56. Broken in Firefox 54, Edge 15 and Safari 10.1....
Read more >
Canvas Element - HTML Standard - whatwg
typedef ( CanvasRenderingContext2D or ImageBitmapRenderingContext or ... Draw a straight line to the point ( x + w , y + h −...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found