Modify

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

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

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: 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

     
    237237                URL u = getAttributionUrl(); 
    238238                UTFInputStreamReader in = UTFInputStreamReader.create(u.openStream(), "utf-8"); 
    239239                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."); 
    241241                return r.getBytes("utf-8"); 
    242242            } 
    243243        } 
     
    248248 
    249249                @Override 
    250250                public List<Attribution> call() throws Exception { 
     251                    System.err.println("call1"); 
     252                 
    251253                    BingAttributionData attributionLoader = new BingAttributionData(); 
     254                    System.err.println("call2"); 
    252255                    int waitTimeSec = 1; 
    253256                    while (true) { 
    254257                        try { 
    255258                            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; 
    257263                        } catch (IOException ex) { 
    258264                            System.err.println("Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds."); 
    259265                            Thread.sleep(waitTimeSec * 1000L); 
     
    11601166     */ 
    11611167    @Override 
    11621168    public void paint(Graphics2D g, MapView mv, Bounds bounds) { 
     1169        System.err.println("### TMSLayer/paint"); 
    11631170        //long start = System.currentTimeMillis(); 
    11641171        EastNorth topLeft = mv.getEastNorth(0, 0); 
    11651172        EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight()); 
  • src/org/openstreetmap/josm/gui/MapView.java

     
    460460     * Draw the component. 
    461461     */ 
    462462    @Override public void paint(Graphics g) { 
     463        System.err.println("#####paint"); 
    463464        if (BugReportExceptionHandler.exceptionHandlingInProgress()) 
    464465            return; 
  • jmapviewer/tilesources/BingAerialTileSource.java

     
    214214            } 
    215215        }; 
    216216    } 
    217  
     217static int dd = 0; 
    218218    protected List<Attribution> getAttribution() { 
     219//        Thread.currentThread().dumpStack(); 
     220    int d = dd++; 
     221System.err.println("getAttribution() "+d); 
    219222        if (attributions == null) { 
    220223            // see http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html 
    221224            synchronized (BingAerialTileSource.class) { 
    222225                if (attributions == null) { 
     226                    System.err.println("start to get attribution"); 
    223227                    attributions = Executors.newSingleThreadExecutor().submit(getAttributionLoaderCallable()); 
    224228                } 
    225229            } 
    226230        } 
    227231        try { 
    228             return attributions.get(1000, TimeUnit.MILLISECONDS); 
     232            List<Attribution> ret = attributions.get(1000, TimeUnit.MILLISECONDS); 
     233System.err.println("getAttribution()/ret "+d); 
     234            return ret; 
    229235        } catch (TimeoutException ex) { 
     236System.err.println("getAttribution()/TimeoutException "+d); 
    230237            System.err.println("Bing: attribution data is not yet loaded."); 
    231238        } catch (ExecutionException ex) { 
    232239            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: 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

Replying to simon04:

I thought this was fixed in [o27519].

I can confirm this update fixed the problem on my config (I was seeing them almost every day but never took time to report the bug, as a zoom/unzoom was enough to reload missing tiles).

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: Changed 11 months ago by Don-vip

In 5406/josm:

see #7280 - Change synchronization mechanism of MapView when being notified of paint preferences change.

The previous mechanism leads to a deadlock when the paint() method triggers itself a paint preference change, such as when a TMS layer wants to paint attribution.
This caused an HMI freeze of 1s and Bing layer to never display tiles at its first display without cached attribution.

comment:11 in reply to: ↑ 6 ; follow-up: 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

Replying to Don-vip:

In 5406/josm:

see #7280 - Change synchronization mechanism of MapView when being notified of paint preferences change.

The previous mechanism leads to a deadlock when the paint() method triggers itself a paint preference change, such as when a TMS layer wants to paint attribution.
This caused an HMI freeze of 1s and Bing layer to never display tiles at its first display without cached attribution.

Thanks for fixing this deadlock, didn't think of that... :)

comment:13 in reply to: ↑ 11 ; follow-up: 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

Replying to bastiK:

Someone wrote a DOM parser in #6866, this might speed it up a little.

Nice ! I'll try that tonight :)

comment:15 Changed 7 months ago by simon04

Any update on this?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team. Next status will be 'new'.
Next status will be 'needinfo'.The owner will change to bastiK
as duplicate The resolution will be set to duplicate. Next status will be 'closed'.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.