RFR: 6176679: Application freezes when copying an animated gif image to the system clipboard [v8]

Alexey Ivanov aivanov at openjdk.org
Thu Apr 20 19:15:49 UTC 2023


On Wed, 19 Apr 2023 20:26:54 GMT, Rajat Mahajan <rmahajan at openjdk.org> wrote:

>> **Problem:**
>> 
>> On pressing the Copy button we keep waiting in AWT-EventQueue thread in reconstruct() function as we detect that we have missing information for the animated image since we are copying single frame at a time.
>> Due to this infinite wait the application freezes.
>> 
>> **Proposed Fix:**
>> 
>> There are conditions in the reconstruct() function that avoid entering the wait() code if we have some error reading the image , etc. So, I added the condition to avoid entering the wait() code if we are copying single frame at a time. This sounded logical to me since if we have incomplete information(single frame) about the animated image we shouldn’t keep waiting, as it leads to infinite wait. 
>> After this change I see the GIF image being correctly copied and animated.
>> 
>> 
>> **Testing:**
>> 
>> Added a test for this (bug6176679.java) and tested locally on my Windows machine and on mach5.
>
> Rajat Mahajan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   code cleanup

Changes requested by aivanov (Reviewer).

test/jdk/java/awt/Clipboard/CopyAnimatedGIFTest.java line 98:

> 96:         sys.setContents(new MyTransferable(img), null);
> 97: 
> 98:     }

Suggestion:

    private void copyImage() {
        Clipboard sys = Toolkit.getDefaultToolkit().getSystemClipboard();
        sys.setContents(new MyTransferable(img), null);
    }

Let's remove unnecessary blank line.

test/jdk/java/awt/Clipboard/CopyAnimatedGIFTest.java line 132:

> 130:         }
> 131:     }
> 132:     private static class MyTransferable implements Transferable {

Suggestion:

    }

    private static class MyTransferable implements Transferable {

A blank line between class declarations.

test/jdk/java/awt/Clipboard/CopyAnimatedGIFTest.java line 161:

> 159: 
> 160: }
> 161: 

Suggestion:

}

Now there are two blank lines in the end of the file for some reason. The thing is, GitHub and `git diff` don't usually show the blank line in the end of the file.

It's not too important, however, it may create noise when someone else updates the file and IDE removes the extra blank lines or adds ones if it's missing.

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

PR Review: https://git.openjdk.org/jdk/pull/13414#pullrequestreview-1394606699
PR Review Comment: https://git.openjdk.org/jdk/pull/13414#discussion_r1172987332
PR Review Comment: https://git.openjdk.org/jdk/pull/13414#discussion_r1172987735
PR Review Comment: https://git.openjdk.org/jdk/pull/13414#discussion_r1172990156



More information about the client-libs-dev mailing list