-
Notifications
You must be signed in to change notification settings - Fork 85
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
Performance issues when clearing the chart several times (ref: hotline
and almostOver
layers)
#233
Comments
Hi @mttucl
As you say, the problem could be related precisely to the fact that not all other support layers / markers are correctly removed from the map. Keep in mind that for a long time my average use case of one layer per map (and per page!) was more than enough, that's why your case it's not much tested.. Waiting for improvement pull requests |
The issue seems to be with map
.on('almost:move', (e) => this._onMouseMoveLayer(e))
.on('almost:out', (e) => this._onMouseOut(e)); Instead, it should handle any update with I also see a performance issue with Sorry, I'm not very good at this and I don't have a proper fix. My hack is with this.on('eledata_clear', () => {
map.almostOver.removeLayer(layer);
}); _updateAlmostOverHandler: function(map, layer) {
if (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {
map.almostOver.addLayer(layer);
}
} I still see a performance issue with the above but it is much better than before. |
Hi @mttucl this is exactly one of those cases where it's worth writing some automated test (as you see from the Since it's something intrinsic to this library I suggest you directly edit the code within the As for the performance issue you notice some options (eg. the Here too, to facilitate the writing of the tests, it should be enough for you to check the value returned by the following property from time to time: Object.keys(map._layers).length Just to be clear, I know that without a starting point it can seem complicated or challenging:
Have a good debugging sessions |
Hi @Raruto, I will be happy to contribute to this project. Fair warning, I'm a novice in using GitHub and have limited experience in Javascript. Is the test supposed to be in /spec folder to run In any case, I will keep debugging as I'm enjoying it and I would love to improve it. |
Hi @mttucl,
No problem, I've always kept these repositories active just to learn new things. But keep in mind my real use case is really much more mundane than anything I've published over the years, so I'm happy if someone else tries to lighten some of my work.
Frontend testing is a tricky business:
To give you an idea of the available ones, I report below some images from the article: Restructuring Frontend Testing Pyramid: alternative to Unit/Integration/E2E approach NB
Frontend testing pyramid (in short)Frontend testing pyramid (in a real world)Anyway, my advice is to take inspiration from what others (much more expert than me) have done. As you can see within this repository this subject it has never been digged that much, except for: I would just like to point out, even if it doesn't solve the problem of this issue, that in the next period it was my intention to introduce some more specific jsdoc comments (ref: Types without Typescript) In a local branch I was working on better documenting the available types for the options and the various event listeners, but even here the issue is to try to find the right compromise on code readability... The limit is your imagination |
PS just to understand the concept of "manual tests":
|
hotline
and almostOver
layers)
I meant that for your local debugging I don't recommend going the way of overriding functions which I showed you in here: #231 (comment) In this case, If you don't want to go crazy, it's much easier to locally edit the code of this library (which you can found in the /src folder) |
Hi @Raruto, Thanks for the explanation and pointers. I'm looking through the code and noticed you have a map
.on('almost:move', (e) => this._onMouseMoveLayer(e))
.on('almost:out', (e) => this._onMouseOut(e)); For |
@mttucl giving us a quick look, I think you just need to do the reverse of what is written here (ie. I don't think there is a need to create a "grouping" layer). leaflet-elevation/src/control.js Line 408 in 8681792
Ref: makinacorpus/Leaflet.AlmostOver/src/leaflet.almostover.js#L81-L97 BTW, at the moment what I think doesn't really matter, the important thing (however you intend to edit the code) is that the number of levels currently loaded in the map will always prove us what is right or wrong: // expected: Object.keys(map._layers).length == 7
controlElevation.load(...);
// expected: Object.keys(map._layers).length == 19
controlElevation.clear()
// excpected: Object.keys(map._layers).length) == 7
/* test accepted ? */ Just to make it clear, if you start taking your jsfiddle and edit it one step at a time in order to load it as a new file in the /examples folder you are already on the right track to understand how to write a test for this case (then knowing how to code / transform it in an automated test is just a next step). The closest thing I've done in the past is: examples/leaflet-elevation_multiple-maps.html (but as you can see it has never derived in an automated test ..) 👋 Raruto |
Hi @mttucl, here 88cfa11 you can see a starting point on how start coding some "end to end" tests. You can try the code of that pull as follows: npm i
npm run test For the first times, it could be better if you use playwright through the graphical interface: npm i
npx playwright test --ui For more info:
While hoping someone else joins forces.. 👋 Raruto |
* add `edgeScale` option * prevent multiple control instantiations * add `leaflet-elevation_edge-scale.html` * update examples * update versions * workaround when "rotate: true" * update default option * Update leaflet-elevation_edge-scale.html * update dev dependencies * setup some `e2e` tests Start to handle: #233 (comment) * Update leaflet-elevation.spec.ts * fix warning * add test case for: #241 * comments * sample tests integration: `uvu` + `playwright` * remove extra parameters * remove `e2e` folder * delete `spec` folder * add test case for: #241 * make use of abortcontroller to ensure killing of http server * add default `timeout` to uvu tests * Create leaflet-elevation_edge-scale.spec.js * update tests * update how develop instructions * Update leaflet-elevation_multiple-maps.spec.js * Update leaflet-elevation_multiple-maps.html * add clear button example Related to: #233 * add test file * Update leaflet-elevation_clear-button.spec.js
And here it is a new dedicated example from v2.3.0: examples/leaflet-elevation_clear-button.html Now, someone else improve the related test file.. leaflet-elevation/examples/leaflet-elevation_clear-button.spec.js Lines 1 to 44 in 382451f
|
Hi @Raruto,
I have a list of tracks and the option to add more tracks from geojsons or strings. What would be the proper way to clear a showing track and load a new one?
I made a JSFiddle example of my attempt but the issue is the more I switch between tracks, the slower the map becomes.
In your example, you add the layer and then
addData
instead ofload
the url or a string like in my case. I'm not sure if this is the issue but for my use, it is more convenient to load the json which will take care of the chart, and the layer e.g. hotline, and start/end markers.I appreciate your help with this.
The text was updated successfully, but these errors were encountered: