-
-
Notifications
You must be signed in to change notification settings - Fork 756
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
VectorTileWorkerSource: change reloadTile behavior to reload right away instead of waiting for previous parse to complete #1874
Conversation
Bundle size report: Size Change: +17 B
ℹ️ View Details
|
Thanks for taking the time to fix this!! |
5ad7f83
to
ae4db96
Compare
@HarelM: done, thanks a lot! |
@ambientlight thanks! see me new comments. Sorry for the ping-pong... |
@HarelM: thanks for the review, let me know if all your questions are addressed now |
@ambientlight do you want to push thie PR forward or close it? |
@HarelM: yes, thanks for reminding this |
31c012a
to
c562c67
Compare
Please let me know when this is ready to review again. |
@HarelM: I am still on this, but I am having difficulties figuring out a consistent repro again, I can only catch the original issue with sprites not loading if I use custom images via MapLibre.GL.JS.debug.page.mp4I guess this is not really a blocker unless we need a render test here |
@ambientlight @HarelM Hello to everyone. Sorry for slipping out of this, got distracted with other things to do, then vacation and so on and so on... |
@smellyshovel: nothing on your end actually, I was just curious if by some chance you still have the repro siting somewhere from the PR you have completed last year (#1805 (comment)) |
@ambientlight then I'm afraid I won't be of much help here. Definitely don't have anything from half a year ago on my machine now :( |
@ambientlight on the other hand I remember roughly the state of the project when I took the video you mentioned in the OP. UPD. |
@smellyshovel: thanks a lot, I found the demo page you used in your video in that commit, (though the repro is same flaky) |
@HarelM: after investigating further, I don't think there is anything to add to this PR actually. For context: we have discussed the issue where when multiple maplibre-gl-js/src/source/geojson_source.ts Line 404 in 2a63bff
maplibre-gl-js/src/source/source_cache.ts Line 275 in 2a63bff
If I understand this correctly, in this case the lost callback inside web worker doesn't cause the problem on the main thread since the last callback will hit the eventual If we would actually event on all callbacks like: /**
* Parses worker tile and invokes all pending reload callbacks.
*/
_parseTileAndConsumeReloadCallbacks(workerTile: WorkerTile) {
const reloadCallbacks = workerTile.reloadCallbacks;
if (reloadCallbacks) {
delete workerTile.reloadCallbacks;
workerTile.parse(workerTile.vectorTile, this.layerIndex, this.availableImages, this.actor, (err, data: WorkerTileResult) => {
for (const reloadCallback of reloadCallbacks) {
reloadCallback(err, data);
}
});
}
} we would run into problem, since we would need to copy the data returned, since the ownership of ArrayBuffers, etc. in Let me know what you think. |
The last comment I wrote here: #1874 (comment) was talking about moving some logic into the worker tile class. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1874 +/- ##
==========================================
+ Coverage 73.97% 74.48% +0.50%
==========================================
Files 238 238
Lines 18996 19002 +6
Branches 4281 4284 +3
==========================================
+ Hits 14052 14153 +101
+ Misses 4944 4849 -95
☔ View full report in Codecov by Sentry. |
@HarelM: ou, missed that, let me clarify something first:
So my prior comment there was not exactly about the callbacks but the fact that when reloadCallback is set, we essentially wait for dependencies at https://github.com/maplibre/maplibre-gl-js/blob/main/src/source/worker_tile.ts#L141:L177 to fetch, perform maybePrepare and then we reparse again. Maybe there was a reason for that (like not doing it aggressively on every reloadTile call, but instead swapping callbacks and doing it once in the end), but let me check what if we reparse right away and cancel in-flight |
Ok, waiting on your check in order to merge this. |
@HarelM: pushed this 'idea', let me know what you think here. note, we may incur higher loads in web worker, if |
I think this looks good in general - the worker tile is self contained generally. |
@HarelM: done, 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!!
…ay instead of waiting for previous parse to complete (#1874) * reloadCallback needs to be checked in loadTile * add test that would verify reloadCallback and parse called appropriately * add changelog entry and lint fix * remove unncessary tile read * use jest.spyOn for mocking of WorkerTile.parse * fix changelog * rem rebase remnants * eliminate reload callback - reparse instead and cancel or drop dependency requests in flight * lint fix, remove unit tests that no longer apply * add worker_tile tests
… view with negative elevation (#2858) * Add min elevation parameter to transform * Fix lint, failing test * Fix build tests * Fix build test * Fix terrain edge case where elevation is negative for camera but not for tile. * Fully fix the problem with min elevation * feat: update supported example (#2859) * feat: update supported example * feat: add changelog * feat: add cooperated gestures example (#2860) * feat: add cooperated gestures example * fix: update coopertiveGestures config * fix: changelog * Remove cooperative gesture screen from accessibility tree (#2857) * Remove cooperative gesture screen from a11y tree * Add changelog item * Add unit test which makes sure that cooperative gesture container element is hidden from a11y tree * Improve documentation on Map and Camera classes (#2863) * typedoc cleanup * Fix comment formatting * Lint fixes * Remove incorrect event doc * Replace tables with simple lists * Fix lint * Remove tables * Remove unwanted file * Fix build test * Added a test to make sure it won't break in the future * Added unit test * Updated change log * Bump @maplibre/maplibre-gl-style-spec from 19.2.1 to 19.2.2 (#2867) * Remove unused 'name' parameter (#2872) * Bump @rollup/plugin-commonjs from 25.0.2 to 25.0.3 (#2873) Bumps [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/HEAD/packages/commonjs) from 25.0.2 to 25.0.3. - [Changelog](https://github.com/rollup/plugins/blob/master/packages/commonjs/CHANGELOG.md) - [Commits](https://github.com/rollup/plugins/commits/commonjs-v25.0.3/packages/commonjs) --- updated-dependencies: - dependency-name: "@rollup/plugin-commonjs" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump pretty-bytes from 6.1.0 to 6.1.1 (#2875) Bumps [pretty-bytes](https://github.com/sindresorhus/pretty-bytes) from 6.1.0 to 6.1.1. - [Release notes](https://github.com/sindresorhus/pretty-bytes/releases) - [Commits](sindresorhus/pretty-bytes@v6.1.0...v6.1.1) --- updated-dependencies: - dependency-name: pretty-bytes dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @types/jest from 29.5.2 to 29.5.3 (#2878) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.5.2 to 29.5.3. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @types/react from 18.2.14 to 18.2.15 (#2881) Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.2.14 to 18.2.15. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) --- updated-dependencies: - dependency-name: "@types/react" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump devtools-protocol from 0.0.1167732 to 0.0.1170846 (#2883) Bumps [devtools-protocol](https://github.com/ChromeDevTools/devtools-protocol) from 0.0.1167732 to 0.0.1170846. - [Changelog](https://github.com/ChromeDevTools/devtools-protocol/blob/master/changelog.md) - [Commits](ChromeDevTools/devtools-protocol@v0.0.1167732...v0.0.1170846) --- updated-dependencies: - dependency-name: devtools-protocol dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump eslint-plugin-jest from 27.2.2 to 27.2.3 (#2884) Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 27.2.2 to 27.2.3. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](jest-community/eslint-plugin-jest@v27.2.2...v27.2.3) --- updated-dependencies: - dependency-name: eslint-plugin-jest dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump eslint from 8.44.0 to 8.45.0 (#2879) Bumps [eslint](https://github.com/eslint/eslint) from 8.44.0 to 8.45.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](eslint/eslint@v8.44.0...v8.45.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * VectorTileWorkerSource: change reloadTile behavior to reload right away instead of waiting for previous parse to complete (#1874) * reloadCallback needs to be checked in loadTile * add test that would verify reloadCallback and parse called appropriately * add changelog entry and lint fix * remove unncessary tile read * use jest.spyOn for mocking of WorkerTile.parse * fix changelog * rem rebase remnants * eliminate reload callback - reparse instead and cancel or drop dependency requests in flight * lint fix, remove unit tests that no longer apply * add worker_tile tests * Bump postcss from 8.4.25 to 8.4.26 (#2880) Bumps [postcss](https://github.com/postcss/postcss) from 8.4.25 to 8.4.26. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.4.25...8.4.26) --- updated-dependencies: - dependency-name: postcss dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @types/node from 20.4.1 to 20.4.2 (#2877) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.4.1 to 20.4.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump puppeteer from 20.8.0 to 20.8.2 (#2882) Bumps [puppeteer](https://github.com/puppeteer/puppeteer) from 20.8.0 to 20.8.2. - [Release notes](https://github.com/puppeteer/puppeteer/releases) - [Changelog](https://github.com/puppeteer/puppeteer/blob/main/release-please-config.json) - [Commits](puppeteer/puppeteer@puppeteer-v20.8.0...puppeteer-v20.8.2) --- updated-dependencies: - dependency-name: puppeteer dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/parser from 5.61.0 to 5.62.0 (#2876) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.61.0 to 5.62.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.62.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix broken links (#2888) * Bump word-wrap from 1.2.3 to 1.2.4 (#2890) Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](jonschlinkert/word-wrap@1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix changelog * Code review fixes * Code review fixes * Fix lint * Fix build size * Fix refactoring in tests * Rename method according to code review --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: visitskyworld <96882365+visitskyworld@users.noreply.github.com> Co-authored-by: Manuel Roth <manuel.roth@srf.ch> Co-authored-by: Brian Sperlongano <zelonewolf@gmail.com> Co-authored-by: Karol Leśniak <16785518+kajkal@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Taras Vozniuk <primary.taras.vozniuk@gmail.com> Co-authored-by: JabSYsEmb <32222578+JabSYsEmb@users.noreply.github.com>
As pointed out in #1805 (comment), the issue occurred where after adding a geojson source, a bunch of symbol layers and new spritesheets in a
load
callback, the sprites would be not shown for geojson's source tiles already loaded (which are loaded before the sprites are loaded), as a result of tiles not being reparsed:maplibre-gl-js/src/source/worker_tile.ts
Line 64 in 870c2a3
not getting called inside the web-worker and so the
maplibre-gl-js/src/source/worker_tile.ts
Line 169 in 870c2a3
This issue would not happen if browser have cached sprite assets, hinting on some async behavior weirdness. Tracing the flow of
maplibre-gl-js/src/style/style.ts
Line 503 in 870c2a3
happened to show that
maplibre-gl-js/src/source/vector_tile_worker_source.ts
Lines 157 to 167 in 870c2a3
parsing
state would not fire. This happened because the workerTile.reloadCallback would only happen if theworkerTile.parse
(that sets the status toparsing
) would itself be called fromreloadTile
, but would not from its ownloadTile
logic that could happen prior to thisreloadTile
call.This PR fixes that by checking the reloadCallback inside the
loadTile
'sworkerTile.parse
callback.UPDATE: 2023/07/15
reload callback has been eliminated per conversation in favor of reloading right away and cancelling in flight dependency sprite / glyphs dependency loading during parse at https://github.com/maplibre/maplibre-gl-js/blob/main/src/source/worker_tile.ts#L141:L177.
Launch Checklist
CHANGELOG.md
under the## main
section.