{"action":"created","issue":{"url":"https://api.github.com/repos/openlayers/ol3/issues/5795","repository_url":"https://api.github.com/repos/openlayers/ol3","labels_url":"https://api.github.com/repos/openlayers/ol3/issues/5795/labels{/name}","comments_url":"https://api.github.com/repos/openlayers/ol3/issues/5795/comments","events_url":"https://api.github.com/repos/openlayers/ol3/issues/5795/events","html_url":"https://github.com/openlayers/ol3/pull/5795","id":173665421,"number":5795,"title":"Render older loaded tiles while waiting for new tiles","user":{"login":"thomasmoelhave","id":179143,"avatar_url":"https://avatars.githubusercontent.com/u/179143?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasmoelhave","html_url":"https://github.com/thomasmoelhave","followers_url":"https://api.github.com/users/thomasmoelhave/followers","following_url":"https://api.github.com/users/thomasmoelhave/following{/other_user}","gists_url":"https://api.github.com/users/thomasmoelhave/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasmoelhave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasmoelhave/subscriptions","organizations_url":"https://api.github.com/users/thomasmoelhave/orgs","repos_url":"https://api.github.com/users/thomasmoelhave/repos","events_url":"https://api.github.com/users/thomasmoelhave/events{/privacy}","received_events_url":"https://api.github.com/users/thomasmoelhave/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-08-28T20:19:30Z","updated_at":"2016-09-02T12:16:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/openlayers/ol3/pulls/5795","html_url":"https://github.com/openlayers/ol3/pull/5795","diff_url":"https://github.com/openlayers/ol3/pull/5795.diff","patch_url":"https://github.com/openlayers/ol3/pull/5795.patch"},"body":"This patch improves the perceived performance of TileImage (e.g. WMTS) tile transitions. This patch is based on the discussion in #4455 and uses an idea from #3660 that did not make the cut for #4389. The problem it solves can be illustrated by the following timeline:\r\n\r\n1. Layer initially has dimension `x` set to 0, and everything is rendered.\r\n2. User sets `x=10` and a bunch of tile requests are issued (e.g. a number of tiles are in the LOADING state)\r\n3. User sets `x=20`, and a new bunch of tile requests are issued. The requests for `x=10` are *not* aborted by ol.\r\n4. The tiles for `x=10` start arriving from the WMTS server, however since the current key is now `x=20`, these tiles are discarded.\r\n5. User sets `x=30`, and a new bunch of tile requests are issued. Any pending requests for `x={10,20}`  are *not* aborted by ol.\r\n6. The tiles for `x=20` and straddlers from `x=10` start arriving from the WMTS server, however since the current key is now `x=30`, these tiles are also discarded.\r\n7. The user stops updating `x`, and once the `x=30` tiles arrive from the server they are rendered on the screen. Until that point, the map still showed the `x=0` tiles and this gives a bad user experience.\r\n\r\nAny rendering of the map occuring in steps 2 through 6 would use `x=0` tiles through the current interim tile mechanism. This ensures that the map does not flicker - but instead the map remains static. At step 7, we're back to an up-to-date view. If 3 and 5 are triggered by something like a slider (e.g. as in the[ WMTS transition example](http://openlayers.org/en/latest/examples/wmts-dimensions.html)), it can take several seconds for step 7 to occur if the user repeatedly updates the dimension beyond `x=30`.  Although multiple newer tiles have been requested and received from the server, those are not used.\r\n\r\nThis patch changes this behavior by displaying most recently loaded tile for a given tile coordinate. It should not change anything about what tile requests are made and how they are scheduled, it simply tries to use as many of the received tiles as possible. \r\n\r\nTo see the effect of this patch, visit the [WMTS transition example]((http://openlayers.org/en/latest/examples/wmts-dimensions.html)), and drag the slider at a relatively quick pace (if you have a very low-latency collection to the SCALGO tile server, the effect is less noticable). \r\n\r\n### Technical Details\r\n\r\nThe patch works by making interimTiles into a linked list of tiles, ordered by update time. When rendering a tile position where the tile corresponding to the current dimension value is not in the LOADED state, the list is traversed and the most recent LOADED tile is used instead. The list is repeatedly garbage collected such that no superfloues tiles are kept around. In practice the list has length < 3. Under heavy parameter changing, the state of the list is usually:\r\n\r\n1. List head: The currently wanted tile, state IDLE until scheduled. \r\n2. head+1: tiles in the LOADING state for this position (mostly only one of these is present).\r\n3. head+2: The most recent loaded tile for this position. [anything after this position is no longer relevant and are garbage collected]\r\n\r\nSince tiles can arrive out of order from the tile, the time a tile has been loaded is not the deciding factor for determining the most recent loaded tile. Instead, we introduce a global sequence counter that is incremented when a new tile is created. When comparing to loaded tiles for the same tile coordinate, the tile with the highest sequence number is the most recent. \r\n\r\nThe code is ready for review. In particular I am unsure about where to put the global sequence counter - and I am sure you will have other suggestions as well. The bulk of the code is in two new functions that manages the linked list of interim tiles, plus a sprinkling of changes that integrates the list into the renderer and introduces the sequence numbers into the tile class."},"comment":{"url":"https://api.github.com/repos/openlayers/ol3/issues/comments/244358897","html_url":"https://github.com/openlayers/ol3/pull/5795#issuecomment-244358897","issue_url":"https://api.github.com/repos/openlayers/ol3/issues/5795","id":244358897,"user":{"login":"ahocevar","id":211514,"avatar_url":"https://avatars.githubusercontent.com/u/211514?v=3","gravatar_id":"","url":"https://api.github.com/users/ahocevar","html_url":"https://github.com/ahocevar","followers_url":"https://api.github.com/users/ahocevar/followers","following_url":"https://api.github.com/users/ahocevar/following{/other_user}","gists_url":"https://api.github.com/users/ahocevar/gists{/gist_id}","starred_url":"https://api.github.com/users/ahocevar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahocevar/subscriptions","organizations_url":"https://api.github.com/users/ahocevar/orgs","repos_url":"https://api.github.com/users/ahocevar/repos","events_url":"https://api.github.com/users/ahocevar/events{/privacy}","received_events_url":"https://api.github.com/users/ahocevar/received_events","type":"User","site_admin":false},"created_at":"2016-09-02T12:16:39Z","updated_at":"2016-09-02T12:16:39Z","body":"Nice! This is almost good to go. Please consider cherry-picking b156e13f197d002fab4e7c22662d3db34da554d4, which moves the interim tile related methods to `ol.Tile`, saving a few more bytes of unnecessary code.\r\n\r\nI'll merge when you have cherry-picked."}}
{"actor":{"display_login":"ahocevar"}}