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

loading single frame gif cause JavaScript engine to hang #3

Open
lain-d opened this issue Nov 12, 2018 · 2 comments
Open

loading single frame gif cause JavaScript engine to hang #3

lain-d opened this issue Nov 12, 2018 · 2 comments

Comments

@lain-d
Copy link

lain-d commented Nov 12, 2018

Loading a single frame gif causes the page to become completely unresponsive and for it to crash

@zzuzsj
Copy link

zzuzsj commented Aug 26, 2021

image

@raihara3
Copy link

I had the same problem.
So I made changes to the library.
Download "gifler.bundle.js" and make the following changes will improve the situation.

Gif.prototype.animate = function(selector) {
  var canvas;
  canvas = Gif.getCanvasElement(selector);
  return this._animatorPromise.then(function(animator) {
    // add from here ----->
    if(animator._frames.length === 1) {
      var frame = animator._frames[0]
      var imageData = new ImageData(frame.pixels, frame.width, frame.height);
      canvas.width = frame.width;
      canvas.height = frame.height;
      ctx = canvas.getContext('2d');
      ctx.putImageData(imageData, 0, 0);
      return
    }
    // <-----
    return animator.animateInCanvas(canvas);
  });
};

Gif.prototype.frames as well, if necessary.

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

3 participants