On Thu, 12 Nov 2026 22:07:08 GMT, Phil Race <[email protected]> wrote:

>> If a GIF image contains one frame and the loop count isn't set to 1, it is 
>> still animated.
>> 
>> The GIF decoder starts the animation thread that decodes the single frame 
>> over and over again. The image itself looks static, but decoding consumes 
>> CPU and memory.
>> 
>> The proposed fix stops animating the image if it contains one frame only.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java line 241:
> 
>> 239:     }
>> 240: 
>> 241:     /**
> 
> This isn't "wrong" and it is an internal method .. but the description 
> perhaps could be clearer that it is required that this be called ONLY from an 
> animation thread .. not that it goes off and some how finds an animator 
> thread to stop.
> 
> And you could just have made the existing private method package visible.

My idea was to follow the style of `startingAnimation` that promotes the 
current thread from fetchers to animators. Similarly, `stoppingAnimation` does 
the opposite.

https://github.com/openjdk/jdk/blob/968660485c667f9841a30a63279f3d34e841d92a/src/java.desktop/share/classes/sun/awt/image/GifImageDecoder.java#L197-L200

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33701#discussion_r4591252524

Reply via email to