Ticket #1417 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

resizing the map quickly messes up tile load events (singleTile)

Reported by: bartvde Owned by: euzuro
Priority: minor Milestone: 2.6 Release
Component: Layer.Grid Version: 2.5
Keywords: Cc:
State: Complete

Description

When resizing the map quickly (so resize before the tiles from the previous resize are in), the LoadingPanel keeps spinning, indicating that something goes wrong with the load events.

If I removed the clearGrid call from onMapResize in Grid.js all is fine.

    onMapResize: function() {
        if (this.singleTile) {
            //this.clearGrid();
            this.setTileSize();
        }
    },

Attachments

ticket1417.patch Download (391 bytes) - added by bartvde 5 years ago.
destroy_events.patch Download (1.3 KB) - added by crschmidt 5 years ago.
unload.patch Download (2.6 KB) - added by crschmidt 5 years ago.

Change History

Changed 5 years ago by bartvde

  • owner set to euzuro
  • component changed from general to Layer.Grid

Changed 5 years ago by bartvde

Changed 5 years ago by ahocevar

  • state set to Review
  • milestone set to 2.6 Release

Changed 5 years ago by ahocevar

  • state changed from Review to Commit

I can confirm that the patch provided by bartvde works withoud side effects.

Changed 5 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [6436]) resizing the map quickly messes up tile load events (singleTile). Thanks bartvde for the patch. r=me (closes #1417)

Changed 5 years ago by ahocevar

(In [6437]) updated ND comment (see #1417)

Changed 5 years ago by crschmidt

  • status changed from closed to reopened
  • state changed from Complete to Needs More Work
  • resolution fixed deleted

Andreas:

If you take a relatively sized WMS Untiled map (change wms-untiled to 50% instead of 512px), then resize the map from smaller to bigger, you will see that the image inside the map is not resizing appropriately. Reverting this changeset fixes the problem. Removing the tiles from the grid is the way that they get recreated and therefore resized (because initSingleTile is called again).

Since this messes up events, I think the right solution is to check if the event is still waiting. (I believe this state can be checked on the tile.) If the tile is not yet loaded, then in clearGrid(), we should fire the event before we call removeTileMonitoring hooks, presumably via triggerEvent directly on the tile. This will cause the events to be updated.

With your approval, I'll roll back r6436/r6437, and then we can take the next step of actually solving the problem correctly.

Changed 5 years ago by crschmidt

(This issue was raised by #1420, which I've now closed as a duplicate.)

Changed 5 years ago by crschmidt

Changed 5 years ago by crschmidt

  • state changed from Needs More Work to Review
  • Restore clearGrid().
  • Change tile.destroy() to fire an event.
  • In the Layer.Grid, listen to destroy() events as well as tileloaded events, and

increment the count appropriately either way.

Changed 5 years ago by bartvde

I'll test your new patch tomorrow Chris and provide feedback.

Changed 5 years ago by bartvde

Hi Chris, unfortunately your patch does not work, after a resize the loading panel does not come back anymore.

Changed 5 years ago by bartvde

The following line ("destroy": tile.onLoadEnd) fixed up the previous problem, but the problem that the loadingpanel keeps loading after multiple resizes still exists:

    removeTileMonitoringHooks: function(tile) {
        tile.events.un({
            "loadstart": tile.onLoadStart,
            "loadend": tile.onLoadEnd,
            "destroy": tile.onLoadEnd,
            scope: this
        });
    },

Changed 5 years ago by bartvde

It looks like a timing problem to me, the tiles are destroyed but the tile loadend function is not called for all layers (it seems the slower layer is the one which does not get called):

destroying tile
destroying tile
loadstart: OV Zonering
loadstart: Weggeg portalen
tile on load end: Weggeg portalen
loadend: Weggeg portalen
destroying tile
destroying tile

Changed 5 years ago by bartvde

Strange things are actually happening, it seems that the slower untiled layer, being singleTile, gets numLoadingTiles to be 2 :-) :

destroying tile
destroying tile
loadstart: Weggeg portalen
tile on load end: Weggeg portalen, num loading tiles: 1
loadend: Weggeg portalen
tile on load end: OV Zonering, num loading tiles: 2

In order to get the "tile on load end for OV Zonering" I get had to not destroy the events object in Tile.js, which to me indicates that indeed there is a timing problem as well.

Changed 5 years ago by crschmidt

  • state changed from Review to Needs More Work

Changed 5 years ago by crschmidt

Of course this won't work. The removeTileMonitoringHooks is called *before* we call destroy, so we stop listening to events before we actually fire them.

Hmmm. I wonder what to do about that. I know that Erik likes to see explicit unregisters, but the tile does take care of this automatically. I wonder if I could convince him that our unregister code is good enough.

Changed 5 years ago by crschmidt

Changed 5 years ago by crschmidt

  • state changed from Needs More Work to Review

Okay. Destroy is too late, so we add an 'unload' method to the tile. Anyone wanting to get events when a tile is about to be destroyed if it is still loading has the requirement of calling tile.unload() on the tile: This will cause the tile to report an 'unload' event if it is still loading at the time the method is called. The layer should register for an unload event, and use that to decrement the count. (This also fixes another bug in the previous patch, which was that you could get a numTilesLoading of -1.) Also, unregister our events. (Which is what made me think it was working before, cause I wasn't cleaning up after myself.) Also, do it for the WFS layer too, since it suffers the same problem.

I've confirmed that when I resize the map with a single untiled layer, I'm getting load start/end events that match up one to one. Bart, please try this one when you get a chance.

Changed 5 years ago by bartvde

Chris, this works like a charm for untiled layers. I haven't tested WFS.

Changed 5 years ago by crschmidt

I've tested WFS, and it seems to work, so I'm happy with that. Thanks for the feedback and confirmation.

Anyone looking to review? /me glances towards ahocevar

Changed 5 years ago by ahocevar

  • state changed from Review to Commit

Chris, thanks for cleaning up my bad. The patch looks brilliant, and besides fixing the issue, the introduction of a tile unload event is a great idea! Please commit.

Changed 5 years ago by crschmidt

  • status changed from reopened to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [6495]) Improve the handling of tile events with regard to tiles being unloaded before their load events fire by adding an 'unload' event to the tile, and calling it from the places where we're about to stop listening to events. In the longer term, it might make sense to have this be automatic, but this resolves issues with map resizes screwing with tile events, and reverts a previous, incomplete solution to solve a problem with untiled tiles not resizing when the map size changes. r=ahocevar, checked out by bartvde (Closes #1417)

Note: See TracTickets for help on using tickets.