Skip to content
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

Add option to use scrollBehavior:smooth to fix choppy firefox scroll when resistFingerprinting is enabled #3701

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kamkudla
Copy link

Problem: Fake timestamps are provided to Vimium when privacy.resistFingerprinting is set true in Firefox which results in choppy and unpredictable scrolling.
Solution: Added option for alternative smooth scroll using native scrollBy toggling between options smooth and instant

Fixes #3641

@kabeersvohra
Copy link

Yep ran into this issue too, could this please be merged? :)

@kabeersvohra
Copy link

@kamkudla I compiled your change in an unpacked version of the latest version of vimium and I am still getting choppy scrolling after selecting the Use alternative smooth scroll (Firefox fix) option that you added, I tried this with and without the normal Use smooth scrolling option selected, do you know why this may be?

@kamkudla
Copy link
Author

@kabeersvohra It's probably due to the new KV pair not getting set to storage unless you refresh 1) Use smooth scroll must be off 2) Make sure to press "Save Changes" in the Vimium options UI 3) Restart all previous tabs

Try Settings.get('scrollBehaviorSmooth') in console in the Vimium options page, does it return true?

@kabeersvohra
Copy link

@kamkudla yes sorry about that, this was my bad that it was clashing with the normal vimium that I had installed already. However when I try and hold down j now it moves down for a small amount, stops for half a second and then scrolls but still in a slightly jittery manner, it is much smoother than the normal setting but still not the same as the original smooth scrolling. Perhaps this is a limitation of the 'scrollBehaviourSmooth' setting?

@kamkudla
Copy link
Author

@kabeersvohra Change the scroll step size in the Vimium options to something greater like 100px or to your preference and save. It could also be your system is resource constrained, close some tabs and check again. It's scrolling smoothly on my end with the key pressed.

@kabeersvohra
Copy link

Thanks for the help, will have another go tomorrow and Let you know

@kabeersvohra
Copy link

Sorry didn't get back to you, I am still having the same issue after changing the pixel size and trying on 3 different devices, are you getting exactly the same behaviour as the normal smooth scrolling with fingerprinting on?

@kamkudla
Copy link
Author

kamkudla commented Nov 3, 2020

Go to the Vimium options page and open up the console - what does Settings.get('scrollBehaviorSmooth') return?

@kabeersvohra
Copy link

It returns true, I do notice that the scrolling is smoother than with the option off, however when I hold it, it moves for a bit, stops, and then continues, here is the output:

ezgif-2-529b19adce94

@gdh1995
Copy link
Contributor

gdh1995 commented Nov 3, 2020

Does your version require Use smooth scrolling to be disabled, when Use alternative smooth scroll (Firefox fix) is enabled?

@gdh1995
Copy link
Contributor

gdh1995 commented Nov 3, 2020

During my tests on Firefox 80 x64, Win 10, with system animation enabled, it works only when I disabled Use smooth scrolling and enabled "alternative smooth scroll", and there's still a difference: the Vimium Options page scrolled much slower in such a case, compared with "the original smooth scrolling + not resist fingerprinting".

BTW, my working around for this issue is to assume a small time period of 17ms, when two timestamps from requestAnimationFrame are same:

https://github.com/gdh1995/vimium-c/blob/7c1b595d09aef528d445cb7f25dd0261f94c0448/content/scroller.ts#L76-L80

@kamkudla
Copy link
Author

kamkudla commented Nov 3, 2020

@kabeersvohra Sounds like it could be a system issue. Behavior on my end is normal. I am on MacOS running Firefox Developer Edition 83.0b7. It could be the calling of Settings.get on every performScroll call - in order to isolate you can hardcode the value and bypass the setting. Change line 64 of content_script/scroller.js and rebuild and reinstall

const scrollArg = {behavior: Settings.get("scrollBehaviorSmooth") ? "smooth" : "instant"};

From const scrollArg = {behavior: Settings.get("scrollBehaviorSmooth") ? "smooth" : "instant"};
To const scrollArg = {behavior: "smooth"};

Use smooth scroll in the options must be off, Alternative smooth scroll doesn't matter because we're bypassing it

@kamkudla
Copy link
Author

kamkudla commented Nov 3, 2020

@gdh1995 Yes, Use smooth scroll has to be disabled for the alternative smooth scroll to work as there's a call that checks this setting and if disabled goes to 'jump scrolling'

if (!Settings.get("smoothScroll")) {
// Jump scrolling.
performScroll(element, direction, amount);
checkVisibility(element);
return;
}

Which then performs a native JS scrollBy bypassing the timing. Originally the scrollBy was hardcoded with {behavior: "instant"}. My fix is just a checkbox to change this setting from "instant" to "smooth". Although the slowness on your end and @kabeersvohra could be a system issue as it works fine on my end. Hardcoding {behavior: "smooth"} on line 64 of scroller.js could help isolate the issue.

Thanks for sharing your solution. I'll have to study the sequence a bit further. Is your scroll logic in your fork fundamentally different than this one?

@gdh1995
Copy link
Contributor

gdh1995 commented Nov 3, 2020

My animation logic is forked from this Vimium, and the scrolling step algorithm has no changes.

On my win10 laptop/PC, both Chrome and Firefox will make scrolling very slow, if {behavior: "smooth"}, and it's because smooth scrolling causes element.scrollTop change step by step, so in a middle time (like +17ms) point Vimium only gets a scroll offset of 1~2px, then a next element.scrollTo(...) in a next animation frame will stop the earlier scrolling action, and use the 2px as its new base to execute further animation - as a result, the scrollTop will be 0px, 2px, 3px, 5px, ..., so the final result will be scrolling slows down.

@quentincaffeino
Copy link

quentincaffeino commented Jan 28, 2022

Thanks for the PR.

I think this is a good PR but it lacks in being generic. Scroll behavior is also supported by other browsers and should generally have better performance than custom. Wouldn't it be better to call it just Native smooth scroll and use it by default when it is available, ie:

'scrollBehavior' in document.documentElement.style

If not - fallback to old custom smooth scrolling.

Edit: Using native smooth scroll when available will also probably fix: #3225

@philc philc changed the title added option to fix choppy firefox scroll Add option to use scrollBehavior:smooth to fix choppy firefox scroll when resistFingerprinting is enabled Sep 17, 2023
@philc
Copy link
Owner

philc commented Sep 17, 2023

Rather than adding another option for Firefox which interacts with Vimium's existing smooth scrolling option, it would be nice if we could always use the browser's smooth scrolling behavior. I've opened #4306 for discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In Firefox, smooth scrolling is very choppy when "privacy.resistFingerprinting" is set to true in about:config
5 participants