-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Wait to start loading source assets until onAdd
is called
#3761
Conversation
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.
In what cases did calling setEventedParent
in the source constructors fail?
sourceCache.onAdd(this.map); | ||
|
||
this._changed = true; | ||
} | ||
|
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.
Are the changes to this file significant?
…ce, set evented parent before possible racing for ImageSprite
@lucaswoj the way it has been working:
Another minor, related change I made in this PR is to pass |
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.
Looks good! I appreciate that this is blocking #3765 and want to 🚢 to keep that project moving.
Some thoughts on future refactors: (I'll tix these out seperately)
- we could make
eventedParentData
a function to eliminate any circular dependency problems Make "eventedParentData" a function rather than a static object #3777 - we could pass
map
toSource
cache as a constructor arg and moveSource#onAdd
logic into theSource
constructor now that we don't support "orphaned" sources Eliminate Source#on{Add,Remove}(map) #3350
@lbud Are you ready to merge this PR? I'd hate for a rebase conflict to emerge 😅 |
Fixes #3735 by taking advantage of the
onAdd
method to load assets/fire events. Previously we were doing those in the source constructors, and they were constructed before establishing ownership (map -> style -> source_cache -> source), meaning events fired almost immediately wouldn't bubble up to the map object — so for example, vector tile sources (loaded over network connection) would reliably triggermap.on('source.load', fn)
listeners, but canvas sources which loaded very quickly (from the same page) would not.This isn't a perfect solution, but since sources will soon undergo a pretty big overhaul… 🔨
cc @lucaswoj