-
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
Animations of circle layer extremely sluggish in version 1.30 #8701
Comments
@thunderkid oh no! This is likely because of changes in #8633 and #8673. Can you provide a minimal live (e.g. JSFiddle) test case? That would make it much easier to get to the bottom of this and do a quick fix. |
@thunderkid I tried to create a reproducible example based on your description. Here are the fiddles: However, the general best-practice when animating is to call @mourner @asheemmamoowala , not sure if this is a release-blocker, given it might be a bad implementation. |
@arindam1993 I'm afraid I can't get your fiddles to tell me much - the last one doesn't load at all. My animation is a bit more complex than yours. For each event I add a circle with text in the center, and over ~1 second it expands by a factor of ~1.5 and simultaneously fades, then disappears. It looks nice and smooth on It's a fairly complex project so hard for me to produce a small fiddle for it. I was hoping someone else would have something smaller and cleaner for stress testing. I could probably produce a couple of animated gifs to show you what it looks like, but the degradation is pretty bad! |
@thunderkid animated gifs would be a good start. Can you say more about how many circles are in your source, and how frequently the events occur that add circles? How many layers are referring to the source, and what is the complexity of the expressions in the layer properties? |
@asheemmamoowala In this example I'm adding 1000 circles over a 10 second interval. Each circle expands for 0.5 seconds, then fades for 0.4 seconds. So on average around 100 circles are active at any moment. There are two layers referring to the data source - a text layer which doesn't do much:
and a circle layer which gets the radius and opacity which are dynamically driven by the animation of the data source, updated by
Hope that helps. |
I've created a similar fiddle based on earthquake data: I've tried this in Firefox 70, Chrome 76, and Safari 12, all on 4-core Macbook 15" running macOS, but was unable to spot any differences. They all get sluggish after a few seconds, but I can't tell that 1.2.1 is less sluggish than 1.3.0. @thunderkid, are you able to share a reduced test case with actual code (like a jsfiddle test page) that exhibits what you're observing? |
@kkaefer: Thanks! That's a nice clean example and it runs fine on my systems too under 1.3.0. My own code uses React & Mobx and has other non-animating layers so it will take a bit of work to figure out what's interfering with the animation, but I'll try to build a simple test case. |
I fully agree with @thunderkid that 1.2.1 is less sluggish than 1.3.0 EnvironmentMacOS Catalina browsers: mapbox-gl-js version: latest turf version: jQuery: Steps to Trigger Behaviorparse large geojson files
while moving the mouse @turf/nearest-point is using: takes a reference point and a FeatureCollection of Features with Point geometries and returns the point from the FeatureCollection closest to the reference.
Actual BehaviorI've created two versions based on my project on clpa.tunayschuster.com. 1.2.1: https://clpa.tunayschuster.com/performance-test-mapboxgl_1.2.1.html Behavior less smooth than version 1.2.1. |
@sunaviation thank you so much for this great example. I can finally reproduce it locally with this example. |
I can confirm this issue. |
@mmuelder would you help us by sharing a minimal reproducible live test case? This turned out to be quite a difficult issue to crack, so the more test cases we have, the sooner we will find a solution. |
@mourner it was pretty hard but it looks like I found a test case which replicates our problem: https://jsfiddle.net/L0omq42a/11/ <- mapbox gl js v1.3.0 If I open the 1.3.0 version, the circle lags behind the camera view so far, that its basically out of view all the time. (On a Nokia 8.1. Again, on a desktop PC the difference is barely noticeable) I also found that it was apparently dependent of the map positon/zoom level. The more details/buildings/roads are visible and have to be rendered, the bigger the difference between the two versions was. |
I'm seeing this problem as well for animating a simple line layer. The map needs to be at least a few tiles to start seeing the problem. https://jsfiddle.net/erhpzwaj/ <- mapbox gl js 1.2.1 (works fine) This is a blocker for my use-case to upgrade to 1.3.0 or later. |
I can confirm it. The performance issues are not only based on the circle layers. I guess it depends to setData. While moving the mouse instance member .getSource .setData (data) is called permanently.
In the current examples only layer line is used. Draw a line between the nearest lat/lng and the mouse pointer. 1.2.1: https://clpa.tunayschuster.com/performance-test-mapboxgl_1.2.1.html <- smooth |
I've just checked against today's release of mapboxgl 1.5.0. Unfortunately this release is still very jerky. |
I think the issue is with responses getting queued up in the main thread. If I change the logic in new actor implementation to run pending callbacks synchronously, the main thread will process ~20 response messages in a single animation frame, whereas when they get deferred with Do responses need to get queued in the main thread? Do workers ever tell main thread to cancel? If not it might be sufficient to only queue them up in the workers. |
I have a potential fix in #8913 which seems to resolve the issue on my setup - could anyone who has been seeing this issue let me know if this fixes it for them: https://cdn.jsdelivr.net/gh/msbarry/mapbox-gl-js@build-fix-8701/dist/mapbox-gl.js |
You did it! - it's fixed. Everything is running smoothly as before (like mapbox gl js 1.2.1) https://clpa.tunayschuster.com/performance-test-mapboxgl_1.2.1.html <- 1.2.1 (works fine) Thanks a lot! edit: environment: |
@thunderkid you should be able to temporarily grab the |
@msbarry Yes, the sluggishness now seems to be fixed. (On chrome at least. I haven't tested safari.) |
@sunaviation: I can confirm that this mostly fixes the issue on Chrome. Both Safari and Firefox don't seem to be affected by this issue because the 1.2.1 version is already very janky and I couldn't observe a noticeable difference between 1.2.1, 1.3+, and @msbarry's patch. |
@msbarry our example seems to be fixed as well, thank you. |
I am animating the appearance and disappearance of ~2000 circles over 10 seconds using a data driven circle-layer. In version 1.2.1, this was running fine at ~35fps, with the circles updating continuously. In version 1.3.0 the circles no longer update continuously - they update in batches only about once every 2 seconds, giving a very sluggish/jerky experience. (NB: If you just look at the fps, it's now reporting ~50fps, so by that metric it's faster than before, but that's because it's no longer doing the hard work of actually updating the circles. As soon as you look at the map as opposed to the fps meter, you see how bad the performance is now.)
mapbox-gl-js version: 1.3.0
browser: Chrome 76
Steps to Trigger Behavior
Expected Behavior
Animation at least as smooth as version 1.2.1.
Actual Behavior
Animation dramatically less smooth than version 1.2.1.
The text was updated successfully, but these errors were encountered: