Page 1 of 1

SOLVED: Reverse and slow scrolling with JCEF (Off Screen

PostPosted: Sat Apr 17, 2021 10:06 am
by JCEFBeginner
Hello everyone,
I have a problem with JCEF. Steps to reproduce the problem:

    [1] Run JCEF detailed example with --off-screen-rendering-enabled
    [2] Navigate to a website, on which you can scroll
    [3] Try to scroll with the mouse wheel
The problem is that the scrolling is slow and reverse. I have the same problem with an application that I created.

My question: What can I do in my application to fix this problem or should I report this behavior as an Issue of JCEF/CEF?

For your information: This question is a dublicate of this https://stackoverflow.com/questions/66832470/reverse-and-slow-scrolling-with-jcef-off-screen-rendering-os-linux strackoverflow question.

JCEFBeginner

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Sat Apr 17, 2021 12:16 pm
by magreenblatt
How did you configure scroll direction in your Linux distro? The fix will involve accessing that setting from Java somehow.

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Sat May 01, 2021 2:06 pm
by JCEFBeginner
@magreenblatt Thank you for your fast answer.
Sorry for my late answer. I saw your answer only today.

I found a setting for reversing scroll-direction, but I don't know yet how I can access it in Java.
This setting solves the first problem (reverse scrolling).

But it does not solve the problem with slow scrolling.
Does anyone have an idea?

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Sun May 02, 2021 1:28 pm
by JCEFBeginner
I think a solution is maybe to install an extension like SmoothScroll https://chrome.google.com/webstore/detail/smoothscroll/nbokbjkabcmbfdlbddjidfmibcpneigj?utm_source=chrome-ntp-icon.
But how I can do this with JCEF?

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Sun May 02, 2021 3:00 pm
by magreenblatt
You can test with the binary distribution from here to see if the problem is specific to OSR (build the cefclient target and run with the --off-screen-rendering-enabled command-line flag). I believe smooth scrolling is disabled with OSR, for performance reasons.

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Sun May 02, 2021 3:03 pm
by amaitland
You can also try the disable-threaded-scrolling command line arg.

https://peter.sh/experiments/chromium-c ... -scrolling

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Mon May 03, 2021 6:49 am
by JCEFBeginner
Thank you, @magreenblatt and @amaitland for your response.

I built the cefclient target with cef version "88.2.6+gd717f0e+chromium-88.0.4324.150".
I ran the cefclient executable with all combinations of the command line flags that you-all proposed to me.
However I ran it, I don't had problems with scrolling.

Maybe the problem is in the java code?

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Mon May 03, 2021 10:24 am
by magreenblatt
Yes, the problem could be in the Java code.

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Tue May 04, 2021 3:21 am
by JCEFBeginner
Today I ran the JCEF detailed example with off-screen-rendering-enabled. I had the same scrolling problems.
If I ran it without off-screen-rendering-enabled command line flag, I had no problems with scrolling, but If I resized the window, the browser UI did not get resized.

(Sorry if my english is bad)

Re: Reverse and slow scrolling with JCEF (Off Screen renderi

PostPosted: Tue May 04, 2021 11:34 am
by JCEFBeginner
I have a solution.
My solution is not perfect, but better than no solution.

I changed the Class CefBrowserOsr and the method sendMouseWheelEvent of CefBrowser_N to public.
I also deleted this code from CefBrowserOsr:
Code: Select all
 canvas_.addMouseWheelListener(new MouseWheelListener() {
            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                    browserOsr.sendMouseWheelEvent(e_);
            }
        });


Then I added these lines of code to my application:
Code: Select all
CefBrowserOsr browserOsr = (CefBrowserOsr) browser;
Component browserUIComponent = browserOsr.getUIComponent();
browserUIComponent.addMouseWheelListener(new MouseWheelListener() {
       @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
               MouseWheelEvent e_ = new MouseWheelEvent(browserUIComponent,
                     e.getID(),
                     e.getWhen(),
                     e.getModifiers(),
                     e.getX(),
                     e.getY(),
                     e.getClickCount(),
                     e.isPopupTrigger(),
                     e.getScrollType(),
                     e.getScrollAmount(),
                     e.getWheelRotation() * -1);
               for (int i=0; i<8;i++) {
                     browserOsr.sendMouseWheelEvent(e_);
                }
            }
        });


The solution works for me.

Thank you, @magreenblatt and @amaitland for your help!
If you have a better solution, you are free to share it in this thread.

JCEFBeginner