Opened 17 months ago
Last modified 7 months ago
#7280 new defect
Bing (unsuccessfully) loads images before attribution data is ready
| Reported by: | bastiK | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Component: | Core |
| Version: | Keywords: | tms bing | |
| Cc: |
Description
After adding Bing layer, I get the following console output
failed loading 13/4246/2754 null failed loading 13/4248/2755 null failed loading 13/4247/2754 null failed loading 13/4246/2756 null failed loading 13/4248/2754 null failed loading 13/4247/2756 null failed loading 13/4246/2755 null failed loading 13/4247/2755 null failed loading 13/4249/2754 null failed loading 13/4249/2755 null failed loading 13/4250/2755 null failed loading 13/4250/2756 null failed loading 13/4250/2754 null failed loading 13/4248/2756 null failed loading 13/4249/2756 null Successfully loaded Bing attribution data.
This indicates, that JOSM tries to load images for Bing before the attribution data is fetched.
Attachments (0)
Change History (15)
comment:1 Changed 17 months ago by skyper
comment:2 Changed 17 months ago by bastiK
Is this fixed? At the moment I get
Successfully loaded Bing attribution data. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded.
comment:3 follow-up: ↓ 7 Changed 17 months ago by simon04
I thought this was fixed in [o27519].
This output makes no sense to me. Is this error reproducible with fresh settings?
comment:4 Changed 17 months ago by bastiK
Yes. I added some debugging output, maybe this helps?
console:
#####paint #####paint #####paint getAttribution() 0 start to get attribution getAttribution() 1 getAttribution() 2 getAttribution() 3 getAttribution() 4 getAttribution() 5 call1 call2 getAttribution() 6 TMSLayer: Successfully loaded Bing attribution data. call3 getAttribution()/TimeoutException 5 Bing: attribution data is not yet loaded. failed loading 10/552/329 null getAttribution()/TimeoutException 4 Bing: attribution data is not yet loaded. failed loading 10/552/328 null getAttribution()/TimeoutException 0 Bing: attribution data is not yet loaded. failed loading 10/548/329 null getAttribution()/TimeoutException 3 Bing: attribution data is not yet loaded. failed loading 10/552/327 null getAttribution()/TimeoutException 2 Bing: attribution data is not yet loaded. failed loading 10/548/327 null getAttribution()/TimeoutException 1 Bing: attribution data is not yet loaded. failed loading 10/548/328 null getAttribution()/TimeoutException 6 Bing: attribution data is not yet loaded. getAttribution() 7 getAttribution()/TimeoutException 7 Bing: attribution data is not yet loaded. getAttribution() 8 call4 getAttribution()/ret 8
-
src/org/openstreetmap/josm/gui/layer/TMSLayer.java
237 237 URL u = getAttributionUrl(); 238 238 UTFInputStreamReader in = UTFInputStreamReader.create(u.openStream(), "utf-8"); 239 239 String r = new Scanner(in).useDelimiter("\\A").next(); 240 System.out.println(" Successfully loaded Bing attribution data.");240 System.out.println("TMSLayer: Successfully loaded Bing attribution data."); 241 241 return r.getBytes("utf-8"); 242 242 } 243 243 } … … 248 248 249 249 @Override 250 250 public List<Attribution> call() throws Exception { 251 System.err.println("call1"); 252 251 253 BingAttributionData attributionLoader = new BingAttributionData(); 254 System.err.println("call2"); 252 255 int waitTimeSec = 1; 253 256 while (true) { 254 257 try { 255 258 String xml = attributionLoader.updateIfRequiredString(); 256 return parseAttributionText(new InputSource(new StringReader((xml)))); 259 System.err.println("call3"); 260 List<Attribution> ret = parseAttributionText(new InputSource(new StringReader((xml)))); 261 System.err.println("call4"); 262 return ret; 257 263 } catch (IOException ex) { 258 264 System.err.println("Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds."); 259 265 Thread.sleep(waitTimeSec * 1000L); … … 1160 1166 */ 1161 1167 @Override 1162 1168 public void paint(Graphics2D g, MapView mv, Bounds bounds) { 1169 System.err.println("### TMSLayer/paint"); 1163 1170 //long start = System.currentTimeMillis(); 1164 1171 EastNorth topLeft = mv.getEastNorth(0, 0); 1165 1172 EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight()); -
src/org/openstreetmap/josm/gui/MapView.java
460 460 * Draw the component. 461 461 */ 462 462 @Override public void paint(Graphics g) { 463 System.err.println("#####paint"); 463 464 if (BugReportExceptionHandler.exceptionHandlingInProgress()) 464 465 return;
-
jmapviewer/tilesources/BingAerialTileSource.java
214 214 } 215 215 }; 216 216 } 217 217 static int dd = 0; 218 218 protected List<Attribution> getAttribution() { 219 // Thread.currentThread().dumpStack(); 220 int d = dd++; 221 System.err.println("getAttribution() "+d); 219 222 if (attributions == null) { 220 223 // see http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html 221 224 synchronized (BingAerialTileSource.class) { 222 225 if (attributions == null) { 226 System.err.println("start to get attribution"); 223 227 attributions = Executors.newSingleThreadExecutor().submit(getAttributionLoaderCallable()); 224 228 } 225 229 } 226 230 } 227 231 try { 228 return attributions.get(1000, TimeUnit.MILLISECONDS); 232 List<Attribution> ret = attributions.get(1000, TimeUnit.MILLISECONDS); 233 System.err.println("getAttribution()/ret "+d); 234 return ret; 229 235 } catch (TimeoutException ex) { 236 System.err.println("getAttribution()/TimeoutException "+d); 230 237 System.err.println("Bing: attribution data is not yet loaded."); 231 238 } catch (ExecutionException ex) { 232 239 throw new RuntimeException(ex.getCause());
comment:5 Changed 17 months ago by bastiK
It does seem to work however, just the console output looks strange.
comment:6 follow-up: ↓ 11 Changed 17 months ago by simon04
Interestingly, the parsing takes a "long" time (call3 to call4).
To fix this, …:
- we could increase the timeout (from 1000 to e.g. 5000 milliseconds)
- change the console output:
Successfully loaded Bing attribution data --> Successfully fetched Bing attribution data
Bing: attribution data is not yet loaded --> Bing: attribution data is not yet ready
comment:7 in reply to: ↑ 3 Changed 17 months ago by Don-vip
comment:8 Changed 17 months ago by simon04
From #7284: skyper:
It seems to work but I get strange messages on the console:
Repository Root: http://josm.openstreetmap.de/svn Build-Date: 2012-01-30 02:32:23 Last Changed Author: stoecker Revision: 4878 Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b URL: http://josm.openstreetmap.de/svn/trunk Last Changed Date: 2012-01-30 00:02:54 +0100 (Mon, 30 Jan 2012) Last Changed Rev: 4878 Warnung: Fehlende Einstellungsdatei "$HOME/.josm/preferences.xml". Datei mit Standardeinstellungen wird erstellt. GET http://api.openstreetmap.org/api/capabilities... OK Successfully loaded Bing attribution data. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. GET http://api.openstreetmap.org/api/0.6/map?bbox=....
comment:9 Changed 11 months ago by Don-vip
I still have this problem in r5402:
1. Download some OSM data of a given area 2. Add Bing layer 3. All tiles fail to load, and I can see on the console: Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Bing: attribution data is not yet loaded. Failed loading http://ecn.t2.tiles.virtualearth.net/tiles/a1202220232311021121.jpeg?g=1008: null Failed loading http://ecn.t1.tiles.virtualearth.net/tiles/a1202220232311021120.jpeg?g=1008: null Failed loading http://ecn.t0.tiles.virtualearth.net/tiles/a1202220232311021031.jpeg?g=1008: null Failed loading http://ecn.t1.tiles.virtualearth.net/tiles/a1202220232311021103.jpeg?g=1008: null Failed loading http://ecn.t2.tiles.virtualearth.net/tiles/a1202220232311021011.jpeg?g=1008: null Failed loading http://ecn.t0.tiles.virtualearth.net/tiles/a1202220232311021102.jpeg?g=1008: null Failed loading http://ecn.t0.tiles.virtualearth.net/tiles/a1202220232311021101.jpeg?g=1008: null Failed loading http://ecn.t3.tiles.virtualearth.net/tiles/a1202220232311021013.jpeg?g=1008: null Failed loading http://ecn.t1.tiles.virtualearth.net/tiles/a1202220232311021010.jpeg?g=1008: null Failed loading http://ecn.t2.tiles.virtualearth.net/tiles/a1202220232311021012.jpeg?g=1008: null Failed loading http://ecn.t3.tiles.virtualearth.net/tiles/a1202220232311021100.jpeg?g=1008: null Failed loading http://ecn.t3.tiles.virtualearth.net/tiles/a1202220232311021030.jpeg?g=1008: null
Restarting JOSM or refreshing the tiles solve the problem, I think it's maybe cache-related ?
comment:10 follow-up: ↓ 12 Changed 11 months ago by Don-vip
In 5406/josm:
comment:11 in reply to: ↑ 6 ; follow-up: ↓ 13 Changed 11 months ago by Don-vip
Replying to simon04:
Interestingly, the parsing takes a "long" time (call3 to call4).
Indeed. The method org.openstreetmap.gui.jmapviewer.tilesources.parseAttributionText() takes more than 300ms to parse Bing attribution, this is way too long. Replacing all these Xpath expressions with a faster StaX parsing would reduce this time drastically.
comment:12 in reply to: ↑ 10 Changed 11 months ago by bastiK
comment:13 in reply to: ↑ 11 ; follow-up: ↓ 14 Changed 11 months ago by bastiK
Replying to Don-vip:
Replying to simon04:
Interestingly, the parsing takes a "long" time (call3 to call4).
Indeed. The method org.openstreetmap.gui.jmapviewer.tilesources.parseAttributionText() takes more than 300ms to parse Bing attribution, this is way too long. Replacing all these Xpath expressions with a faster StaX parsing would reduce this time drastically.
Wow, that's is really slow for such a small document. Someone wrote a DOM parser in #6866, this might speed it up a little.
comment:14 in reply to: ↑ 13 Changed 11 months ago by Don-vip
comment:15 Changed 7 months ago by simon04
Any update on this?



One reason this was not reported ealier is that the attributions are loaded when opening the download dialog (#7284).