javascript - How to test if Canvas.toBlob() failed -


using canvas.toblob(callback, ...), converting several large canvas elements (2048x2048 pixels) png.

however, @ least in chrome, callback not called. there no errors generated in chrome devtools.

my questions:

  1. is there way check if toblob() failed, aside timing out after x seconds?
  2. under conditions toblob() fail? how know condition not met / how error message?

the code using:

function trigger_browser_download(blob, filename) { "use strict";     var url = window.url.createobjecturl(blob);     a.href = url;     a.download = filename;     a.click();     window.url.revokeobjecturl(url); };  function download_canvas(canvas, filename) { "use strict";     canvas.toblob(function(blob) {         debugger; // not reached         if(blob instanceof blob) {             trigger_browser_download(blob, filename);         } else {             console.error("error generating blob");         }     }, 'application/octet-binary');  }  for(var = 0; < 10; ++i) {     var canvas = document.createelement('canvas');     canvas.height = 2048;     canvas.width = 2048;     download_canvas(canvas, + ".png");  } 


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -