News for hackers. Stuff that matters.
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by JKCalhoun on Friday May 21, 2021 @02:29AM (#27231107)
My first thought was that each "frame" of the GIF is being expanded/rendered to its own backingstore.

GIFs are pretty optimized files — where each "frame" can be a diff from the previous. "De-diffing", converting palette-based pixels to full 24 or 32-bit RGB could really blow up fast.

Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by okamiueru on Friday May 21, 2021 @02:39AM (#27231168)
From a codec perspective gifs would be the first thing that came to mind for a poorly optimized format. The only thing it has going for it is simplicity. This is a bit besides the point you're making, but I did a double take at seeing the words "gif" and "pretty optimized" together. I'm also curious as to what this has to do with M1 in particular. Looks to be like a memory allocation issue in the decoder library. But hard to tell given the amount of information given. Memory leaks tend to be boundless, but increasing, so the op statement of a fixed memory usage kinda sounds more like poorly optimized allocations, rather than non-properly-cleared up allocations. Though, could also be a mix of everything.
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by eduo on Friday May 21, 2021 @03:32AM (#27231422)
"Optimized" in this sense meant that animated gifs can have a frame reference only three pixels of the original image. So an image of 300K with only small movement (think cinemagraphs) wouldn't be much larger.

This is a given for movie formats, but at the time the animated GIF came up it was revolutionary. I think the proper phrase should be "animated GIFs can be pretty optimized, taking into account how inefficient the algorithm is, when compared with other animation algorithms of the time".

I also think there's an interpretation that applies here: When you see an animated gif, even if it's a frame that changes three pixels and nothing else, internally the renderer may be expanding it into a full movie (that is, uncompressing each resulting "frame"). This usually makes GIFs (regardless of how large or small the GIF actually is) take much more memory than common sense would tell you.

Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by TomSwirly on Friday May 21, 2021 @06:00AM (#27232184)
That's "compressed," not "optimized".
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by TazeTSchnitzel on Friday May 21, 2021 @07:31AM (#27232717)
GIF also uses a normal compression algorithm so saying “compressed” about frame deltas is unhelpful.
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by machello13 on Friday May 21, 2021 @09:23AM (#27233665)
Isn't that just... optimizing for space?
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by galangalalgol on Friday May 21, 2021 @07:38AM (#27232765)
For an image codec I think of those as the same thing. What do you mean by optimized besides compression?
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by klodolph on Friday May 21, 2021 @05:06AM (#27231884)
If you do the math, 730 frames x 400x240 pixels x 32bpp, you get only 280 MB.
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by nyanpasu64 on Friday May 21, 2021 @02:53PM (#27238306)
That's exactly what happened to Firefox WebRender a year ago. I even managed to pick out the raw image frames in a memory dump of the process: https://bugzilla.mozilla.org/show_bug.cgi?id=1627739
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by pkulak on Friday May 21, 2021 @10:47AM (#27234681)
I'm pretty sure animated gifs only support intra frames.
Re:Animated GIF uses over 35GB RAM in Acorn on M1 Mac, likel... by efreak on Sunday May 23, 2021 @02:05PM (#27257116)
Looking this up led me to some interesting unrelated facts about gif animation:

1. animation isn't technically intended by the gif format [0]:

> Although GIF was not designed as an animation medium, its ability to store multiple images in one file naturally suggested using the format to store the frames of an animation sequence. To facilitate displaying animations, the GIF89a spec added the Graphic Control Extension (GCE), which allows the images (frames) in the file to be painted with time delays, forming a video clip > > To enable an animation to loop, Netscape in the 1990s used the Application Extension block (intended to allow vendors to add application-specific information to the GIF file) to implement the Netscape Application Block (NAB).........Most browsers now recognize and support NAB, though it is not strictly part of the GIF89a specification

2. SMIL[1] is an animation alternative I'd never heard of for the browser.

[0]: https://en.wikipedia.org/wiki/GIF#Animated_GIF [1]: https://en.wikipedia.org/wiki/Synchronized_Multimedia_Integr...