Modify

Opened 13 years ago

Closed 10 years ago

Last modified 10 years ago

#6797 closed defect (fixed)

Loading of http:// images blocks user input. It should be done in background

Reported by: bastiK Owned by: team
Priority: normal Milestone: 14.01
Component: Core Version:
Keywords: background Cc:

Description (last modified by bastiK)

...continued from #6137.

At the moment, we load images in EDT. When there is delay in the network, the user interface may block for some time. Instead, we should fetch the images asynchronously in a background thread.

Attachments (3)

async.diff (7.7 KB ) - added by bastiK 12 years ago.
async2.diff (19.1 KB ) - added by bastiK 12 years ago.
async3.diff (31.2 KB ) - added by bastiK 12 years ago.
ready for commit

Download all attachments as: .zip

Change History (17)

comment:1 by bastiK, 13 years ago

Replying to cmuelle8:

  • First the preliminary icon is shown on the map, but when loading is finished, no repaint is done.

This should be solvable.

  • The ElemStyles are cached and the preliminary Image causes wrong hash value. Consequently the wrong icon may be shown.

This really sucks. There is a comment in StyleCache I suppose you are refering to: "StyleCache must not be changed after it has been added to the intern pool." This would mitigate all efforts to do asynchronous resource loading.

Since resources effect hashCode calculation and hashCodes must not be manipulated after intern pool is built, we would have to wait building the intern pool until all resources are fetched.

Would it not suffice to just hash the name of the image? After all, if images use the same icon-image value in a style sheet, they evaluate to the same hashCode, just as the name values should, if they are identical. There would only be deviations to current behavior if a style writer uses the same image under different names - a case highly improbable.

You are right, it can be fixed relatively easy. The name is not enough, because there can be multiple zip archives that contain icons with the same name. See MapPaintStyles.IconReference class for a full description. My point was, that the patch doesn't quite work like this, but there is more to do...

comment:2 by bastiK, 13 years ago

Replying to cmuelle8:

Replying to bastiK:

  • First the preliminary icon is shown on the map, but when loading is finished, no repaint is done.

In MapPainter.java, function drawNodeIcon(), line

icon.paintIcon ( nc, g,   [...]

nc is used as a Component implementing ImageObserver. Maybe we can leverage this and use AWT functionality for asynchronous image loading, no need to write code twice.

Sure, whatever works best. No need to force it, though.

comment:3 by bastiK, 12 years ago

In [4822/josm]:

make identity of map icons depend on the name and not the image data (see #6797)

comment:4 by bastiK, 12 years ago

In [4823/josm]:

forgot to add (see #6797)

by bastiK, 12 years ago

Attachment: async.diff added

comment:5 by bastiK, 12 years ago

Description: modified (diff)

First version. Should work, but is there a better (simpler) way to do this?

by bastiK, 12 years ago

Attachment: async2.diff added

comment:6 by bastiK, 12 years ago

Improved version.

FIXME: Text label position is not updated when the image is loaded and the final image is smaller or larger than the dummy image.

by bastiK, 12 years ago

Attachment: async3.diff added

ready for commit

comment:7 by bastiK, 12 years ago

Fixed wrong label position, this should work now.

comment:8 by bastiK, 12 years ago

In 5054/josm:

see #6797: load map images in background, in case they are loaded over a network. Show temporary image in the meantime.

comment:9 by bastiK, 12 years ago

FIXME: update disabled image cache

comment:10 by Don-vip, 11 years ago

Keywords: background added

comment:11 by Don-vip, 10 years ago

In 6707/josm:

fix #9028, see #6797 - load imagery layer icons in background

in reply to:  9 comment:12 by Don-vip, 10 years ago

Replying to bastiK:

FIXME: update disabled image cache

Is there still something to do or can we close this ticket ?

comment:13 by bastiK, 10 years ago

Resolution: fixed
Status: newclosed

In 6711/josm:

closes #6797 - clear disabled image cache, when image loading is finished

comment:14 by Don-vip, 10 years ago

Milestone: 14.01

thanks !

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.