Modify

Opened 3 months ago

Closed 2 months ago

Last modified 5 weeks ago

#23721 closed defect (fixed)

[PATCH] Application hangs indefinitely if Bing API unavailable

Reported by: openstreetmap.a9ust@… Owned by: team
Priority: normal Milestone: 24.07
Component: Core imagery Version:
Keywords: template_report Cc:

Description

What steps will reproduce the problem?

  1. Try to import Bing imagery
  2. Watch the program hang indefinitely and have to kill it with a process manager

What is the expected result?

If Bing API is unavailable the app shouldn't crash

What happens instead?

The whole time while it's waiting for Bing, the app is unresponsive. This is an issue when the retry timeout doubles each time.

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

2024-06-08 11:27:28.805 WARNING: Could not connect to Bing API. Will retry in 64 seconds.: java.net.SocketTimeoutException: Connect timed out
2024-06-08 11:28:47.877 INFO: GET https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&output=xml&key=...stripped... -> !!! (15.1 s)
2024-06-08 11:28:47.877 WARNING: java.net.SocketTimeoutException: Connect timed out
java.net.SocketTimeoutException: Connect timed out
	at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:592)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
	at java.base/java.net.Socket.connect(Socket.java:751)
	at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:304)
	at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:178)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:531)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:636)
	at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
	at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:377)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1237)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1123)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:141)
	at org.openstreetmap.josm.tools.Http1Client.performConnection(Http1Client.java:78)
	at org.openstreetmap.josm.tools.HttpClient.connect(HttpClient.java:162)
	at org.openstreetmap.josm.tools.HttpClient.connect(HttpClient.java:136)
	at org.openstreetmap.josm.tools.HttpClient.connect(HttpClient.java:125)
	at org.openstreetmap.josm.data.imagery.CachedAttributionBingAerialTileSource$BingAttributionData.updateData(CachedAttributionBingAerialTileSource.java:65)
	at org.openstreetmap.josm.io.CacheCustomContent.updateForce(CacheCustomContent.java:131)
	at org.openstreetmap.josm.io.CacheCustomContent.updateForceString(CacheCustomContent.java:143)
	at org.openstreetmap.josm.io.CacheCustomContent.updateIfRequiredString(CacheCustomContent.java:121)
	at org.openstreetmap.josm.data.imagery.CachedAttributionBingAerialTileSource.lambda$getAttributionLoaderCallable$0(CachedAttributionBingAerialTileSource.java:88)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.lang.Thread.run(Thread.java:1583)

2024-06-08 11:28:47.878 WARNING: Already here java.net.SocketTimeoutException: Connect timed out
2024-06-08 11:28:47.878 WARNING: Could not connect to Bing API. Will retry in 128 seconds.: java.net.SocketTimeoutException: Connect timed out
Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2024-06-03 18:08:14 +0200 (Mon, 03 Jun 2024)
Revision:19096
Build-Date:2024-06-04 01:31:15
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (19096 en_GB) Linux Freedesktop SDK 23.08 (Flatpak runtime)
Memory Usage: 252 MB / 8008 MB (144 MB allocated, but free)
Java version: 21.0.3+2, Flathub, OpenJDK 64-Bit Server VM
Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel
Screen: :0.0 1920×1080 (scaling 1.00×1.00) :0.1 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→16×16, 32×32→32×32
Environment variable LANG: en_GB.UTF-8
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: en_GB
Numbers with default locale: 1234567890 -> 1234567890
Desktop environment: GNOME
VM arguments: [--module-path=/app/share/openjfx/lib, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, -Djosm.restart=true, -Djava.net.useSystemProxies=true, --add-exports=java.base/sun.security.action=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED]

Plugins:
+ BuildingGeneralization (36)
+ ImageWayPoint (36226)
+ ImproveWay (32)
+ OpeningHoursEditor (36258)
+ buildings_tools (36226)
+ centernode (v1.0.4)
+ indoorequal (0.0.7)
+ indoorhelper (1.2.3)
+ terracer (36205)
+ wikipedia (605)

Map paint styles:
+ <josm.userdata>/plugins/indoorhelper/resources/sit.mapcss

Attachments (2)

23721.jmapviewer.patch (1.6 KB ) - added by taylor.smock 3 months ago.
23721.core.patch (6.4 KB ) - added by taylor.smock 3 months ago.

Download all attachments as: .zip

Change History (22)

comment:1 by gaben, 3 months ago

Component: External imagery sourceCore imagery

Hanging is a core issue.

comment:2 by taylor.smock, 3 months ago

This is actually going to take some modifications in JMapViewer; it might not be a bad idea to put some modifications in JOSM as well to handle this.

The problem is that JMapViewer calls future.get() even if the future is not done; instead, it should return null to indicate that loading is not yet complete.

by taylor.smock, 3 months ago

Attachment: 23721.jmapviewer.patch added

by taylor.smock, 3 months ago

Attachment: 23721.core.patch added

comment:3 by taylor.smock, 3 months ago

Milestone: 24.06
Summary: Application hangs indefinitely if Bing API unavailable[PATCH] Application hangs indefinitely if Bing API unavailable

comment:4 by stoecker, 2 months ago

Milestone: 24.0624.07

Milestone closed.

comment:5 by taylor.smock, 2 months ago

In 36292/osm:

See #23721: Application hangs indefinitely if Bing API unavailable

BingAerialTileSource.getAttribution is supposed to exit quickly and return null
if the attributions are not yet loaded. Instead attributions.get() was doing
the following:

  1. Creating a new attributions loader on a different thread (if it didn't exist)
  2. Waiting for the attributions loader to finish
  3. If the loader finished properly, we returned the actual data. Otherwise, null was returned.

This additionally fixes some lint issues, of specific note URL constructors are
deprecated (for details, see https://inside.java/2023/02/15/quality-heads-up/ ).

comment:6 by taylor.smock, 2 months ago

Resolution: fixed
Status: newclosed

In 19145/josm:

Fix #23721: Application hangs indefinitely if Bing API unavailable

This adds a progress monitor that the user can cancel if Bing attribution doesn't
load quickly enough. This additionally removes the need for Thread.sleep calls
by using a timer thread.

This requires an update to the JMapViewer dependency.

comment:7 by taylor.smock, 2 months ago

In 19148/josm:

Dependency updates

ivy.xml

  • Remove old dependencies (javax.json, jsr305 -- fixes #23220)
  • JMapViewer: 2.19 -> 2.20 - fixes deadlock when Bing attribution cannot be loaded (see #23721)
  • Wiremock: 3.6.0 -> 3.8.0
  • Various other minor dependency updates

comment:8 by damjang, 7 weeks ago

I have this warning also with 19149 build: and I con not close josm, only break. Is this related?

2024-07-23 15:21:32.365 WARNING: Already here sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
2024-07-23 15:21:32.366 WARNING: Could not connect to Bing API. Will retry in 128 seconds.: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. Cause: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. Cause: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

comment:9 by taylor.smock, 7 weeks ago

If anything, r19149 should allow you to close JOSM if you cannot reach the Bing API since we are fetching the Bing API in the background instead of in the UI thread. There should be a window with a Cancel button that you can click.

in reply to:  9 comment:10 by damjang, 7 weeks ago

Replying to taylor.smock:

If anything, r19149 should allow you to close JOSM if you cannot reach the Bing API since we are fetching the Bing API in the background instead of in the UI thread. There should be a window with a Cancel button that you can click.

Sorry, but I don't have any window with Cancel

comment:11 by taylor.smock, 7 weeks ago

Can you open a new ticket?

If you are having a freeze, and assuming you are using a JDK instead of one of the JOSM installers, you can help me out by running the following on the command line:

# jps will print the running process ids for Java applications.
# JOSM can show up as one of several different applications, depending upon how it was started.
# The first column is the process id (PID). Copy that for the next step.
$ jps
61813 josm-latest.jar
45208 Boot
65259 MainApplication
$ jstack ${id_from_jps}
[...a whole bunch of text you should attach to the new ticket...]
  • If you are running JOSM with java -jar, jstack $(jps | grep 'josm' | awk '{print $1}') is a good one-liner.
  • If you are running JOSM with OpenWebStart, jstack $(jps | grep 'Boot' | awk '{print $1}') is a good one-liner.
  • If you are running JOSM using an installer, jstack $(jps | grep 'MainApplication' | awk '{print $1}') should work, but you will probably have to fall back to reading jps manually.

For the last two options, you probably don't have a JDK installed. We typically recommend Azul (Windows (use msi) or mac (use dmg)), but any JDK (e.g. Temurin) will work.


Thanks for your report, however your ticket is incomplete and therefore not helpful in its current form.

Please add all needed information according to this list:

  • The required parts of the Status Report from your JOSM.
  • Describe what behaviour you expected.
  • Describe what did happen instead.
  • Describe if and how the issue is reproducible.
  • Add any relevant information like error messages or screenshots.

To ensure that all technical relevant information is contained, create new tickets by clicking in JOSMs Main Menu on Helpsource:trunk/resources/images/bug.svg Report Bug.

Remember: This is a generic notice so we don't need to write the same stuff again and again. It may only apply in parts to the specific case!


in reply to:  11 comment:12 by damjang, 7 weeks ago

Replying to taylor.smock:

Can you open a new ticket?

If you are having a freeze, and assuming you are using a JDK instead of one of the JOSM installers, you can help me out by running the following on the command line:

# jps will print the running process ids for Java applications.
# JOSM can show up as one of several different applications, depending upon how it was started.
# The first column is the process id (PID). Copy that for the next step.
$ jps
61813 josm-latest.jar
45208 Boot
65259 MainApplication
$ jstack ${id_from_jps}
[...a whole bunch of text you should attach to the new ticket...]
  • If you are running JOSM with java -jar, jstack $(jps | grep 'josm' | awk '{print $1}') is a good one-liner.
  • If you are running JOSM with OpenWebStart, jstack $(jps | grep 'Boot' | awk '{print $1}') is a good one-liner.
  • If you are running JOSM using an installer, jstack $(jps | grep 'MainApplication' | awk '{print $1}') should work, but you will probably have to fall back to reading jps manually.

For the last two options, you probably don't have a JDK installed. We typically recommend Azul (Windows (use msi) or mac (use dmg)), but any JDK (e.g. Temurin) will work.


Thanks for your report, however your ticket is incomplete and therefore not helpful in its current form.

Please add all needed information according to this list:

  • The required parts of the Status Report from your JOSM.
  • Describe what behaviour you expected.
  • Describe what did happen instead.
  • Describe if and how the issue is reproducible.
  • Add any relevant information like error messages or screenshots.

To ensure that all technical relevant information is contained, create new tickets by clicking in JOSMs Main Menu on Helpsource:trunk/resources/images/bug.svg Report Bug.

Remember: This is a generic notice so we don't need to write the same stuff again and again. It may only apply in parts to the specific case!


Sorry, after recheck and load the correct josm-latest.jar I have window with Cancel button, so my fault.

comment:13 by taylor.smock, 7 weeks ago

Sorry, after recheck and load the correct josm-latest.jar I have window with Cancel button, so my fault.

No problem. Mistakes happen.

comment:14 by skyper, 6 weeks ago

There is still an annoying glitch as the tiles are not automatically reloaded once the attribution was successfully loaded. Right now, Error: Attribution is not loaded yet remains on the screen and I have to manually reload the tiles on every zoom level.

Last edited 6 weeks ago by skyper (previous) (diff)

comment:15 by taylor.smock, 5 weeks ago

@skyper: that isn't going to be a simple fix. Can you open another ticket?

comment:16 by stoecker, 5 weeks ago

Don't we have a "reload error tiles" function. Would simply calling it when attribution is loaded help?

in reply to:  15 comment:17 by skyper, 5 weeks ago

Replying to taylor.smock:

@skyper: that isn't going to be a simple fix. Can you open another ticket?

See #23841

in reply to:  16 comment:18 by taylor.smock, 5 weeks ago

Replying to stoecker:

Don't we have a "reload error tiles" function. Would simply calling it when attribution is loaded help?

Yes. The problem is calling it from a location where we know that the attribution has been loaded.

We can do one of several different things (semi-psuedocode):

  1. Call MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).stream().filter(l -> l.getInfo() == 'Bing').forEach(TMSLayer::reloadTiles)
  2. Add an overload with a Runnable that will be called when the attribution is loaded.

(1) is easier, (2) is better IMO.

comment:19 by stoecker, 5 weeks ago

1) looks ugly...

comment:20 by taylor.smock, 5 weeks ago

I agree, but it is the "easy" fix. I'd rather do 2, but I think I'm going to have to do changes in JMapViewer. It isn't that difficult, but it is going to take a little bit of time.

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.