Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't work with jpeg datauri on iOS 9 #130

Open
littlee opened this issue Feb 3, 2021 · 1 comment
Open

doesn't work with jpeg datauri on iOS 9 #130

littlee opened this issue Feb 3, 2021 · 1 comment

Comments

@littlee
Copy link

littlee commented Feb 3, 2021

const imgUrl = `data:image/jpg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAA7aADAAQAAAABAAAAcAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgAcADtAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+j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KKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP//T9DooooAKKKM45NABnHJrEuLuW5lFvZnvyw/z0pLq6ku5PstryD1Pr/8AWrStbVLVNo5Y9TQBYUMFAc5OOTTqKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//1PQ6KKKACobiIzwtEGK57ipqKAMCylFlM1vcKFyfvf57Vv1Uu7RLpMHhh0NULO7eB/sl1xjgE9v/AK1AG1RRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//1fQ6KKKACiiigAqpdWcd0Bu4I7j0q3RQA1VCKEHQDFOoooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//2Q==`

loadImage(imgUrl,img => {
    document.body.appendChild(img);
  },
  {
    maxWidth: 750,
    orientation: true,
    canvas: true
  })

the code above will throw a network error on iOS 9

XMLHttpRequest Exception 101: A network error occurred in synchronous requests

my temporary solution is replacing loadImage.fetchBlob with the function below

loadImage.fetchBlob = function (url, callback, options) {
  function executor(resolve, reject) {
    var img = new Image();
    img.src = url;
    img.onload = function () {
      var c = document.createElement('canvas');
      c.width = img.width;
      c.height = img.height;
      var ctx = c.getContext('2d');
      ctx.drawImage(img, 0, 0);
      c.toBlob(bin => {
        resolve(bin);
      });
    };
    img.onerror = function() {
      reject(Error('load image fail'))
    }
  }
  if (global.Promise && typeof callback !== 'function') {
    options = callback; // eslint-disable-line no-param-reassign
    return new Promise(executor);
  }
  return executor(callback, callback);
};
@blueimp
Copy link
Owner

blueimp commented Sep 25, 2021

Thanks for your report @littlee.
Unfortunately I don't have a access to a iOS 9 test device (and it seems simulator runtimes are only available down to iOS 11 for me).
Is this issue limited to iOS9 or does it also occur in other versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants