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

Jeremy Wood jwood at openjdk.org
Thu Nov 6 04:23:50 UTC 2025


> 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.
> 
> There are a cluster of four related PRs that share the GifComparison class in this PR.
> 
> 1. ~~[8357034](https://github.com/openjdk/jdk/pull/25264)~~ (integrated)
> 2. ~~[8356137](https://github.com/openjdk/jdk/pull/25044)~~ (integrated)
> 3. [8356320](https://github.com/openjdk/jdk/pull/25076)
> 4. [8351913](https://github.com/openjdk/jdk/pull/24271) (this one)
> 
> This bug can be observed reading these gif animations:
> https://pixabay.com/gifs/pattern-mandela-geometric-loading-20162/
> https://pixabay.com/gifs/colourful-paint-spiral-pattern-20276/
> https://pixabay.com/gifs/dance-party-dancer-dancing-girl-19993/
> https://pixabay.com/gifs/spiral-orbit-colourful-pattern-20278/
> https://pixabay.com/gifs/flower-smiley-happy-yellow-bright-11997/
> https://pixabay.com/gifs/ghost-spooky-halloween-horror-20223/
> https://pixabay.com/gifs/fish-tadpole-sperm-decorative-20078/
> https://pixabay.com/gifs/cat-kitten-black-cats-sleep-nap-20104/
> https://giphy.com/gifs/party-gzhreEYEFrEYw
> https://giphy.com/gifs/hello-happy-birthday-all-xRVUlSCqTTZRLMdUiC
> https://giphy.com/gifs/GpANv0ZGOo973DNPyg
> https://giphy.com/gifs/pinatafarmsapp-birthday-happy-pinata-farms-rrmf3fICPZWg1MMXOW
> https://pixabay.com/gifs/stars-twinkle-sky-universe-cosmos-13910/
> https://pixabay.com/gifs/laundry-washing-clean-clothes-18875/
> https://giphy.com/gifs/cat-white-mikitti-VItynXR1BzF5z0aTM7
> https://giphy.com/gifs/love-good-morning-cute-sTuKV3kHCkuc1hzd5C
> https://giphy.com/gifs/tv2norge-dance-celebration-birthday-duNowzaVje6Di3hnOu
> https://tenor.com/view/hasher-sticker-gif-24531859
> https://giphy.com/gifs/animanias-emoji-mickey-mouse-minnie-BeiTtDrExJZsoHzglJ
> https://giphy.com/gifs/morning-good-gm-dvwk9tqWYN8Wn2s4yn
> https://giphy.com/gifs/memoriachilena-familia-memoria-chilena-patrimonio-cultural-comn-7rRmOg13aXImUOEhO7
> https://giphy.co...

Jeremy Wood has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 36 commits:

 - 8351913: resolving compiler error introduced with latest merge
   
   In other related tickets: we added a directory in which we can write the gif frames to visually inspect each frame.
 - Merge branch 'master' into JDK-8351913
 - Merge branch 'master' into JDK-8351913
 - 8351913: re-wrapping line breaks
 - Merge branch 'master' into JDK-8351913
   
   # Conflicts:
   #	test/jdk/sun/awt/image/gif/GifComparison.java
 - Merge branch 'master' into JDK-8351913
 - 8356137: Adding copyright to GifComparison
 - 8356320: trivial whitespace and comment changes
 - Merge branch 'master' into JDK-8351913
 - Merge branch 'master' of https://github.com/mickleness/jdk
 - ... and 26 more: https://git.openjdk.org/jdk/compare/acc8a76d...c3f78a51

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

Changes: https://git.openjdk.org/jdk/pull/24271/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24271&range=08
  Stats: 61 lines in 4 files changed: 55 ins; 0 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/24271.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24271/head:pull/24271

PR: https://git.openjdk.org/jdk/pull/24271


More information about the client-libs-dev mailing list