ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 753 forks source link

New chrome issue - Failed to execute 'drawImage' on 'CanvasRenderingContext2D' #1078

Closed songoo closed 5 years ago

songoo commented 5 years ago

Hi folks, some projects still kicking on Kinetic :)

Somehow just lately in newest chrome we started to get some strange errors. (For other browsers is still ok)

Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.
    at Kinetic.SceneContext.drawImage
        drawImage: function() {
            var a = arguments,
                _context = this._context;

            if(a.length === 3) {
                _context.drawImage(a[0], a[1], a[2]);
            }
            else if(a.length === 5) {
                _context.drawImage(a[0], a[1], a[2], a[3], a[4]); /*error marked in here*/
            }

Any idea welcomed :)

songoo commented 5 years ago

After some update of chrome, special symbols are not allowed in "url" , so for example if SVG code is put in src and it contains # or other symbols it fails.

Using - encodeURIComponent helps with this.

url = "data:image/svg+xml," + encodeURIComponent(svgContent)