SOLVED: Reverse and slow scrolling with JCEF (Off Screen

Having problems with building or using the JCEF Java binding? Ask your questions here.

SOLVED: Reverse and slow scrolling with JCEF (Off Screen

Postby JCEFBeginner » Sat Apr 17, 2021 10:06 am

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
Last edited by JCEFBeginner on Wed May 26, 2021 10:36 am, edited 1 time in total.
JCEFBeginner
Newbie
 
Posts: 9
Joined: Fri Feb 12, 2021 12:17 pm

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

Postby magreenblatt » Sat Apr 17, 2021 12:16 pm

How did you configure scroll direction in your Linux distro? The fix will involve accessing that setting from Java somehow.
magreenblatt
Site Admin
 
Posts: 10863
Joined: Fri May 29, 2009 6:57 pm

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

Postby JCEFBeginner » Sat May 01, 2021 2:06 pm

@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?
Last edited by JCEFBeginner on Sun May 02, 2021 1:46 pm, edited 1 time in total.
JCEFBeginner
Newbie
 
Posts: 9
Joined: Fri Feb 12, 2021 12:17 pm

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

Postby JCEFBeginner » Sun May 02, 2021 1:28 pm

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?
JCEFBeginner
Newbie
 
Posts: 9
Joined: Fri Feb 12, 2021 12:17 pm

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

Postby magreenblatt » Sun May 02, 2021 3:00 pm

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.
magreenblatt
Site Admin
 
Posts: 10863
Joined: Fri May 29, 2009 6:57 pm

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

Postby amaitland » Sun May 02, 2021 3:03 pm

You can also try the disable-threaded-scrolling command line arg.

https://peter.sh/experiments/chromium-c ... -scrolling
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 932
Joined: Wed Jan 14, 2015 2:35 am

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

Postby JCEFBeginner » Mon May 03, 2021 6:49 am

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?
JCEFBeginner
Newbie
 
Posts: 9
Joined: Fri Feb 12, 2021 12:17 pm

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

Postby magreenblatt » Mon May 03, 2021 10:24 am

Yes, the problem could be in the Java code.
magreenblatt
Site Admin
 
Posts: 10863
Joined: Fri May 29, 2009 6:57 pm

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

Postby JCEFBeginner » Tue May 04, 2021 3:21 am

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)
JCEFBeginner
Newbie
 
Posts: 9
Joined: Fri Feb 12, 2021 12:17 pm

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

Postby JCEFBeginner » Tue May 04, 2021 11:34 am

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
JCEFBeginner
Newbie
 
Posts: 9
Joined: Fri Feb 12, 2021 12:17 pm


Return to JCEF Forum

Who is online

Users browsing this forum: Google [Bot] and 3 guests