Modify

#22865 closed defect (fixed)

[PATCH] Pressing "Presets" button causes JOSM to get stuck on loading

Reported by: little.banana.peel@… Owned by: team
Priority: normal Milestone: 23.04
Component: Core Version:
Keywords: template_report, macos, javabug Cc: Stereo

Description

What steps will reproduce the problem?

  1. Open JOSM
  2. Download some data
  3. Press "Presets"

What is the expected result?

When pressing "Presets", presets should appear.

What happens instead?

When pressing "Presets", the app gets stuck on loading, forcing me to have to force quit.

Please provide any additional information below. Attach a screenshot if possible.

Opening presets using F3 works fine

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2023-03-30 16:51:36 +0200 (Thu, 30 Mar 2023)
Revision:18700
Build-Date:2023-03-31 01:30:56
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (18700 en) Mac OS X 12.5.1
OS Build number: macOS 12.5.1 (21G83)
Memory Usage: 653 MB / 2048 MB (225 MB allocated, but free)
Java version: 17.0.5+8-LTS, Azul Systems, Inc., OpenJDK 64-Bit Server VM
Look and Feel: com.apple.laf.AquaLookAndFeel
Screen: Display 1 2240×1260 (scaling 2.00×2.00)
Maximum Screen Size: 2240×1260
Best cursor sizes: 16×16→16×16, 32×32→32×32
Environment variable LANG: en_US.UTF-8
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: en_US
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-Djava.util.Arrays.useLegacyMergeSort=true, --add-exports=jdk.deploy/com.sun.deploy.config=ALL-UNNAMED, --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED, --add-reads=java.naming=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.action=ALL-UNNAMED,java.desktop, --add-reads=java.base=ALL-UNNAMED,java.desktop, --add-exports=java.naming/com.sun.jndi.toolkit.url=ALL-UNNAMED,java.desktop, --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED, --add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED, --add-exports=java.desktop/sun.awt=ALL-UNNAMED,java.desktop, --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED, --add-exports=java.base/sun.security.validator=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED,java.desktop, --add-exports=java.base/jdk.internal.util.jar=ALL-UNNAMED,java.desktop, --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED, --add-exports=java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED,java.desktop, --add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/sun.applet=ALL-UNNAMED,java.desktop,jdk.jsobject, --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop, --add-opens=java.base/java.lang=ALL-UNNAMED, --add-exports=java.base/sun.security.util=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED, --add-reads=java.desktop=ALL-UNNAMED,java.naming, --add-opens=java.base/java.nio=ALL-UNNAMED, --add-exports=java.base/sun.security.x509=ALL-UNNAMED,java.desktop, --add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED, --add-exports=java.desktop/javax.jnlp=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.provider=ALL-UNNAMED,java.desktop]

Plugins:
+ CADTools (1008)
+ ColorPlugin (v1.1.2.1)
+ Mapillary (2.1.2)
+ OpeningHoursEditor (35924)
+ ShapeTools (1250)
+ alignways (36011)
+ apache-commons (36034)
+ apache-http (35924)
+ buildings_tools (36011)
+ damn (0.10.1)
+ intersection (0.0.7)
+ jna (36005)
+ mapwithai (789)
+ tageditor (36011)
+ turnlanes (36011)
+ turnlanes-tagging (v0.0.5)
+ utilsplugin2 (36011)

Tagging presets:
+ https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/presets/nsi-josm-presets.min.xml

Map paint styles:
- https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Enhanced_Lane_and_Road_Attributes&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/ParkingLanes&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Lane_and_Road_Attributes&zip=1

Attachments (0)

Change History (3)

comment:1 by taylor.smock, 13 months ago

Cc: Stereo added
Keywords: macos javabug added
Milestone: 23.04
OS Build number: macOS 12.5.1 (21G83)
Java version: 17.0.5+8-LTS, Azul Systems, Inc., OpenJDK 64-Bit Server VM
Look and Feel: com.apple.laf.AquaLookAndFeel

Mac has a problem when adding thousands of entries to a menu. I've reported this upstream to the Java JDK (see https://bugs.openjdk.org/browse/JDK-8297117 ).

A workaround that works on Java 8 is to switch to the Metal Look and Feel (wiki:Help/Preferences/Display). This does not work in Java 17, unfortunately.

We can add some code to never use the screen menu bar if the name-suggestion-index is detected like so:

  • src/org/openstreetmap/josm/tools/PlatformHookOsx.java

    diff --git a/src/org/openstreetmap/josm/tools/PlatformHookOsx.java b/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
    a b  
    3131
    3232import org.openstreetmap.josm.data.Preferences;
    3333import org.openstreetmap.josm.gui.MainApplication;
     34import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
    3435import org.openstreetmap.josm.io.CertificateAmendment.NativeCertAmend;
     36import org.openstreetmap.josm.spi.preferences.Config;
    3537
    3638/**
    3739 * {@code PlatformHook} implementation for Apple macOS (formerly Mac OS X) systems.
     
    4951    }
    5052
    5153    @Override
    52     public void preStartupHook() {
     54    public void afterPrefStartupHook() {
    5355        // This will merge our MenuBar into the system menu.
    5456        // MUST be set before Swing is initialized!
    5557        // And will not work when one of the system independent LAFs is used.
    5658        // They just insist on painting themselves...
    57         Utils.updateSystemProperty("apple.laf.useScreenMenuBar", "true");
     59        // But only use the menu bar if the Name Suggestion Index is not enabled -- see JDK-8297117 (can remove once that is fixed)
     60        // The NSI is especially egregious since it adds something like 8k presets, and is the most likely to trigger JDK-8297117.
     61        if (TaggingPresetReader.getPresetSources().stream().noneMatch(url -> url.contains("name-suggestion-index"))) {
     62            Utils.updateSystemProperty("apple.laf.useScreenMenuBar", "true");
     63        }
    5864        Utils.updateSystemProperty("apple.awt.application.name", "JOSM");
    5965    }
    6066

With that said, I really don't like singling out the NSI, but they are also the only preset that is likely to trigger this bug. I think (but have not verified) that if we enabled all the other presets and disabled the NSI we would not be able trigger this bug.

I think, when I was fiddling with this before, that it took ~20 minutes for the UI to start responding again.

@Stereo: Do you think that Mac OS users would be able to handle having a menu bar in the application window after enabling NSI and restarting JOSM?

comment:2 by taylor.smock, 13 months ago

Summary: Pressing "Presets" button causes JOSM to get stuck on loading[PATCH] Pressing "Presets" button causes JOSM to get stuck on loading

comment:3 by taylor.smock, 12 months ago

Resolution: fixed
Status: newclosed

In 18704/josm:

Fix #22865: Pressing "Presets" button causes JOSM to get stuck on loading (macOS)

This is caused by JDK-8297117, and the Name Suggestion Index is the only preset
that should trigger the bug. This works around the issue by preventing the merging
of our MenuBar with the system menu when the Name Suggestion Index may be
enabled.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.