Skip to content
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 Map#areTilesLoading from not returning true on final sourcedata event #4987

Merged
merged 4 commits into from
Jul 20, 2017

Conversation

mollymerp
Copy link
Contributor

@mollymerp mollymerp commented Jul 17, 2017

Fixes #4975

When tiles are reloading they don't fire a sourcedata event when they finish loading unless debug collision boxes are enabled (https://github.com/mapbox/mapbox-gl-js/blob/master/src/source/tile.js#L232 🤔 )

this approach changes the areTilesLoaded check to accept reloading tiles as loaded, but an alternative approach could be removing the conditional in tile.js linked above so that a sourcedata event would be fired when all reloading tiles switch back to loaded.

cc @ksummerill

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@mollymerp mollymerp requested a review from anandthakker July 17, 2017 21:29
@anandthakker
Copy link
Contributor

so that a sourcedata event would be fired when all reloading tiles switch back to loaded

I would lean towards this approach, because of the use case where someone does setData() and then wants to know when the new data is loaded/rendered.... but that's a pretty mysterious conditional 😬

@mollymerp
Copy link
Contributor Author

yeah – I think that makes sense @anandthakker and it doesn't seem to break anything 🤞
finding this tough to test though 💭

@anandthakker
Copy link
Contributor

anandthakker commented Jul 19, 2017

@mollymerp On a second look, I'm thinking it's non-ideal to be firing this event via Tile#_immediateRedoPlacement. Do you know why this line in SourceCache doesn't already give us the sourcedata event we need?

@mollymerp
Copy link
Contributor Author

@anandthakker it does fire the event, areTilesLoaded won't be true yet for tiles where tile.redoWhenDone=true because https://github.com/mapbox/mapbox-gl-js/blob/master/src/source/vector_tile_source.js#L135 sets the tile's state to reloading and kicks off the async reloading, so it's not loaded when the sourcedata event fires. We could potentially invoke _tileLoaded when a tile finishes reloading though 💭

@anandthakker
Copy link
Contributor

Ohhhh, I see 🤦‍♂️ . In that case, I withdraw my previous comment -- since it's Tile that's responsible for invoking the redoPlacement action, it does make sense for it to fire the associated events.

@mollymerp
Copy link
Contributor Author

ready for your 👓 ✅ @anandthakker !

Copy link
Contributor

@anandthakker anandthakker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

One very small nitpick inline

const tile = new Tile(new TileCoord(1, 1, 1));
tile.loadVectorData(createVectorData(), createPainter());
t.stub(tile, 'reloadSymbolData').returns(null);
const options = util.extend(new Evented(), {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we call this source rather than options?

@mollymerp mollymerp merged commit caf4cfb into master Jul 20, 2017
@mollymerp mollymerp deleted the areTilesLoaded-fix branch July 20, 2017 17:27
@volkanunsal
Copy link

This is still happening.

@ryanhamley
Copy link
Contributor

@volkanunsal if you're still seeing this happening, can you please open a new issue with a minimal reproduction of the problem so that we can better diagnose it? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants