<AWT Dev> [11][JDK-8152974] AWT hang occurs when sequenced events

Krishna Addepalli krishna.addepalli at oracle.com
Fri Feb 16 08:42:06 UTC 2018


Hi Sergey,

Here is my understanding:
When a SequencedEvent, detects that it is not the first event in the list, it tries to dispatch events to ensure that the event that is before it gets processed first. All SequencedEvents are created with the ID - "java.awt.event.FocusEvent.FOCUS_LAST + 1".
Now, when it tries to dispatch, it calls the pumpEvents as below:
                     edt.pumpEvents(SentEvent.ID, new Conditional() {
                             public boolean evaluate() {
                                 return !SequencedEvent.this.isFirstOrDisposed();
                             }
                         });

The SentEvent.ID value is "java.awt.event.FocusEvent.FOCUS_LAST+2", and when in the function pumpOneEventForFilters, it tries to call EventQueue.getNextEvent(id), it looks for SentEvent.ID, which is not present, and then the queue blocks in the hope that someone will post that event. This is what is leading to the hang.
Ideally, the code should have pumped events, with its own id, since all the sequenced events are created with that id. When I made this change and tested, it did not hang.
However, if sequenced events are not posted immediately one after the other, even this would fail, since it would expect that the next event that is scheduled should be of SequencedEvent type. 

I have removed the "id" parameter in pumpEvents, which effectively means to process all events till the current SequencedEvent becomes the first one in the list, at which point, it would process itself.

@Semyon,

I don't think the problem is with multiple AppContexts. I have modified the test case to create a second AppContext, and post few events in that context. In that case, even Java8 was able to run to completion without any problems.
Attached the test case for your reference. 
Let me know if there is a problem with the testcase, or we can exercise the multiple AppContexts in a better way.

Thanks,
Krishna

Message: 3
Date: Thu, 15 Feb 2018 14:30:03 -0800
From: Sergey Bylokhov <Sergey.Bylokhov at oracle.com>
To: awt-dev at openjdk.java.net
Subject: Re: <AWT Dev> [11][JDK-8152974] AWT hang occurs when
	sequenced events arrive out of sequence
Message-ID: <908bf597-c40c-977e-cde4-258c39bbf27c at oracle.com>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hi, Krishna.
Can you please provide more details why the test hang, it post two SequencedEvents out of order, the first waits when the second will be dispatched, why it hangs forever?

On 15/02/2018 04:16, Krishna Addepalli wrote:
> Hi All,
> 
> Please review a fix for ?JDK-8152974: 
> https://bugs.openjdk.java.net/browse/JDK-8152974
> 
> Webrev: http://cr.openjdk.java.net/~kaddepalli/8152974/webrev00/
> 
> The problem is when the events arrive out of sequence, the sequenced 
> event?s dispatch loop assumes that the sequenced events are pushed 
> into the queue together, which may not be the case, and this blocks 
> the event queue. The fix is to continue to process all the events, 
> which ultimately leads to the processing of the SequencedEvents in 
> their order of creation.
> 
> Thanks,
> 
> Krishna
> 


--
Best regards, Sergey.


Message: 5
Date: Thu, 15 Feb 2018 18:09:11 -0800
From: Semyon Sadetsky <semyon.sadetsky at oracle.com>
To: Krishna Addepalli <krishna.addepalli at oracle.com>,
	awt-dev at openjdk.java.net
Subject: Re: <AWT Dev> [11][JDK-8152974] AWT hang occurs when
	sequenced events arrive out of sequence
Message-ID: <32533ac8-0007-668f-f691-fab84a8fac84 at oracle.com>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"

Hi Krishna,

Unlikely this will work for several app contexts.

You need to find the root cause why the sequenced events get mixed up 
and fix it.

--Semyon


On 02/15/2018 04:16 AM, Krishna Addepalli wrote:
>
> Hi All,
>
> Please review a fix for ?JDK-8152974: 
> https://bugs.openjdk.java.net/browse/JDK-8152974
>
> Webrev: http://cr.openjdk.java.net/~kaddepalli/8152974/webrev00/ 
> <http://cr.openjdk.java.net/%7Ekaddepalli/8152974/webrev00/>
>
> The problem is when the events arrive out of sequence, the sequenced 
> event?s dispatch loop assumes that the sequenced events are pushed 
> into the queue together, which may not be the case, and this blocks 
> the event queue. The fix is to continue to process all the events, 
> which ultimately leads to the processing of the SequencedEvents in 
> their order of creation.
>
> Thanks,
>
> Krishna
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20180215/a3b04c00/attachment.html>

End of awt-dev Digest, Vol 130, Issue 11
****************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SequencedEventTest.java
Type: application/octet-stream
Size: 6379 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20180216/6bb54aa6/SequencedEventTest-0001.java>


More information about the awt-dev mailing list