<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi Martin,</div><div><br></div><div>Sorry to tell you that your patch does not fix the reproducer test I made (see at the end).</div><div>It is expected that 2 windows have their corresponding buttons "TEST <num>" animated: <num> is incrementing, showing events are properly propagated among windows (2 AppContexts).<br></div><div><br></div><div>I added few logs in the SequencedEventFilter (accept ids) and reject, and it seems SequencedEvent are still blocking the EDT queues (sort of deadlock):</div><div><span style="font-family:monospace,monospace">SequencedEventsFilter.acceptEvent: reject id = 1200<br>SequencedEventsFilter.acceptEvent: id = 1006<br>SequencedEventsFilter.acceptEvent: id = 1006<br>SequencedEventsFilter.acceptEvent: id = 1006<br>SequencedEventsFilter.acceptEvent: id = 1007<br>SequencedEventsFilter.acceptEvent: reject id = 1200<br>SequencedEventsFilter.acceptEvent: id = 1007<br>SequencedEventsFilter.acceptEvent: id = 1007<br>SequencedEventsFilter.acceptEvent: id = 1007<br>SequencedEventsFilter.acceptEvent: reject id = 800<br>SequencedEventsFilter.acceptEvent: id = 1007<br>SequencedEventsFilter.acceptEvent: reject id = 800<br>SequencedEventsFilter.acceptEvent: reject id = 1200<br>SequencedEventsFilter.acceptEvent: id = 1006<br></span>...<br></div><div><br></div><div>My modified patch:<br></div><div><span style="font-family:monospace,monospace">--- a/src/java.desktop/share/classes/java/awt/SequencedEvent.java       Wed Oct 10 16:20:52 2018 +0530<br>+++ b/src/java.desktop/share/classes/java/awt/SequencedEvent.java       Wed Oct 10 21:15:26 2018 +0200<br>@@ -81,6 +81,20 @@<br>         });<br>     }<br> <br>+    private static final class SequencedEventsFilter implements EventFilter {<br>+        private static final SequencedEventsFilter INSTANCE = new SequencedEventsFilter();<br>+        @Override<br>+        public FilterAction acceptEvent(AWTEvent ev) {<br>+            final int eventID = ev.getID();<br>+            if (eventID == ID || eventID == SentEvent.ID) {<br>+System.out.println("SequencedEventsFilter.acceptEvent: id = "+eventID);<br>+                return FilterAction.ACCEPT;<br>+            }<br>+System.out.println("SequencedEventsFilter.acceptEvent: reject id = "+eventID);<br>+            return FilterAction.REJECT;<br>+        }<br>+    }<br>+<br>     /**<br>      * Constructs a new SequencedEvent which will dispatch the specified<br>      * nested event.<br>@@ -135,7 +149,8 @@<br>                     if (Thread.currentThread() instanceof EventDispatchThread) {<br>                         EventDispatchThread edt = (EventDispatchThread)<br>                                 Thread.currentThread();<br>-                        edt.pumpEvents(ID, () -> !SequencedEvent.this.isFirstOrDisposed());<br>+                        edt.pumpEventsForFilter(() -> !SequencedEvent.this.isFirstOrDisposed(),<br>+                                SequencedEventsFilter.INSTANCE);<br>                     } else {<br>                         if (fxAppThreadIsDispatchThread) {<br>                             fxCheckSequenceThread.start();<br></span></div><div><br></div><div>Kind Regards,</div><div>Laurent<br></div><div><br></div><div>PS: the reproducer TestWinEvent class:</div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">import java.awt.AWTEvent;<br>import java.awt.BorderLayout;<br>import java.awt.Dimension;<br>import java.awt.Toolkit;<br>import java.awt.event.ActionEvent;<br>import java.awt.event.ActionListener;<br>import java.awt.event.WindowEvent;<br>import java.lang.reflect.Constructor;<br>import javax.swing.JButton;<br><br>import javax.swing.JFrame;<br>import javax.swing.JLabel;<br>import javax.swing.SwingUtilities;<br>import javax.swing.Timer;<br>import sun.awt.AppContext;<br>import sun.awt.SunToolkit;<br><br>/*<br> * Running this code causes the AWT Event Queues to be blocked on OpenJDK11<br> * @author Laurent Bourges<br> */<br>public class TestWinEvent extends JFrame implements ActionListener {<br><br>    private static final long serialVersionUID = 1L;<br><br>    private int counter = 0;<br>    private JButton btn;<br><br>    public static void main(String[] args) {<br>        createWin(1);<br>        createWin(2);<br>    }<br><br>    private static void createWin(int tgNum) {<br>        ThreadGroup tg = new ThreadGroup("TG " + tgNum);<br><br>        Thread t = new Thread(tg, new Runnable() {<br>            public void run() {<br>                AppContext context = SunToolkit.createNewAppContext();<br><br>                SwingUtilities.invokeLater(new Runnable() {<br>                    public void run() {<br>                        final TestWinEvent window = new TestWinEvent(tgNum);<br>                        window.setVisible(true);<br><br>                        new Timer(10, window).start();<br>                    }<br>                });<br>            }<br>        });<br>        t.start();<br>    }<br><br>    public TestWinEvent(final int num) {<br>        super("Test Window + " + num);<br>        setMinimumSize(new Dimension(300, 200));<br>        setLocation(100 + 400 * (num - 1), 100);<br><br>        setLayout(new BorderLayout());<br>        JLabel textBlock = new JLabel("Lorem ipsum dolor sit amet...");<br>        add(textBlock);<br><br>        btn = new JButton("TEST");<br>        btn.addActionListener(new ActionListener() {<br>            @Override<br>            public void actionPerformed(ActionEvent e) {<br>                System.out.println("Button#" + num + " clicked: " + counter);<br>            }<br><br>        });<br>        add(btn, BorderLayout.SOUTH);<br><br>        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br>        pack();<br>    }<br><br>    @Override<br>    public void actionPerformed(ActionEvent e) {<br>        AWTEvent eventOne = getSequencedEvent(WindowEvent.WINDOW_GAINED_FOCUS);<br>        AWTEvent eventTwo = getSequencedEvent(WindowEvent.WINDOW_LOST_FOCUS);<br><br>        btn.setText("TEST " + (counter++));<br><br>        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(eventOne);<br>        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(eventTwo);<br>    }<br><br>    private AWTEvent getSequencedEvent(int id) {<br>        AWTEvent wrapMe = new WindowEvent(this, id);<br>        try {<br>            @SuppressWarnings("unchecked")<br>            Class<? extends AWTEvent> seqClass = (Class<? extends AWTEvent>) Class.forName("java.awt.SequencedEvent");<br>            Constructor<? extends AWTEvent> seqConst = seqClass.getConstructor(AWTEvent.class);<br>            seqConst.setAccessible(true);<br>            AWTEvent instance = seqConst.newInstance(wrapMe);<br>            return instance;<br>        } catch (Throwable err) {<br>            throw new Error("Unable to instantiate SequencedEvent", err);<br>        }<br>    }<br>}</span><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">Le mer. 10 oct. 2018 à 20:57, Laurent Bourgès <<a href="mailto:bourges.laurent@gmail.com">bourges.laurent@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Martin,<div dir="auto"><br><div dir="auto">I am not a reviewer, but I will test your fix with the reproducer test I wrote for this bug. <span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">Did you try it ? I will do asap.<br></span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div><span style="font-family:sans-serif">You should use a single instance for your SequencedEventFilter and make this class final:</span></div><div><span style="font-family:sans-serif">    private static final class SequencedEventsFilter implements EventFilter {<br></span></div><div><span style="font-family:sans-serif"><span style="font-family:sans-serif">+     private static <span style="font-family:sans-serif"><span style="font-family:sans-serif">final </span></span>SequencedEventsFilter INSTANCE = new <span style="font-family:sans-serif">SequencedEventsFilter();</span></span></span></div><div><span style="font-family:sans-serif"></span></div><div><span style="font-family:sans-serif"></span></div><div><span style="font-family:sans-serif">Then</span></div><div><span style="font-family:sans-serif">                        edt.pumpEventsForFilter(() -> !SequencedEvent.this.isFirstOrDisposed(),<br>+                                new SequencedEventsFilter());<br>=> <span style="font-family:sans-serif">                            SequencedEventsFilter.<span style="font-family:sans-serif"><span style="font-family:sans-serif">INSTANCE</span></span>);<br></span></span></div><br><div dir="auto">I noticed your patch do not provide any test... yet ?</div><div>I think it is needed here.<br></div><div dir="auto"><br></div><div dir="auto">Good job for your detailed analysis and the webrev.</div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto">Laurent</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">Le mer. 10 oct. 2018 à 18:19, Martin Balao <<a href="mailto:mbalao@redhat.com" target="_blank">mbalao@redhat.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div>Can I have a review for JDK-8204142 [1] Webrev 00?</div><div><br></div><div> * <a href="http://cr.openjdk.java.net/~mbalao/webrevs/8204142/8204142.webrev.00/" target="_blank">http://cr.openjdk.java.net/~mbalao/webrevs/8204142/8204142.webrev.00/</a></div><div> * <a href="http://cr.openjdk.java.net/~mbalao/webrevs/8204142/8204142.webrev.00.zip" target="_blank">http://cr.openjdk.java.net/~mbalao/webrevs/8204142/8204142.webrev.00.zip</a></div><div><br></div><div>As a result of [2], I propose Event Dispatch Threads to be aware of SentEvent AWT events when sleeping.</div><div><br></div><div>In the tests I did, the SequencedEvent.list is successfully flushed with this patch.</div><div><br></div><div>Thanks,</div><div>Martin.-</div><div><br></div><div>--</div><div>[1] - <a href="https://bugs.openjdk.java.net/browse/JDK-8204142" target="_blank">https://bugs.openjdk.java.net/browse/JDK-8204142</a></div><div>[2] - <a href="http://mail.openjdk.java.net/pipermail/awt-dev/2018-October/014426.html" target="_blank">http://mail.openjdk.java.net/pipermail/awt-dev/2018-October/014426.html</a></div></div></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="m_-7378071011077674996gmail_signature" data-smartmail="gmail_signature">-- <br>Laurent Bourgès</div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">-- <br>Laurent Bourgès</div>