Bug 441599 - Incorrect OpenGL viewport after moving window to a monitor with different hidpi scale
Summary: Incorrect OpenGL viewport after moving window to a monitor with different hid...
Status: CONFIRMED
Alias: None
Product: krita
Classification: Applications
Component: OpenGL Canvas (other bugs)
Version First Reported In: nightly build (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-27 10:25 UTC by Alvin Wong
Modified: 2022-02-25 20:22 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Screenshot of wrong viewport size, note that the viewport is stuck on the bottom-left corner (225.73 KB, image/png)
2021-08-27 10:25 UTC, Alvin Wong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alvin Wong 2021-08-27 10:25:30 UTC
Created attachment 141083 [details]
Screenshot of wrong viewport size, note that the viewport is stuck on the bottom-left corner

SUMMARY

When moving the window between the two monitors with Win+Shift+Left/Right repeatedly, at some point the canvas OpenGL viewport appears to be sized incorrectly.

STEPS TO REPRODUCE
1. Press Win+Shift+Left and/or Win+Shift+Right repeatedly


Krita

 Version: 5.0.0-prealpha (git 4826656)
 Languages: zh_TW, zh, en_US, en, zh_TW, zh, en_US, en, zh_TW, zh, en_US, en, zh_TW, zh, en_US, en, zh_TW, zh, en_US, en
 Hidpi: true

Qt

  Version (compiled): 5.12.11
  Version (loaded): 5.12.11

OS Information

  Build ABI: x86_64-little_endian-llp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: winnt
  Kernel Version: 10.0.19041
  Pretty Productname: Windows 10 (10.0)
  Product Type: windows
  Product Version: 10

OpenGL Info
 
  Vendor:  "Google Inc." 
  Renderer:  "ANGLE (Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0)" 
  Version:  "OpenGL ES 3.0 (ANGLE 2.1.0.57ea533f79a7)" 
  Shading language:  "OpenGL ES GLSL ES 3.00 (ANGLE 2.1.0.57ea533f79a7)" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:    QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DefaultSwapBehavior, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile) 
     Version: 3.0
     Supports deprecated functions false 
     is OpenGL ES: true 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsAngleD3D11: true 
  isQtPreferAngle: true 

Hardware Information

  GPU Acceleration: auto
  Memory: 24430 Mb
  Number of Cores: 8
  Swap Location: C:/Users/Alvin/AppData/Local/Temp

Current Settings

  Current Swap Location: C:/Users/Alvin/AppData/Local/Temp
  Current Swap Location writable: true
  Undo Enabled: true
  Undo Stack Limit: 30
  Use OpenGL: true
  Use OpenGL Texture Buffer: true
  Disable Vector Optimizations: false
  Disable AVX Optimizations: false
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 900
  Use Backup Files: true
  Number of Backups Kept: 1
  Backup File Suffix: ~
  Backup Location: Same Folder as the File
  Backup Location writable: false
  Use Win8 Pointer Input: false
  Use RightMiddleTabletButton Workaround: false
  Levels of Detail Enabled: false
  Use Zip64: false


Display Information
Number of screens: 2
	Screen: 0
		Name: \\.\DISPLAY1
		Depth: 32
		Scale: 1.5
		Resolution in pixels: 1707x960
		Manufacturer: 
		Model: 
		Refresh Rate: 60
	Screen: 1
		Name: \\.\DISPLAY2
		Depth: 32
		Scale: 1
		Resolution in pixels: 1920x1080
		Manufacturer: 
		Model: 
		Refresh Rate: 60
Comment 1 vanyossi 2021-08-28 02:08:13 UTC
I can confirm this happens on macOS moving/dragging krita window from a non retina to a retina display (Hi-DPi). however this also happens with 4.4.7

The openGL canvas must be created with the krita window on the non HiDPI display, if it isnt the bug does not happen. But it can be triggered, by entering full screen on the low dpi display before moving the window to the HiDPI display

The effect on macOS is that only 1/4 of the canvas is visible.

I remember seeing something similiar after emmet hiDPI patches on openGL. but then he fixed it, so I suppose the patch did not take into account switching screens.

WORKAROUND: Enter fullscreen mode to refresh canvas coords.
Comment 2 Alvin Wong 2022-02-12 14:04:58 UTC
Git commit fffe152bf1cb0f03790b08d0b727c4bd9b93bae2 by Alvin Wong.
Committed on 12/02/2022 at 12:33.
Pushed by alvinwong into branch 'master'.

ext_qt: Backport various high-DPI fixes for Windows

M  +5    -0    3rdparty/ext_qt/CMakeLists.txt
A  +40   -0    3rdparty/ext_qt/misc_hidpi_backport/0002-Windows-QPA-Fix-missing-resize-when-changing-the-sca.patch
A  +45   -0    3rdparty/ext_qt/misc_hidpi_backport/0003-qwindowswindow-Fix-screen-changes-between-different-.patch
A  +90   -0    3rdparty/ext_qt/misc_hidpi_backport/0004-Windows-QPA-Fix-geometry-when-firing-a-full-expose.patch
A  +38   -0    3rdparty/ext_qt/misc_hidpi_backport/0005-Windows-QPA-Fix-restoring-from-fullscreen-in-High-DP.patch

https://invent.kde.org/graphics/krita/commit/fffe152bf1cb0f03790b08d0b727c4bd9b93bae2
Comment 3 Alvin Wong 2022-02-13 10:31:11 UTC
Looks like the Qt patch does fix the issue for Windows. Which means if it's reproducible on macOS too then it needs to be fixed inside the Qt cocoa platform plugin.
Comment 4 amyspark 2022-02-25 20:22:49 UTC
Git commit 60485da6fdbdf95842ca31317b2096886563b755 by L. E. Segovia, on behalf of Alvin Wong.
Committed on 25/02/2022 at 15:42.
Pushed by lsegovia into branch 'krita/5.0'.

ext_qt: Backport various high-DPI fixes for Windows
(cherry picked from commit fffe152bf1cb0f03790b08d0b727c4bd9b93bae2)

M  +5    -0    3rdparty/ext_qt/CMakeLists.txt
A  +40   -0    3rdparty/ext_qt/misc_hidpi_backport/0002-Windows-QPA-Fix-missing-resize-when-changing-the-sca.patch
A  +45   -0    3rdparty/ext_qt/misc_hidpi_backport/0003-qwindowswindow-Fix-screen-changes-between-different-.patch
A  +90   -0    3rdparty/ext_qt/misc_hidpi_backport/0004-Windows-QPA-Fix-geometry-when-firing-a-full-expose.patch
A  +38   -0    3rdparty/ext_qt/misc_hidpi_backport/0005-Windows-QPA-Fix-restoring-from-fullscreen-in-High-DP.patch

https://invent.kde.org/graphics/krita/commit/60485da6fdbdf95842ca31317b2096886563b755