-
-
Notifications
You must be signed in to change notification settings - Fork 689
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 event.isSourceLoaded to reflect the state of source loading for sourcedata event #2543
Fix event.isSourceLoaded to reflect the state of source loading for sourcedata event #2543
Conversation
5ae1713
to
544a239
Compare
Note that we will release 3.0 soon. If you would like to have this in please finish the changes and request for review. |
@HarelM: yes, I would like to have this in, sure, need to add the tests now, probably need a few hours, thanks. |
…urce cache as loaded before update is called, add missing MapSourceDataType
…for sources outside the viewport
8a503a5
to
98f6c2b
Compare
just fyi - the breaking render test ( /debug/collision , pitched-rotated-debug, and ~3 other ) are known to be a bit flaky since the migration from node mocks to puppeteer, because of what I think is a race-condition, so don't mind it. |
@ambientlight , is this ready for review? |
@birkskyum: yes, it is ready for review. |
It's a bit more complicated than I expected, so I'll need a bit more time to review this, hopefully tonight. |
Can you also check the code coverage for the new code in the report here in the CI to make sure the new code is covered? |
@HarelM, @birkskyum: I've addressed comments and added remaining tests for coverage of idle emissions in canvas / image / video sources. Let me know if there are more questions here, thanks. |
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.
Thanks @ambientlight !
Fixes #2539
sourceCache.loaded()
forevent.isSourceLoaded
sourceCache.loaded()
is true, ifused
orusedForTerrain
in set to false (after source loaded)idle
sourcedatatype used in event emissions to propagate thesource_cache.loaded()
change totrue
for cases when aren't any tile loads pending: onsourceCache.update()
called when viewport is outside of source bounds, on image/video/canvassource.prepare()
Context
The goal of this change is to make sure we have a single
sourcedata
invocation withevent.isSourceLoaded
true for each source at the end after initial load and subsequent interactions that result in tile fetches. Current behavior has usedstyle.loaded()
for the value ofevent.isSourceLoaded
and this would result in whatever source tile load that comes last to have this set. Flipping themaplibre-gl-js/src/style/style.ts
Line 744 in e43e6ef
sourceCache.loaded()
is not enough because we will haveevent.isSourceLoaded
set to true after the source is ready (tilejson fetched), but prior to any tiles actually being fetched.We may only know whether the source will have tiles to fetch once the source receives transform (on update on render), and thus
source_cache.loaded()
would now require update to be called at least once on the source to be considered loaded.Additionally, because the
sourcedata
event emissions are not tied tosource_cache.loaded()
, we are not guaranteed we will actually receive the emission withisSourceLoaded
set totrue
. This applies to cases, when:sourcedata
invocations may happen prior to the firstsource_cache.update()
)image_source
,canvas_source
,video_source
that will not set the tile state toloaded
on its load, and will only set the tile state later onprepare()
onmap.painter.render()
.To compensate for this, additional
sourcedata
event invocations with sourcedatatypeidle
have been added.Launch Checklist
isSourceLoaded
true until the camera is moved to tileBounds.CHANGELOG.md
under the## main
section.