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

Reduce the amount scaled when using mouse-wheel zooming in Chromium-browsers (issue 16325) #16596

Closed

Conversation

Abishek-Jayan
Copy link

@Abishek-Jayan Abishek-Jayan commented Jun 24, 2023

The deltaMode value apparently defaults to a different value depending on the browser OS combo (as per w3c/uievents#181 (comment) ) . In our case I've noticed that for Chromium browsers the delta value always comes out to a value greater than the PIXELS_PER_LINE_SCALE variable. This is what causes the error. So to fix, I just put a check there and set the correct tick value accordingly. Ive tested in both Edge and Brave browsers and it seems to be working fine both in desktop view and mobile view.

This is a fix for #16325

@Abishek-Jayan Abishek-Jayan changed the title Fix for scrolling issue in Chromium browsers ( bug #16325 ) #16595 Fix for scrolling issue in Chromium browsers ( bug #16325 ) Jun 24, 2023
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I still think this feels risky and it could easily break some other configuration (and thus require follow-up patches); hence I'm unfortunately not comfortable approving this.


The PR title mentions scrolling, which seems quite confusing since the issue is regarding mouse-wheel zooming. (Also, the title should use the words (issue 16325) and not ( bug #16325 ) since the original issue was filed in GitHub and not Bugzilla.)

The commit message should have the same title as the PR, and then also contain all of the contents from #16596 (comment).

Finally, please note https://github.com/mozilla/pdf.js/wiki/Squashing-Commits since you've got an unrelated commit included.

web/app.js Outdated Show resolved Hide resolved
@Abishek-Jayan Abishek-Jayan changed the title Fix for scrolling issue in Chromium browsers ( bug #16325 ) Fix for zoom scale factor on scroll issue in Chromium browsers ( bug #16325 ) Jun 25, 2023
@Abishek-Jayan Abishek-Jayan changed the title Fix for zoom scale factor on scroll issue in Chromium browsers ( bug #16325 ) Fix for zoom scale factor on scroll issue in Chromium browsers ( issue 16325 ) Jun 25, 2023
@Snuffleupagus Snuffleupagus changed the title Fix for zoom scale factor on scroll issue in Chromium browsers ( issue 16325 ) Reduce the scale-factor when using mouse-wheel zooming in Chromium-browsers (issue 16325) Jun 25, 2023
@Abishek-Jayan
Copy link
Author

Abishek-Jayan commented Jun 25, 2023

@Snuffleupagus hmm there is one thing i dont understand... in 2782 the variable PIXELS_PER_LINE_SCALE is set as a constant 30? why? If im correct in assuming that that variable represents the number of pixels in one line, couldn't it change based on the size of the device or something?

@Abishek-Jayan Abishek-Jayan changed the title Reduce the scale-factor when using mouse-wheel zooming in Chromium-browsers (issue 16325) Reduce the amount scaled when using mouse-wheel zooming in Chromium-browsers (issue 16325) Jun 25, 2023
@Abishek-Jayan
Copy link
Author

Abishek-Jayan commented Jun 25, 2023

@Snuffleupagus
So I have found that rather than messing with the delta values, the simplest way to solve the problem would be to find a clean way to
detect if the browser was Chromium or not. I found that chromium browsers have a property called windows.chrome which on console logging,
looks something like this:

{
app: {
isInstalled: false,
InstallState: {
DISABLED: disabled,
INSTALLED: installed,
NOT_INSTALLED: not_installed
},
RunningState: {
CANNOT_RUN: cannot_run,
READY_TO_RUN: ready_to_run,
RUNNING: running
}
},
appPinningPrivate: {}
}

Whereas in firefox, logging that property returns undefined. I had searched to see if there were ways that the window.chrome property could be faked (since the navigator.userAgent could be faked) but I couldnt find anything regarding that. Whats more, Edge, Opera, Brave and Chrome all support this property as per https://stackoverflow.com/a/13348618

So the current fix just adds the windows.chrome check to the if condition at line 2762.

I had tested this functionality myself on all these browsers and they work as intended in both desktop and mobile versions.

Hopefully I got the commit message and title right this time as well

web/app.js Outdated Show resolved Hide resolved
…rowsers (issue 16325)

So I have found that rather than messing with the delta values, the simplest way to solve the problem would be to find a clean way to
detect if the browser was Chromium or not. I found that chromium browsers have a property called windows.chrome which on console logging, looks something like this:

{
        app: {
            isInstalled: false,
            InstallState: {
                DISABLED: disabled,
                INSTALLED: installed,
                NOT_INSTALLED: not_installed
            },
            RunningState: {
                CANNOT_RUN: cannot_run,
                READY_TO_RUN: ready_to_run,
                RUNNING: running
            }
        },
        appPinningPrivate: {}
}

Whereas in firefox, logging that property returns undefined. I had searched to see if there were ways that the window.chrome property could be faked (since the navigator.userAgent could be faked) but I couldnt find anything regarding that. Whats more, Edge, Opera, Brave and Chrome all support this property as per https://stackoverflow.com/a/13348618

So the current fix just adds the windows.chrome check to the if condition at line 2762.

I had tested this functionality myself on all these browsers and they work as intended in both desktop and mobile versions.

Update: Added PDFJSDev checks to ensure no unnecessary code ends up in
the built-in Firefox PDF Viewer
@Abishek-Jayan
Copy link
Author

Abishek-Jayan commented Jun 25, 2023

@Snuffleupagus now the current commit should have everything in order

@Abishek-Jayan
Copy link
Author

@Snuffleupagus hope everything is correct

@Snuffleupagus
Copy link
Collaborator

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 3

Live output at: http://54.241.84.105:8877/2390355f2565b5b/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/2390355f2565b5b/output.txt

Total script time: 1.59 mins

Published

@Snuffleupagus Snuffleupagus removed their request for review June 27, 2023 13:24
@Snuffleupagus Snuffleupagus linked an issue Jun 27, 2023 that may be closed by this pull request
@Snuffleupagus
Copy link
Collaborator

I'm still a little bit worried about this potentially causing issues in some edge-case, or for some users, given that this Chrome-only issue has (as far as I can tell) only been reported once.
@calixteman, @timvandermeij How do you feel about this patch?

@calixteman
Copy link
Contributor

calixteman commented Jun 28, 2023

I'm still a little bit worried about this potentially causing issues in some edge-case, or for some users, given that this Chrome-only issue has (as far as I can tell) only been reported once. @calixteman, @timvandermeij How do you feel about this patch?

I don't have my windows machine for the moment, but iirc, I already met this issue with chrome on Windows.
I just tested with Chrome on my mac and it behaves correctly.
As far as I can tell this patch will only affect chrome users so I'm fine with it even if I'm pretty sure that it isn't the correct solution.
And as it has been noticed, the value const PIXELS_PER_LINE_SCALE = 30; probably deserves to be understood maybe the screen resolution matters here... I don't really know. I'll try to find some time to investigate more deeply.

@Abishek-Jayan
Copy link
Author

@Snuffleupagus @timvandermeij @calixteman hi, so...is this fix ok?

@Snuffleupagus
Copy link
Collaborator

Closing this for now, since as mentioned in #16596 (comment) we want to understand how/why Chrome behaves differently before making changes here.

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

Successfully merging this pull request may close these issues.

[Bug] Wheel scroll for scale factor is too big on Chrome.
5 participants