Skip to content

Browser content cut off or gray when window is dragged between monitors with different DPI scalings #546

Description

@friendlyAce

Describe the bug
When running JCEF on a multi-monitor Windows setup where the monitors use different DPI/scaling factors (for example monitor 1 at 2560x1440 @ 125% scaling and monitor 2 at 2560x1440 @ 100% scaling, also reproducible with different resolutions and different scaling on both screens), dragging the JCEF browser window with the mouse from one monitor to the other does not correctly resize/repaint the embedded browser surface.

Instead of the browser content scaling to match the new monitor's DPI, one of the following happens:

  1. The rendered content is cut off on the right side
    Image

  2. A gray/blank area appears where the browser content should have been rendered
    Image

The browser only repaints and resizes correctly again after the user interacts with some buttons or manually resizes the window (even by a very small amount), at which point the content immediately snaps to fill the window frame correctly again.

Notably, moving the window between monitors using the keyboard shortcuts Win+Shift+[Left|Right Arrow key] does not trigger the problem in our testing with the sample applications. The issue only appears when the window is moved by dragging it across the monitor boundary with the mouse.

To Reproduce
Steps to reproduce the behavior:

  1. Build JCEF for Windows (win64, Release) from the master branch (We used the d3de827 commit)
  2. Set up two monitors with different scaling placed side by side (Win+I > System > Display > Scale), for example:
    • Monitor 1: 2560x1440 @ 125% scaling
    • Monitor 2: 2560x1440 @ 100% scaling
  3. From java-cef/tools, run the demo:
    run.bat win64 Release detailed 
    
    (also reproducible with simple instead of detailed)
  4. Move the JCEF window from monitor 1 to monitor 2 (or vice versa) by dragging it with the mouse across the boundary between the two screens
  5. Observe the browser content area: either part of the page content is cut off, or a gray/blank area appears where content should be rendered
  6. Resize the window slightly, for example by dragging a window edge by a few pixels. The content immediately snaps back and renders correctly at the new size and scale

Expected behavior
When the window is moved to a monitor with a different DPI scaling factor, the embedded CEF browser should automatically detect the scale-factor change and resize/repaint its surface to correctly fill the window, without requiring a manual resize.

Screenshots
Two screenshots are attached above, illustrating both failure modes:

  • Screenshot 1: content cut off after dragging the window to the other monitor
  • Screenshot 2: gray/blank area after dragging the window to the other monitor

Versions (please complete the following information):

  • OS: Windows 11, 25H2 (10.0.26200, Build 26200)
  • Java Version: OpenJDK 25.0.1 LTS, Eclipse Temurin build 25.0.1+8-LTS
  • JCEF Version (commit): d3de827 (master)
  • CEF Version: 146.0.10+g8219561+chromium-146.0.7680.179

Additional context

  • Reproduces in both the simple and detailed sample applications launched via tools/run.bat win64 Release [simple|detailed]
  • No DPI-awareness overrides were configured for the demo run. The application manifest and DPI-awareness settings used are whatever JCEF ships with by default; we did not apply any custom manifest, registry key, or compatibility settings
  • We also observe the same behavior in our own product, which embeds a JCEF browser via an SWT/AWT bridge (heavyweight embedding). We are not able to share that product's source code, but wanted to flag that the issue is not specific to the sample apps or to a particular embedding approach, since it reproduces with the plain JCEF simple/detailed demos as well

Question for maintainers:
Are there any known workarounds that we can use for the meantime, to force CEF to re-layout properly on such a monitor setup with different display scalings?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug report

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions