OSR Smooth Scrolling

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

OSR Smooth Scrolling

Postby Devyre » Fri Nov 27, 2020 12:54 am

Hello,

How do I use smooth scrolling with OSR? Do I need to interpolate the delta myself when calling SendMouseWheelEvent?
I'm unable to get it to work using the most recent CEFClient with --off-screen-rendering-enabled.
Devyre
Techie
 
Posts: 27
Joined: Fri Nov 20, 2020 8:31 pm

Re: OSR Smooth Scrolling

Postby magreenblatt » Fri Nov 27, 2020 12:01 pm

You can use the CefRenderHandler::OnScrollOffsetChanged callback to shift the existing image, then render the newly exposed rectangles.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OSR Smooth Scrolling

Postby Devyre » Sat Nov 28, 2020 3:25 am

OnScrollOffsetChanged does not seem to trigger, while other CefRenderHandler callbacks trigger fine.
Could you tell me what you mean by shifting the existing image?
I only render the texture provided by OnAcceleratedPaint (using shared textures), is there a way to set an offset other than SendMouseWheelEvent?
Devyre
Techie
 
Posts: 27
Joined: Fri Nov 20, 2020 8:31 pm

Re: OSR Smooth Scrolling

Postby Devyre » Wed Dec 02, 2020 7:47 am

Seems like the shared textures branch I am using disabled that functionality, I will attempt to re-enable. I am guessing by what you said I am supposed to provide a different (vertically/horizontally larger) View Rect if there is a scroll offset and then move the texture as it's being scrolled to replicate a smooth scroll
Devyre
Techie
 
Posts: 27
Joined: Fri Nov 20, 2020 8:31 pm

Re: OSR Smooth Scrolling

Postby magreenblatt » Wed Dec 02, 2020 10:27 am

That shouldn’t be necessary with OnAcceleratedPaint. Maybe smooth scrolling is disabled in the code (OnAcceleratedPaint is not supported currently, so you’ll need to look at the code yourself). How does it behave with windowed rendering?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OSR Smooth Scrolling

Postby Devyre » Wed Dec 02, 2020 11:37 am

This issue does not exclusively exist for OnAcceleratedPaint, even with only --off-screen-rendering-enabled there is no smoothing.
Using most recent CefClient from cef-builds.spotifycdn.com (4280)

cefclient.exe (no arguments): https://i.imgur.com/NjPmGKH.mp4
cefclient.exe --off-screen-rendering-enabled: https://i.imgur.com/xmlATsV.mp4
Devyre
Techie
 
Posts: 27
Joined: Fri Nov 20, 2020 8:31 pm

Re: OSR Smooth Scrolling

Postby magreenblatt » Wed Dec 02, 2020 11:49 am

Devyre wrote:This issue does not exclusively exist for OnAcceleratedPaint, even with only --off-screen-rendering-enabled there is no smoothing.

This is expected behavior with OnPaint because smooth scrolling is expensive when rendering to bitmap. The above comments about OnScrollOffsetChanged apply for OnPaint usage.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OSR Smooth Scrolling

Postby Devyre » Wed Dec 02, 2020 4:57 pm

magreenblatt wrote:This is expected behavior with OnPaint because smooth scrolling is expensive when rendering to bitmap. The above comments about OnScrollOffsetChanged apply for OnPaint usage.

I have been testing out old branches where shared textures were still supported.
I found out that on branch 3626 smooth scrolling existed for both OnPaint and OnAcceleratedPaint. Then, with branch 3683, smooth scrolling was disabled for both OnPaint and OnAcceleratedPaint (up to branch 3770, after which shared textures no longer worked).
How do I re-enable this? Is this chromium or CEF? I don't really know where to look. I checked the range of commits from chromium 72 - 73, and couldn't find anything smooth scrolling related that would make sense to me.
Devyre
Techie
 
Posts: 27
Joined: Fri Nov 20, 2020 8:31 pm

Re: OSR Smooth Scrolling

Postby magreenblatt » Wed Dec 02, 2020 6:14 pm

Sorry, I don't know. You can start with the documentation in Chromium and work backwards from there to find out why it's not working for you.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: OSR Smooth Scrolling

Postby Devyre » Thu Dec 03, 2020 8:39 am

I managed to solve it using a workaround.
I noticed that there is a difference between views and OSR MouseWheelEvents. Views uses 'native_event' which basically holds hwnd/message/wparam/lparam (on Windows).
In the file ui/events/blink/web_input_event.cc in method 'MakeWebMouseWheelEvent', there is a shorthand if statement for constructing the blink::WebMouseWheelEvent:
Code: Select all
blink::WebMouseWheelEvent webkit_event =
      event.native_event().message
          ? MakeUntranslatedWebMouseWheelEventFromNativeEvent(
                event.native_event(), event.time_stamp(),
                event.pointer_details().pointer_type)
          : MakeWebMouseWheelEventFromUiEvent(event);


Since OSR's SendMouseWheelEvent does not include a native_event, it falls back to MakeWebMouseWheelEventFromUiEvent and in that function is where the problem seems to be.
Now, the way I solved it was by implementing a SendMouseWheelEventNative function that does not use CefMouseEvent, but instead ui::PlatformEvent (On Windows, MSG).

The optimal fix would be to solve whatever causes this inconsistency in MakeWebMouseWheelEventFromUiEvent, but I have too little knowledge about chromium to fix this myself.
Instead of calling SendMouseWheelEvent in the CefClient, I call SendMouseWheelEventNative with a MSG constructed like this (basically copied from views hwnd_message_handler.cc:
Code: Select all
MSG msg = {hwnd_,
                   message,
                   wParam,
                   lParam,
                   static_cast<DWORD>(GetMessageTime()),
                   {CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam)}};
browser_host->SendMouseWheelEventNative(msg);


After doing this, OSR works with smooth scrolling as intended.
I hope this helps solve the actual problem!
Devyre
Techie
 
Posts: 27
Joined: Fri Nov 20, 2020 8:31 pm


Return to Support Forum

Who is online

Users browsing this forum: civilogic, Google [Bot] and 93 guests