aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tarasov <anton.tarasov@jetbrains.com>2018-06-20 19:48:05 +0300
committerAnton Tarasov <anton.tarasov@jetbrains.com>2018-06-20 19:48:05 +0300
commit1f6dc10fc29427dc188442b77a69ad8f4083e4ae (patch)
treee8f744fab73439a258c6e2b21453aa9e2ccfbd64
parentc1ccf91cd6463e855d5a4084c5b7bde197a5f85b (diff)
downloadjdk8u_jdk-jb8u152-b1285.tar.gz
JDK-8202768 [macos] Appkit thread slows when any Window Manager activejb8u152-b1285
- Backport the Oracle version of the fix - Revert our versino of the fix JRE-336
-rw-r--r--src/macosx/native/sun/awt/JavaComponentAccessibility.m16
-rw-r--r--test/javax/accessibility/SlowPanelIteration/SlowPanelIteration.java107
2 files changed, 112 insertions, 11 deletions
diff --git a/src/macosx/native/sun/awt/JavaComponentAccessibility.m b/src/macosx/native/sun/awt/JavaComponentAccessibility.m
index 7df7446005..313887d4be 100644
--- a/src/macosx/native/sun/awt/JavaComponentAccessibility.m
+++ b/src/macosx/native/sun/awt/JavaComponentAccessibility.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -622,6 +622,9 @@ static NSObject *sAttributeNamesLOCK = nil;
}
// The above set of attributes is immutable per role, but some objects, if
// they are the child of a list, need to add the selected and index attributes.
+ if ([self accessibilityIsIgnored]) {
+ return names;
+ }
id myParent = [self accessibilityParentAttribute];
if ([myParent isKindOfClass:[JavaComponentAccessibility class]]) {
NSString *parentRole = [(JavaComponentAccessibility *)myParent javaRole];
@@ -895,16 +898,7 @@ static NSObject *sAttributeNamesLOCK = nil;
// Element containing current element (id)
- (id)accessibilityParentAttribute
{
- // NSAccessibilityUnignoredAncestor may cause a chain of recursive calls with
- // accessibilityAttributeNames method involved, that leads to a noticeable performance delay.
- // return NSAccessibilityUnignoredAncestor([self parent]);
-
- // In order to manually test whether an element is ignored there's "accessibilityIsIgnored" method,
- // though deprecated, so its suggested replacement - "accessibilityElement" method - should be used.
- // According to the spec, the method returns "true" by default for an element adopting NSAccessibility
- // protocol. So the only we should test is whether the java target of the element is accessible.
- // But we already have such method - "parent". It returns a native JCA wrapper over accessible parent.
- return [self parent];
+ return NSAccessibilityUnignoredAncestor([self parent]);
}
- (BOOL)accessibilityIsParentAttributeSettable
diff --git a/test/javax/accessibility/SlowPanelIteration/SlowPanelIteration.java b/test/javax/accessibility/SlowPanelIteration/SlowPanelIteration.java
new file mode 100644
index 0000000000..2e42f8fa14
--- /dev/null
+++ b/test/javax/accessibility/SlowPanelIteration/SlowPanelIteration.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+/**
+ * @test
+ * @key headful
+ * @bug 8202768
+ * @summary we should not hang when lots of panels are used
+ */
+public final class SlowPanelIteration {
+
+ private static JFrame frame;
+ private static Point center = new Point();
+ private static volatile CountDownLatch go;
+
+ public static void main(final String[] args) throws Exception {
+ Robot r = new Robot();
+ // accessibility tool will need time to react to our clicks
+ r.setAutoDelay(200);
+ try {
+ EventQueue.invokeAndWait(SlowPanelIteration::showUI);
+ for (int i = 0; i < 10; ++i) {
+ go = new CountDownLatch(1);
+ r.mouseMove(center.x, center.y);
+ r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ if (!go.await(10, TimeUnit.SECONDS)) {
+ throw new RuntimeException("Too slow operation");
+ }
+ }
+ } finally {
+ EventQueue.invokeAndWait(SlowPanelIteration::dispose);
+ }
+ }
+
+ private static void showUI() {
+ frame = new JFrame();
+ frame.setSize(new Dimension(400, 400));
+ frame.setLocationRelativeTo(null);
+
+ final Container content = frame.getContentPane();
+ content.setLayout(new BorderLayout(0, 0));
+ Container lastPanel = content;
+ for (int i = 0; i < 500; i++) {
+ final JPanel p = new JPanel();
+ p.setLayout(new BorderLayout(0, 0));
+ lastPanel.add(p);
+ lastPanel.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ System.out.println("click");
+ go.countDown();
+ }
+ });
+ lastPanel = p;
+ }
+
+ lastPanel.setBackground(Color.GREEN);
+ frame.setVisible(true);
+
+ Point loc = frame.getLocationOnScreen();
+ center.x = loc.x + frame.getWidth() / 2;
+ center.y = loc.y + frame.getHeight() / 2;
+ }
+
+ private static void dispose() {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+} \ No newline at end of file