-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add idle & [PLACEHOLDER NAME] events [DO NOT MERGE] #1904
Conversation
@@ -42,6 +42,7 @@ function Style(stylesheet, animationLoop) { | |||
var loaded = function(err, stylesheet) { | |||
if (err) { | |||
this.fire('error', {error: err}); | |||
console.info('error'); |
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.
please, remove this console log
@blythest can you please squash into one commit? |
989bdd7
to
c08d003
Compare
c08d003
to
dbf9562
Compare
Weirdly, mentioning the issue # in the title of the PR doesn't do all the GitHub metadata magic. It has to be in a commit message or the body of the PR fixes #1715 |
@lucaswoj github will track an issue reference in the subject line of a commit or PR, although it's a practice I personally don't care for. In this case, it wasn't linked because the |
if (this.loaded()) { | ||
this.fire('tiles.loaded'); | ||
} | ||
} |
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 a good strategy for triggering the event. this.loaded()
also deals with sprites, therefore:
- We should do a similar check on the sprite
load
event. There are pathological cases were we might miss firingtiles.loaded
because some icons or glyphs were pending. tiles.load
isn't the best name because this event also indicates something about sprite state (and maybe should be extended to indicate the state of image and video assets in a later PR). See Decide on terminology for map loading states DEPRECATED-mapbox-gl#5 for a discussion in naming. (I'm strongly against any word that's a direct synonym of "load" but I defer to your judgement call.)
Ah! Didn't know that @scothis. Thanks! 🙇 |
We should also try to find a way to test this feature. |
|
This doesn't touch any browser events, just |
f66246f
to
6881f1d
Compare
@@ -63,7 +63,7 @@ function Style(stylesheet, animationLoop) { | |||
|
|||
if (stylesheet.sprite) { | |||
this.sprite = new ImageSprite(stylesheet.sprite); | |||
this.sprite.on('load', this.fire.bind(this, 'change')); | |||
this.sprite.on('load', this.fire.bind(this, ['change', 'sprites.quiesce'])); |
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.
The goal of #1715 is to fire a quiesce
event on the Map
object when both the sprites and the tiles have "quiesced" (there are no outstanding network requests for any sprites or tiles).
Here, you're correctly firing an event when the sprites "quiesce" but we want the event to fire when both sprites and tiles have "quiesced", as indicated by the this._loaded()
method (which should really be renamed to this._isQuiesced()
now)
this.sprite.on('load', this.fire.bind(this, 'change'));
this.sprite.on('load', function() {
if (this.loaded()) {
this.fire('quiesce');
}
});
66f69fe
to
d2e9bb3
Compare
…nts. Added test to fail on quiesce event when style does not load. Added single event to fire when tiles and sprites quiesce.
d2e9bb3
to
2715a52
Compare
@kelvinabrokwa @ansis How does this look to you? |
Looks good to me! This also needs documentation, right? something like mapbox-gl-js/js/ui/interaction.js Lines 213 to 221 in 25b02a0
|
Are we locked-in on the name quiesce? I think there are strong points against it: It doesn't properly describe the event:
The Wikipedia page on quiesce uses it as an active verb, as something done to a process rather than the process arriving in a state.
The wordnik definition describes something very different from this - we're looking for an event that signifies completion, not quietness. The triple-vowel combo-plus-rareness in quiesce is almost guaranteed to incur support load for users listening to the I think the words |
No the name is not locked in.. My main issue with it is that it places additional burden on us to explain to developers what it means. ("guaranteed to incur support load" is my new favorite phrase). My imperfect understanding is that users want an event that fires when all the visible tiles are finished being processed. For clarity I like events like |
I agree about the name, I pretty much never heard that word before as a non-native speaker, unlike widely used words like |
We decided to go ahead and implement the code while discussions about the name continue. Quiesce isn't a good name. If we can build consensus around any particular word, I'm happy to .
(on the plus side, |
Remaining Steps
|
I'm 👍 on Have we thought about whether it should be fired when an animation completes, even if that animation doesn't trigger additional loads? I would kind of expect it to. |
Ok,
By "animation" do you mean If the latter, I've listed "the event should fire when a style changes but does not new external assets" as a "Next Step" above. @scothis any comments, as the original author of this issue? |
I would expect an event named
|
Also:
|
@lucaswoj what do you means above by 'the event should fire when sources load, not tiles'? The original use case was knowing when all the tiles for a source had loaded, so it could be displayed all at once without seeing individual tiles load. I wouldn't worry about the animation delay from setting a style property. In the case of flyTo, it will be fetching data tiles, so we're also covered. For example:
|
There is no guarantee that |
I meant covered as in it doesn't matter for the use case I outlined. If there are other use cases where it does matter then by all means. I care more that the sources are idle fetching data. Whether or not the map is repainting isn't as interesting. If we care about both cases, they should probably be separate events. |
In retrospect, this is a mistake. I was thrown off by |
Ok, then I'm back to preferring |
Let's rescope this PR to include both events
|
"no pending network loads" - how about 'downloadComplete' ? Whatever it ends up being, definitely think it is a useful event to have. |
This is a little stale. We should finish it off but I'm closing for now. |
@kelvinabrokwa @lucaswoj @scothis Ready for review. Thx!