-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
map.isSourceLoaded(...) may return true while a GeoJSON source is still loading #669
Comments
I think the problem lies in the maplibre-gl-js/src/source/geojson_source.ts Line 286 in d5d4e1d
The The problematic sequence is:
|
This is an interesting analysis, thanks for sharing! |
No problem, and yes, it seems to be a race condition on |
Based on the following unit test, it looks like the pending call is always expected to run to completion; only calls that have not yet started loading are abandoned when a new call is made: maplibre-gl-js/test/unit/source/geojson_worker_source.test.js Lines 225 to 245 in b2c300a
Based on that, should we show data from the previous pending call when it gets loaded while data from the latest one is still loading? In other words, should we show stale data from the previous |
I believe we should present data from previous call to setData until a new data is ready, this is at least what I would expect. |
Sounds good. Thanks! |
Fixed by #684 |
re: #669 (comment), do you think it could be worth adding a configuration option to GeoJSON sources that prevents stale data from being shown? It could be disabled by default. Our use case is that we call |
Personally, I would like to avoid complicating geojson with this kind of options... I'm not even sure where would one place such configuration option... |
We tried doing the following: // First query
GeoJSONSource.setData(url1);
// Second query (url1 is still loading)
GeoJSONSource.setData({type: "FeatureCollection", features: []});
GeoJSONSource.setData(url2); Unfortunately, the maplibre-gl-js/src/source/geojson_worker_source.ts Lines 132 to 135 in ddc348f
|
What about removing and re-adding the source in order to abandon the current call and remove the data? |
I'd need to try it... My concern with that solution however is that, unless I'm wrong, all layers that use the source will need to be removed and re-added. While it's certainly possible to do that, it seems a bit cumbersome. |
1.15.2:
Steps to Trigger Behavior
After the
map.load
event has fired, callGeoJSONSource.setData(...)
twice, the first time passing a URL to a small GeoJSON file and the second time passing a URL to a large GeoJSON file.Link to Demonstration
https://jsbin.com/colaxiboka/2/edit?html,output
Expected Behavior
map.isSourceLoaded(...)
should returnfalse
until the file specified in the lastGeoJSONSource.setData(...)
call has finished loadingGeoJSONSource.setData(...)
Actual Behavior
map.isSourceLoaded(...)
returnstrue
between the times the files specified in the twoGeoJSONSource.setData(...)
calls finish loadingGeoJSONSource.setData(...)
call and the time the second file finishes loadingThe text was updated successfully, but these errors were encountered: