Bug 467138 - Fullscreen apps have the wrong orientation when using a non default rotation
Summary: Fullscreen apps have the wrong orientation when using a non default rotation
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (other bugs)
Version First Reported In: git-stable-Plasma/5.27
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-10 05:34 UTC by quackdoctech
Modified: 2023-04-21 19:56 UTC (History)
1 user (show)

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


Attachments
example of application in windowed mode (1000.45 KB, image/jpeg)
2023-03-10 09:13 UTC, quackdoctech
Details
example of fullscreen (1000.45 KB, image/jpeg)
2023-03-10 09:14 UTC, quackdoctech
Details
Ignore the last one, I accidentally uploaded the same image (991.75 KB, image/jpeg)
2023-03-10 09:15 UTC, quackdoctech
Details
WAYLAND_DEBUG logs (492.84 KB, text/plain)
2023-03-10 09:49 UTC, quackdoctech
Details

Note You need to log in before you can comment on or make changes to this bug.
Description quackdoctech 2023-03-10 05:34:14 UTC
SUMMARY
***
When entering fullscreen in some applications like SDL apps. the fullscreen is forced to the default orientation of the display, not the current orientation. this effects both auto rotate and statically rotated displays. this has been reproduced using VKmark, gamescope, Moonlight-QT and mpv's libmpv sdl example when modified to enter fullscreen.
***


STEPS TO REPRODUCE
1. Install arch
2. Install KDE
3. Install moonlight-qt or vkmark
4. launch in fullscreen mode

OBSERVED RESULT
application is forced to default orientation of display

EXPECTED RESULT
application is forced to current orientation of display

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux 6.2.2
(available in About System)
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Comment 1 Vlad Zahorodnii 2023-03-10 08:10:08 UTC
What's "default orientation" and "current orientation"?
Comment 2 quackdoctech 2023-03-10 08:34:42 UTC
(In reply to Vlad Zahorodnii from comment #1)
> What's "default orientation" and "current orientation"?

thanks for the prompt reply

the default orientation would be auto rotation off, and no rotation applied. current rotation in this context would be any rotation that is not the "default orientation". for context, I have a chuwi Hi10x 2 in 1, the display is naturally a "portait" orientation, however when docked which is my typical use case. it is in landscape, the landscape is the "current orientation"

using SDL libmpv example for testing I have verified that gnome has working auto rotation, Sway and weston work for the "current orientation" when the app is launched, but sway does not support auto rotate, and I havent figured out how to rotate weston live so no testing was done there.  as for KDE, I have manually tried setting the video= panel_orientation= kernel flag as well as the rotate flag and neither have worked to remedy the situation
Comment 3 Vlad Zahorodnii 2023-03-10 08:42:13 UTC
we don't support auto rotation when launching fullscreen apps, or am I misunderstanding it?
Comment 4 quackdoctech 2023-03-10 08:52:11 UTC
(In reply to Vlad Zahorodnii from comment #3)
> we don't support auto rotation when launching fullscreen apps, or am I
> misunderstanding it?

the issue is broadly, that the applications tested are forced into the "default orientation" regardless of manually changing rotation, or auto rotate
Comment 5 Vlad Zahorodnii 2023-03-10 08:55:28 UTC
fullscreen mpv looks fine on a rotated output on my machine. Can you share some photos showing the problem (there's still a chance that I misunderstand the issue)? also, please run mpv with WAYLAND_DEBUG=1 and post the output here
Comment 6 quackdoctech 2023-03-10 09:13:38 UTC
Created attachment 157164 [details]
example of application in windowed mode
Comment 7 quackdoctech 2023-03-10 09:13:51 UTC
(In reply to Vlad Zahorodnii from comment #5)
> fullscreen mpv looks fine on a rotated output on my machine. Can you share
> some photos showing the problem (there's still a chance that I misunderstand
> the issue)? also, please run mpv with WAYLAND_DEBUG=1 and post the output
> here

I wasn't using mpv itself but rather this https://github.com/mpv-player/mpv-examples/blob/master/libmpv/sdl/main.c with a patch that adds SDL_SetWindowFullscreen(windows, 1)

I was also able to replicate the issue using supertux and supertuxkart. regardless here are the pictures of supertux
Comment 8 quackdoctech 2023-03-10 09:14:11 UTC
Created attachment 157165 [details]
example of fullscreen
Comment 9 quackdoctech 2023-03-10 09:15:59 UTC
Created attachment 157166 [details]
Ignore the last one, I accidentally uploaded the same image
Comment 10 Vlad Zahorodnii 2023-03-10 09:39:26 UTC
Another thing to test: try setting KWIN_DRM_NO_DIRECT_SCANOUT=1 environment variable
Comment 11 quackdoctech 2023-03-10 09:49:43 UTC
Created attachment 157167 [details]
WAYLAND_DEBUG logs

Sorry for the delay, it took a minute to find an app that would actually spit the logs since most apps were running xwayland.

KWIN_DRM_NO_DIRECT_SCANOUT=1 did not help. there was no difference.
Comment 12 quackdoctech 2023-03-15 12:26:50 UTC
I went back and tested X11 directly, the issue only effects wayland, x11 seems to work just fine. When I reported the issue to SDL https://github.com/libsdl-org/SDL/issues/7439 this is what was pondered 

"... SDL reports the display orientation received from the compositor to the application, as well as adjusts the display coordinates for rotated displays. Beyond that, I'm not sure what else it is supposed to do to 'respect the compositor orientation'?"
Comment 13 betaminos 2023-04-20 17:20:50 UTC
I am facing this issue on a OneXPlayer, small laptop-like device, running an Intel 1165g7 and a tablet-screen that defaults to portrait orientation. What seems funny to me is that any kind of fullscreen app triggers the bug, e.g. YouTube fullscreen mode is sufficient. However, forcing an overlay, like changing volume, rotates the screen correctly, at least until the overlay disappears again which causes the screen to fall back to the incorrect orientiation.

Additionally, using YouTube for testing has shown that the device seems to confuse the orientation and rendering area. The "fullscreen" video is in fact squeezed into a part of the screen due to the incorrect rotation - but I am able to move the mouse outside of the video frame, giving me the impression that somewhere along the rendering, the surface to display the fullscreen content is incorrectly rotated.

Is there any log or other info I can provide to help solve this? I am running Plasma 5.27.4, Framework 5.105, Qt 5.15.9 and Linux 6.2.11.
Comment 14 Bug Janitor Service 2023-04-20 22:22:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3995
Comment 15 Zamundaaa 2023-04-21 16:33:40 UTC
Git commit 8ca38fb328606f8a0bababea2e07b36fd775768f by Xaver Hugl.
Committed on 21/04/2023 at 15:35.
Pushed by zamundaaa into branch 'master'.

backends/drm: fix buffer orientation check for direct scanout

Without hardware rotation, the buffer transform with always be "normal",
so all "normal" client buffers would be accepted for direct scanout, which
is not correct.

M  +1    -30   src/backends/drm/drm_egl_layer.cpp

https://invent.kde.org/plasma/kwin/commit/8ca38fb328606f8a0bababea2e07b36fd775768f
Comment 16 Bug Janitor Service 2023-04-21 17:45:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4002
Comment 17 Vlad Zahorodnii 2023-04-21 19:33:05 UTC
Git commit 5e0349cd99be7c8728f93ba7cf0e2cf590756971 by Vlad Zahorodnii, on behalf of Xaver Hugl.
Committed on 21/04/2023 at 19:14.
Pushed by vladz into branch 'Plasma/5.27'.

backends/drm: fix buffer orientation check for direct scanout

Without hardware rotation, the buffer transform with always be "normal",
so all "normal" client buffers would be accepted for direct scanout, which
is not correct.

(cherry picked from commit 8ca38fb328606f8a0bababea2e07b36fd775768f)

M  +1    -30   src/backends/drm/drm_egl_layer.cpp

https://invent.kde.org/plasma/kwin/commit/5e0349cd99be7c8728f93ba7cf0e2cf590756971
Comment 18 quackdoctech 2023-04-21 19:56:03 UTC
tested and confirmed working!