-
-
Notifications
You must be signed in to change notification settings - Fork 789
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
Lagging when zooming in/out of the map (especially with free rolling mouse wheel) #4362
Comments
I doubt there's a (easy) solution to this issue. |
This is what I have so far:
Next I will investigate if there are more renders happening during a single frame received from |
The cause of the lag is an issue in the easing functionality in the scroll_zoom.ts. Will investigate further. |
Figured it out! maplibre-gl-js/src/ui/handler/scroll_zoom.ts Lines 293 to 302 in 0327486
When the mouse scroll wheel is rotating fast the value of The fix that I found is the following: let t = Math.min((browser.now() - this._lastWheelEventTime) / 200, 1);
if (startZoom !== targetZoom && t === 0) {
t = 0.1;
} Number This only affects fast wheel rotation so no other zoom methods nor regular (stepped) wheel rotation is affected. I will prepare a PR with this fix. Pinging @anandthakker as he wrote the original code. |
Why is it 0? last wheel and browser.now are the same? |
Yes, they are the same. This is the log of me spinning the mouse wheel. You can see that most of the time the difference is 0. When I slow the wheel down at the end we can see the diff increase. |
Feel free to open a PR, I'll be happy to review it. |
* fix lag when zooming in/out fast #4362 * add changelog * rework fix, add test --------- Co-authored-by: Antonio Kovačević <[email protected]> Co-authored-by: Harel M <[email protected]>
Apologies for commenting on a closed issue, but I am still experiencing this issue in Chromium based browsers; zooming in and out using the mouse scroll wheel feels super choppy, unless the developer tools are open (this behavior is noted above in here, hence I believe it must point to the same issue). It appears that v4.5.1 did include the fix relating to this bug (hence the issue is closed and marked as completed), so I am not sure how/why it persists on my end. I have tested this on v4.5.1 locally and in production for personal projects and the bug is present in all. Here is a replication of the original example above from https://maplibre.org/maplibre-gl-js/docs/:
vid1.mp4
vid2.mp4
vid3.mp4Is there any chance that the fix above was not wholly implemented and/or included in the latest NPM version properly? |
The PR was merged on Jul 1. The release of 4.5.1 was done on Aug 1. |
This sentence from PR #4366 is relevant, as I am also using an MX Master 3 mouse with stepped scroll on – using a regular mouse does not exhibit this laggy behavior. That said, Firefox and Safari do not have this lagginess when using an MX Master 3, but Chrome does; would this be a Chromium issue rather than a maplibre one? |
Sounds like a Chrome issue to me... |
Same here, but still unclear as to why having the dev tools open fixes the issue on Chrome... |
@firatciftci have you managed to solve the issue? I also see stuttering when zooming on latest 4.5.2 version. Moreover, when I downgrade to 4.5.0, it's gone. Here is a smooth scroll: And here are some random zoom jumps on latest version: |
@Monstrofil I haven't had the time to look more into it yet – are you also using an MX Master 3? I can confirm that reverting back to 4.5.0 fixes the issue. @HarelM, as counterintuitive as it may sound, it might make more sense to revert the 'fixes' in PR #4366 – the changes in src/ui/handler/scroll_zoom.ts seem like a real regression in scroll zooming for certain mouse types. It might make sense to re-open this issue, and I will get to work on filing a new PR to see what I can do to address this once-and-for-all. |
Feel free to submit a PR that reverts this fix. |
No, just a generic A4tech mouse. |
I'm experiencing the same issue on chrome with a Logitech G403 |
I am also having the same issue on version 4.7.1, Lagging when scrolling with mouse on chrome, especially on higher zoom levels (>8). Issue is resolved when dev tools are open. Interestingly the built it |
I make a custom scroll method implementation that works better for me than the default one, also it works across browsers. Its not as butter smooth as google maps but hey if anyone has any ides how to improve it met me know `
|
Same issue here with 4.7.1. Reverting to 4.5.0 fixes it. macOS on a M1 mac, Chrome, Logitech G Pro X Superlight (non-free rolling). |
I'm not experiencing any of these issues, but if you think the latest fix should be reverted I suggest to make sure the original issue that was reported does not return. |
I've also been experiencing these same issues with mouse scroll not being smooth since 4.5.1. I believe I have identified the issue, and can reliably reproduce on chrome and Firefox using a regular mouse wheel. I've tried 3 different mouses with regular stepped scroll wheels and they all trigger this issue. The issue frequently occurs when a 2nd scroll event happens immediately after the previous has finished. This happens on quick mouse scroll into or out of a map with multiple scroll wheel actions, and is also easily triggered if the stepped mouse wheel is scrolled beyond it's bump. When this 2nd scroll event occurs, 'browser.now()' and _'this.lastWheelEventTime' are often the same value. In this case, 'lastWheelEventTimeDiff' gets set to 0 on line 307 of scroll_zoom.ts. Then, immediately after on line 308, 'lastWheelEventTimeDiff' is falsy and the easing block is skipped, and 'zoom' is immediately set to 'targetZoom' on line 321, causing the immediate jump in zoom level and stuttering affect. maplibre-gl-js/src/ui/handler/scroll_zoom.ts Lines 307 to 323 in 87486a5
Removing the 'lastWheelEventTimeDiff' check resolves the issue, but would re-introduce the original problem for free rolling mouse wheels. |
Please read through the this thread and the relevant PR. @Codebreaker101 can you help out here to resolve this? |
I've now got a free scrolling mouse and have been working on this. I have a fix which reverts back to 4.5.0 behavior and also addresses the free rolling wheel issue. In Chrome it's now very smooth regardless of mouse type / scroll speed. I'd say the fast scroll zoom performance between Firefox and Chrome is now about the same. scrollFix.mp4I need to look into writing test(s) and then I would like to submit a PR for review please? @HarelM |
Sure, I'll be happy to review a proper fix to this issue, thanks for looking into it! |
maplibre-gl-js version: v4.5.0
browser: Chromium (Version 126.0.6478.126 (Official Build) (64-bit)) and their derivatives
Steps to Trigger Behavior
Link to Demonstration
Laggy Chromium:
chromium.mov
Smooth Firefox:
firefox.mov
Expected Behavior
For smooth zooming to be the same as in Firefox browser
Actual Behavior
Lagging when zooming in Chromium
The text was updated successfully, but these errors were encountered: