Java 17 clipped content on secondary monitor

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

Java 17 clipped content on secondary monitor

Postby vkatkov » Mon Jan 24, 2022 11:25 am

Hi,

i have a problem with content rendering on secondary monitor with different windows scaling. This issue appeared when project migrated from Java 1.8 (no problems on this version) to Java 17.
JDK is OpenJDK 17.
JCEF Version = 88.2.9.281
CEF Version = 88.2.9
Chromium Version = 88.0.4324.182

Primary monitor - 1920x1080 with 125% scaling
Secondary monitor - 1680x1050 with 100% scaling

When application located on primary monitor, everything works as expected, but when i drag application to secondary monitor and create new CefBrowser (basically new tab), all content in this tab is moved right (in case if monitor is configured to be on right side), image is attached.

The main thing is when i manually change size of main application window, content is rerendered and displayed as expected.

I tried to set correct width, height, x, y programatically (took values from current JFrame) using
Code: Select all
CefBrowserWr.getUIComponent()
object, but unfortunately it doesn't change anything if i put same values as application window had previously. But when i change width at least to 1px, whole JPanel content got rerendered and repositioned to right place.
After some time of debugging i came up that method stack goes to
Code: Select all
CefBrowser_N.N_WasResized(int width, int height)
and all the rest happens in C++ code, it seems that this code is responsible for decision of triggering some rerendering logic.

A this moment i came up with ugly solution to change width of the CefBrowserWr UIComponent twice - frist -1 px then +1px after browser is constructed. This allows to correctly position content on secondary monitor.

Also it's worth to mention that i debugged and figured out that it's not JPanel is broken (or JFRame) but the content inside of it.

As i came up to some native C++ code, i cannot continue investigation because of lack of technical background here. I'm really wondering if there're any callbacks to Java from C++ code when
Code: Select all
CefBrowser_N.N_WasResized(int width, int height)
is triggered, and if there is some caching of application width and height that blocks some of the logic to be executed when same width and height are set.
And of course i want to find clean solution for my problem.
Attachments
Screenshot_1.png
Screenshot_1.png (147.51 KiB) Viewed 5801 times
vkatkov
Newbie
 
Posts: 2
Joined: Mon Jan 24, 2022 10:25 am

Re: Java 17 clipped content on secondary monitor

Postby magreenblatt » Mon Jan 24, 2022 11:31 am

This issue appeared when project migrated from Java 1.8 (no problems on this version) to Java 17.

What did you change in the code when performing this migration?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Java 17 clipped content on secondary monitor

Postby vkatkov » Tue Feb 01, 2022 8:03 am

What did you change in the code when performing this migration?

Checked all changes after Java migration was done and figured out there were no major changes which directly related to browser initialization and configuration, everything almost look the same. The parts which are changed actualy have no influence to the browser initialization and rendering.
vkatkov
Newbie
 
Posts: 2
Joined: Mon Jan 24, 2022 10:25 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 17 guests