RFR: 8351913: ToolkitImage renders some gifs wrong [v4]

Jeremy Wood duke at openjdk.org
Sat May 10 19:01:59 UTC 2025


On Wed, 7 May 2025 03:08:00 GMT, Jeremy Wood <duke at openjdk.org> wrote:

>> I do not have much background in LZW compression or in C, but I'm reasonably confident this resolves the problem I'm observing. It looks like the GifImageDecoder was not always correctly handling compression codes after the table reached its limit of ~4096. If anyone has suggestions for improvements I'm happy to make adjustments.
>> 
>> Luckily while debugging this: I was able to compare the flawed implementation (GifImageDecoder) with ImageIO's implementation (GIFImageReader) to help identify how the suffix/prefix tables are supposed to work.
>> 
>> ImageIO's implementation may have suffered a similar bug (maybe https://bugs.openjdk.org/browse/JDK-7131823 ?), and that appears to have been backported.
>> 
>> I have dozens of additional test cases for this problem, but unfortunately I don't have the rights to commit them to the OpenJDK repo. Feel free to email me for additional context/test cases.
>
> Jeremy Wood has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8351913: moving test package
>   
>   I have two other PRs in progress that place their tests in a dir like:
>   /jdk/test/jdk/sun/awt/image/gif/bug8351913/
>   
>   They aren't approved/merged yet, but hopefully all 3 of these new gif bugs will be merged and they'll benefit from being grouped in the same new gif directory. (And maybe more will test/directories will follow.)

I'm closing this for now; it turns out this is not ready for review yet.

[This gif](https://pixabay.com/gifs/ginger-gingerbread-man-cookies-9997/) is much improved with this PR, but frame 12 still has issues:

According to the app Preview, it should resemble:
![image](https://github.com/user-attachments/assets/23a4e1c7-9be5-4956-ae17-039200360e59)

But with this PR it currently resembles (see bottom of image):
![frame-12](https://github.com/user-attachments/assets/2b13b306-447f-4410-9a9a-38b3697c784b)

I'm 90% sure these weird artifacts are related to this ticket.

Before this PR several frames get mangled, and frame 12 resembled: 
![frame-12](https://github.com/user-attachments/assets/5dc57af8-9d47-46f0-bca6-fe235317dc2a)

(As before: if anyone feels confident in this subject matter and has any extra capacity I'd appreciate some help, but so far with enough time I've been able to make progress on these issues...)

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

PR Comment: https://git.openjdk.org/jdk/pull/24271#issuecomment-2869111725


More information about the client-libs-dev mailing list