i used glfx.js to add some effects on canvas. I created a button that changes the canvas and sometimes i get the error "Error: uncaught exception: compile error:". I got more details thanks to JavaScript global error handling.
I assigned the window.onerror event to an event handler and i got :
Error: uncaught exception: compile error: url: line: 0
error: compile error:
How can i resolve that error ?
code :
function createContrastCanvas( imgEffect, canvasSent, p, A, x ) {
$( ".loaderImgEffects" ).fadeIn();
var base64 = canvasSent.toDataURL( "image/jpeg" );
var image = new Image();
image.setAttribute( "id", "contrast_image");
image.addEventListener( "load", function() {
console.log(2);
document.body.appendChild( image );
try {
var canvas = fx.canvas();
canvas.setAttribute( "id", "dialog_canvas" );
console.log(3);
} catch (e) {
alert(e);
return;
}
// convert the image to a texture
var contrastImage = document.getElementById( 'contrast_image' );
var texture = canvas.texture( contrastImage );
console.log( 4 );
switch( imgEffect ) {
case "contrast":
console.log(5);
canvas.draw(texture).brightnessContrast(0.1, 0.24).update();
//contrastBase64[0] = canvas.toDataURL( "image/jpeg" );
contrastBase64[0] = image;
break;
case "hue":
console.log(5);
canvas.draw(texture).hueSaturation( 0, 0.39 ).update();
//hueBase64[0] = canvas.toDataURL( "image/jpeg" );
hueBase64[0] = image;
break;
/*case "denoise":
canvas.draw(texture).unsharpMask(20, 0.45).update();
break;*/
}
console.log(6);
// replace the image with the canvas
$( "#dialog_canvas" ).parent().html( canvas );
$( ".loaderImgEffects" ).fadeOut();
//activeAllEvents( canvas, p, A, x );
//document.getElementById( "dialog_canvas" ).parentNode.removeChild( contrastImage );
} )
image.src = base64;
}