RFR: 8356137: GifImageDecode can produce opaque image when disposal method changes [v11]
Phil Race
prr at openjdk.org
Thu Jul 10 21:44:43 UTC 2025
On Wed, 9 Jul 2025 20:54:23 GMT, Jeremy Wood <duke at openjdk.org> wrote:
>> This resolves a gif parsing bug where an unwanted opaque rectangle could appear under these conditions:
>>
>> 1. The disposal method for frames is 1 (meaning "do not dispose", aka "DISPOSAL_SAVE")
>> 2. The transparent pixel is non-zero
>> 3. There's more than one such consecutive frame
>>
>> Previously: the GifImageDecoder would leave the saved_image pixels as zero when they were supposed to be transparent. This works great if the transparent pixel index is zero, but it flood fills the background of your frame with the zeroeth color otherwise.
>>
>> I wrote four PRs that share the GifComparison class in this PR. Once any of them clear code review the other PRs will be much simpler:
>>
>> 1. [8357034](https://github.com/openjdk/jdk/pull/25264)
>> 2. [8356137](https://github.com/openjdk/jdk/pull/25044) (this one)
>> 3. [8356320](https://github.com/openjdk/jdk/pull/25076)
>> 4. [8351913](https://github.com/openjdk/jdk/pull/24271)
>>
>> This bug can be observed reading these gif animations:
>>
>> https://pixabay.com/gifs/cat-kitten-black-cats-pet-animal-20315/
>> https://free-gifs.org/gif/CC0-3D
>
> Jeremy Wood has updated the pull request incrementally with two additional commits since the last revision:
>
> - Merge remote-tracking branch 'origin/JDK-8356137' into JDK-8356137
> - 8356137: rewrapping line breaks so text is < 80 chars
>
> This is in response to:
> https://github.com/openjdk/jdk/pull/25044#issuecomment-3051978321
LGTM.
Might get the award for "best original test".
I did modify the test to dump the frames being generated and the accumulated image, just so I could see.
Maybe you could add such a feature as a debugging option in one of the follow-on PRs.
-------------
Marked as reviewed by prr (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/25044#pullrequestreview-3007487527
More information about the client-libs-dev
mailing list