-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix invalid tile key issues when swapping rasters when region picker active #105
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
757f8b1
check if the tile exists before accessing
Shane98c 7ce2389
cleaner
Shane98c 20cae37
revert tile check
Shane98c 3d3ea9f
update usecontrols - default values, rm unfired 'load' listener
Shane98c a456b0d
cleanup line break
Shane98c 6d4c2cb
setup listener once
Shane98c d34970f
update level after initialization
Shane98c 15279ec
revert useEffect deps change
Shane98c d4e264a
move level update to initialization step
Shane98c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sooo much cleaner than the callback!!
Question: in the case that triggered the race condition where
queryRegion
runs beforeupdateCamera
(rendering a newRaster
in an existingMap
with an already activeregion
), will the tiles from the max zoom level always be fetched and queried regardless of what level the tiles actually end up rendering at?For example, if the map is at zoom ~0 but
maxZoom === 1
, will the1
-level tiles be fetched byqueryRegion
while the0
-level tile is fetched forupdateCamera
? While not a huge deal in this example, this could potentially be quite costly for pyramids with highmaxZoom
s.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm if i'm following correctly I think the
zoomToLevel
function returns the lesser of zoom vs maxzoom, which is what's used byqueryRegion
, so my understanding is that it should fetch the data for the relevant current zoom of the map, not the maxZoom. This works becausethis.zoom
has been set by updateCamera previously. There might be a possible edge case where if you're swapping out rasters while actively zooming something could get funky - but I don't think this fix makes that situation worse than it would be normally. If zoom is for some reason undefined, I thinkzoomToLevels
will return zero, so I don't see a way that we'd be fetching data for higher levels than needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I thought that we were hitting this case because
updateCamera
hadn't finished by the timequeryRegion
ran but it's actually becauseupdateCamera
can run beforeinitialized
resolves, right? And because of this we saw the real value ofthis.zoom
but an unexpected value forthis.level
inqueryRegion
?Then this all feels great, especially with the assurance that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I think that's right! we had a real zoom but
maxZoom
was undefined because we hadn't finished initializing yet so we were getting a level set based onzoom
, with no consideration formaxZoom
So another potential spot issues could arise is if there are places in updateCamera where level not respecting maxZoom could cause issues. It looks like
level
is used a few times throughout. and some bad tile keys are created, but I think the check for this.loaders[level] prevents anything from going further than that.