Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8317771

[macos14] Expand/collapse a JTree using keyboard freezes the application in macOS 14 Sonoma

    XMLWordPrintable

Details

    • b10
    • 18
    • b06
    • aarch64
    • os_x

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        Apple Silicon M1/M2 32GB, Sonoma 14.0
        The problem is visible in these tested Java versions:
        - Java HotSpot(TM) 64-Bit Server VM, 17.0.8+9-LTS-211, Oracle Corporation
        - OpenJDK 64-Bit Server VM, 17.0.8.1+1, Eclipse Adoptium
        - OpenJDK 64-Bit Server VM, 21+35, Azul Systems, Inc.

        A DESCRIPTION OF THE PROBLEM :
        Having a simple JTree with one root and 10 000 child nodes. Toggle the root expansion state using double-click works fine, as well does toggling using the expand/collapse icon. However, using the keyboard right/left keys eventually freezes the Java VM for a long time.

        The app works fine in Apple Silicon M1/M2, Ventura 13.x

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Launch the attached sample app
        1. Select the "Root" node
        2. Press left keyboard key collapse the root
        3. Press right keyboard key to expand
        Now the app is frozen

        Using double-click or the expansion icon to expand/collapse works fine

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The tree should instantly expand/collapse when double-click, using the expansion icon, or the keyboard
        ACTUAL -
        The application hangs showing the macOS beachball. After many minutes the app comes back to usable state but the problem will reappear at following expand/collapse using keyboard

        ---------- BEGIN SOURCE ----------
        import javax.swing.*;
        import javax.swing.tree.DefaultMutableTreeNode;
        import java.awt.*;

        /**
         * Shows a simple JTree with one root and 10 000 child nodes.
         * Toggle the root expansion state using double-click works fine, as well when toggle using the expand/collapse icon.
         * However, using the keyboard right/left keys eventually freezes the Java VM for a long time.
         */
        class SonomaARMJTreeBug {
           public static void main(String[] args) {
              SwingUtilities.invokeLater(() -> {
                 String javaInfo = System.getProperty("os.name") + " " +
                                   System.getProperty("os.version") + " (" +
                                   System.getProperty("os.arch") + "), " +
                                   System.getProperty("java.vm.name") + ", " +
                                   System.getProperty("java.vm.version") + ", " +
                                   System.getProperty("java.vm.vendor");
                 System.out.println(javaInfo);
                       
                 DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Root");
                 for (int i = 0; i < 10000; i++) {
                    rootNode.add(new DefaultMutableTreeNode("Child " + i));
                 }

                 JTree tree = new JTree(rootNode);
                 tree.setShowsRootHandles(true);
        // t.setLargeModel(true); // This makes no difference

                 JFrame frame = new JFrame();
                 frame.add(new JLabel("<html>- Toggle the handle icon next to 'Root' or double-click it a few times. Expand/collapse works fine." +
                                      "<br>- Now use keyboard right/left to expand/collapse, the app eventually freeze for a long time.</html>"), BorderLayout.NORTH);
                 frame.add(new JScrollPane(tree), BorderLayout.CENTER);
                 frame.add(new JLabel(javaInfo), BorderLayout.SOUTH);
                 frame.setSize(700, 700);
                 frame.setVisible(true);
              });
           }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        In macOS 14 use "OpenJDK 64-Bit Server VM, 17.0.7+7-b966.2, JetBrains s.r.o." or downgrade any other Java VM to version 11.x.

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                asemenov Artem Semenov
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: