[Maps] Keep track of tile loading state #90970
Closed
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.
WIP - POC
Closes #76237
[UPDATE] Second approach: 5f37ebc
This keeps explicit track of the life-cycle of each tile in a separate data-structure (
this._tileCache
)sourcedataloading
: a tile load event is started (this is internal to mapbox, doesn't even correspond to actual network request) -> add to the cacheerror
: a tile load failed (e.g. due to503
from server) -> remove from the cachesourcedata
: a tile load event succeeded -> remove from the cacheThis also needs to explicitly erase aborted requests, when tile-loading-state is determined. An aborted request does not have an associated event associated with it (
aborted
state can be acccessed through internal property).First approach: fb5d418
This listens to
sourcedata
events, and checks source tile status withMbMap#isSourceLoaded(sourceId)
MbMap#isSourceLoaded(sourceId)
seems buggy, or at least, does not entirely behave as expected. Most notably, it will returntrue
when there are pending requests. This starts to happen after the layer has had many failed tile-request (e.g. because server does not support zoom level).Can test with
http://c.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg
http://c.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg
Will need to see if there's a better approach (e.g. hooking into lifecycle of individual tiles, keeping track of requested tiles and success/errors on per layer basis).