perf: throttle WMS playback requests to prevent overlapping GeoServer tile rendering - #229
Merged
Merged
Conversation
OpenLayers does not cancel pending tile requests when updateParams() is called, so a date change every playback tick left GeoServer rendering tiles the frontend discards. Track in-flight tiles via tileloadstart/tileloadend/tileloaderror on the TileWMS source. Date changes that arrive while tiles are loading are coalesced into the latest date and applied once the source goes idle, which paces requests to the server's rendering capacity without touching the Timeline components or the 2.5s interval. A 10s guard applies the pending date anyway if a tile load event never arrives, so a stuck request cannot stall playback for the layer.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Throttling date changes inside the WMS layer alone decoupled the map from the playback clock: the slider and date label advanced every 2.5s while the map held back and then jumped, skipping the coalesced dates. Advance the timeline only once the map source is idle. The WMS layers publish their in-flight tile state to a Jotai atom, and both timelines step through usePacedTimelineStep, which waits for that state to clear and counts load time towards the interval, so the cadence is max(2.5s, tile load time) and no date is skipped. The layer-level coalescing stays as a safeguard for date changes that do not come from playback, along with its 10s guard, which now also releases the loading flag so a missing tile event cannot stall the timeline. This touches the Timeline components, which OEMC-443 ruled out, because coalescing at the layer while the clock keeps running cannot keep the slider and the map on the same date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
During timeline playback the map called
updateParams({ DIM_DATE })on every tick (2.5s), regardless of whether the previous batch of tiles had finished. OpenLayers does not cancel in-flight tile requests onupdateParams(), so GeoServer kept rendering tiles the frontend then discarded — wasted server work whenever the server ran slower than the playback interval.Two commits, and the second one is the important one.
perf: throttle WMS date changes against in-flight tilesimplements the ticket as written:src/components/map/layers/buffered-tile-wms.tsxcounts in-flight tiles viatileloadstart/tileloadend/tileloaderror, and a date arriving while tiles load is stored and applied once the source goes idle, coalescing several ticks into one request.On its own that fixes the server load but makes playback stutter. The Timeline advances the date every 2.5s unconditionally, so the clock and the map decouple: the slider and date label keep moving while the map holds and then jumps, the coalesced dates never render, and the value tooltip (which reads
datefrom state, not from the source) shows a date the map is not displaying.perf: pace timeline playback on map tile readinessfixes that by making the clock wait for the map:mapTilesLoadingAtom(src/app/store.tsx), keyed per instance, derived intoareMapTilesLoadingAtom.usePacedTimelineStep(src/hooks/timeline.ts) instead of a bareuseInterval. A step is held while tiles are loading and fires as soon as they settle; time already spent loading counts towards the interval, so the cadence ismax(2.5s, tile load time).The layer-level coalescing stays in place as a safeguard for date changes that do not come from playback (manual scrubbing, tick clicks). Its 10s guard (
PENDING_DATE_TIMEOUT) also releases the loading flag, so a tile whose load event never arrives cannot stall the timeline.Deviation from the ticket: OEMC-443 asks for the change to be isolated to
buffered-tile-wms.tsxwith the Timeline untouched. That constraint is what produced the stutter — coalescing at the layer while the clock keeps running cannot keep the slider and the map on the same date. Noted on the ticket.Designs
N/A
Testing instructions
/explore, activate a layer with a time dimension, open DevTools → Network, filter byGetMap.DIM_DATEbatch only starts after the previous one settles, no interleaving.Not verified at runtime by the author.
Feature relevant tickets
OEMC-443
Checklist before submitting
develop.deploying to staging/production, please add brief testing instructions
to the deploy checklist