Changeset 18150 in josm for trunk/src/org


Ignore:
Timestamp:
2021-08-21T03:19:58+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #20799 - fix performance/memory issues while scrolling across many geolocated images

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java

    r18018 r18150  
    2222import java.io.IOException;
    2323import java.util.Objects;
     24import java.util.concurrent.Future;
    2425
    2526import javax.swing.JComponent;
     
    635636     * Sets a new source image to be displayed by this {@code ImageDisplay}.
    636637     * @param entry new source image
    637      * @since 13220
     638     * @return a {@link Future} representing pending completion of the image loading task
     639     * @since 18150
    638640     */
    639     public void setImage(ImageEntry entry) {
     641    public Future<?> setImage(ImageEntry entry) {
    640642        LoadImageRunnable runnable = setImage0(entry);
    641         if (runnable != null) {
    642             MainApplication.worker.execute(runnable);
    643         }
     643        return runnable != null ? MainApplication.worker.submit(runnable) : null;
    644644    }
    645645
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r18049 r18150  
    1919import java.util.List;
    2020import java.util.Optional;
     21import java.util.concurrent.Future;
    2122
    2223import javax.swing.AbstractAction;
     
    7374
    7475    private final ImageDisplay imgDisplay = new ImageDisplay(imageryFilterSettings);
     76    private Future<?> imgLoadingFuture;
    7577    private boolean centerView;
    7678
     
    205207        imageRemoveFromDiskAction.destroy();
    206208        imageZoomAction.destroy();
     209        cancelLoadingImage();
    207210        super.destroy();
    208211        dialog = null;
     
    467470
    468471            if (imageChanged) {
     472                cancelLoadingImage();
    469473                // Set only if the image is new to preserve zoom and position if the same image is redisplayed
    470474                // (e.g. to update the OSD).
    471                 imgDisplay.setImage(entry);
     475                imgLoadingFuture = imgDisplay.setImage(entry);
    472476            }
    473477            setTitle(tr("Geotagged Images") + (!entry.getDisplayName().isEmpty() ? " - " + entry.getDisplayName() : ""));
     
    628632    }
    629633
     634    private void cancelLoadingImage() {
     635        if (imgLoadingFuture != null) {
     636            imgLoadingFuture.cancel(false);
     637            imgLoadingFuture = null;
     638        }
     639    }
     640
    630641    @Override
    631642    public void selectedImageChanged(ImageData data) {
  • trunk/src/org/openstreetmap/josm/gui/progress/swing/ProgressMonitorExecutor.java

    r14068 r18150  
    4949                ((Future<?>) r).get();
    5050            } catch (CancellationException cancellationException) {
    51                 t = cancellationException;
     51                Logging.debug("Thread {0} raised {1}", Thread.currentThread().getName(), cancellationException);
    5252            } catch (ExecutionException executionException) {
    5353                Logging.trace(executionException);
Note: See TracChangeset for help on using the changeset viewer.