Bug 443705

Summary: Various application windows are started with the smallest possible size in Wayland
Product: [Plasma] kwin Reporter: Reiddragon <this.is.reid>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kde, memegames1337, nate
Priority: NOR    
Version: 5.23.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.23.1
Attachments: log for `WAYLAND_DEBUG=1 konsole`
log for `WAYLAND_DEBUG=1 gwenview path/to/file`
config files for gwenview, okular, kate, and konsole (+ konsole profile)
kwinrc
kwinrulesrc

Description Reiddragon 2021-10-14 12:32:04 UTC
SUMMARY
Various application windows are started with the smallest possible size in the Wayland session
Affected applications I have observed:
- Konsole
- Gwenview
- Okular
- qTox chat windows (in multi-window mode, friends list window is unaffected)

(some) KDE apps not affected:
- Kate
- Dolphin
- KTorrent
- System Settings

STEPS TO REPRODUCE
1. log into Plasma Wayland session
2. launch any of the applications listed as affected
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.23.0
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Graphics Platform: Wayland

ADDITIONAL INFORMATION
Comment 1 David Edmundson 2021-10-14 12:51:28 UTC
I have not seen that with kate. 
Please include output of WAYLAND_DEBUG=1 for those applications.
Comment 2 Reiddragon 2021-10-14 13:57:34 UTC
Created attachment 142428 [details]
log for `WAYLAND_DEBUG=1 konsole`

log for konsole
Comment 3 Reiddragon 2021-10-14 13:59:11 UTC
Created attachment 142430 [details]
log for `WAYLAND_DEBUG=1 gwenview path/to/file`

and log for Gwenview
another note is it seems like the bug only manifests in Okular and Gwenview when trying to open it with a document right off the getgo, launching them from KickOff or from a terminal without a path to a file won't trigger the bug
Comment 4 Vlad Zahorodnii 2021-10-14 14:12:26 UTC
[1652706.929]  -> wl_registry@2.bind(5, "xdg_wm_base", 1, new id [unknown]@35)
[1652707.005]  -> wl_registry@2.bind(7, "zxdg_decoration_manager_v1", 1, new id [unknown]@36)
[1652707.061]  -> xdg_wm_base@35.get_xdg_surface(new id xdg_surface@37, wl_surface@23)
[1652707.095]  -> xdg_surface@37.get_toplevel(new id xdg_toplevel@38)
[1652707.114]  -> zxdg_decoration_manager_v1@36.get_toplevel_decoration(new id zxdg_toplevel_decoration_v1@39, xdg_toplevel@38)
[1652707.135]  -> zxdg_toplevel_decoration_v1@39.unset_mode()
[1652707.146]  -> xdg_toplevel@38.set_min_size(8, 8)
[1652707.166]  -> xdg_toplevel@38.set_max_size(0, 0)
[1652707.190]  -> xdg_toplevel@38.set_title("Profile 1 — Konsole")
[1652707.206]  -> xdg_toplevel@38.set_app_id("org.kde.konsole")
[1652707.221]  -> wl_surface@23.set_buffer_scale(1)
[1652707.238]  -> zxdg_toplevel_decoration_v1@39.unset_mode()
[1652707.253]  -> wl_surface@23.set_buffer_transform(0)
[1652707.269]  -> wl_surface@23.commit()
[1652732.577]  -> xdg_toplevel@38.set_title("~ : zsh — Konsole")
[1652733.639] wl_surface@23.enter(wl_output@16)
[1652733.712] zxdg_toplevel_decoration_v1@39.configure(2)
[1652733.735] xdg_toplevel@38.configure(0, 0, array)
[1652733.766] xdg_surface@37.configure(810)

seems good so far

[1652733.808]  -> xdg_surface@37.set_window_geometry(0, 0, 875, 600)
[1652733.861]  -> xdg_surface@37.ack_configure(810)
[1652734.567]  -> org_kde_kwin_appmenu_manager@25.create(new id org_kde_kwin_appmenu@40, wl_surface@23)
[1652734.636]  -> org_kde_kwin_appmenu@40.set_address(":1.404", "/MenuBar/1")
[1652734.671]  -> org_kde_kwin_blur_manager@32.create(new id org_kde_kwin_blur@41, wl_surface@23)
[1652734.709]  -> wl_compositor@4.create_region(new id wl_region@42)
[1652734.736]  -> org_kde_kwin_blur@41.set_region(wl_region@42)
[1652734.756]  -> org_kde_kwin_blur@41.commit()
[1652734.891]  -> wl_shm@6.create_pool(new id wl_shm_pool@43, fd 19, 2100000)
[1652734.952]  -> wl_shm_pool@43.create_buffer(new id wl_buffer@44, 0, 875, 600, 3500, 0)
[1652744.765]  -> wl_surface@23.frame(new id wl_callback@45)
[1652744.840]  -> wl_surface@23.attach(wl_buffer@44, 0, 0)
[1652744.882]  -> wl_surface@23.damage(0, 0, 875, 600)
[1652744.927]  -> wl_surface@23.commit()
[1652744.979] xdg_toplevel@38.configure(1, 1, array)

this one is weird. do you use any scripts?

[1652745.017] xdg_surface@37.configure(811)
[1652745.405]  -> xdg_surface@37.set_window_geometry(0, 0, 8, 8)

off-topic: qtwayland has violated the xdg-shell protocol. it should be killed but kwin_wayland doesn't check configured sizes

[1652745.513]  -> xdg_surface@37.ack_configure(811)
[1652746.114]  -> wl_shm@6.create_pool(new id wl_shm_pool@46, fd 19, 256)
[1652746.201]  -> wl_shm_pool@46.create_buffer(new id wl_buffer@47, 0, 8, 8, 32, 0)
[1652746.544]  -> wl_surface@23.attach(wl_buffer@47, 0, 0)
[1652746.612]  -> wl_surface@23.damage(0, 0, 8, 8)
[1652746.653]  -> wl_surface@23.commit()
[1652746.704]  -> org_kde_kwin_blur_manager@32.create(new id org_kde_kwin_blur@48, wl_surface@23)
[1652746.741]  -> wl_compositor@4.create_region(new id wl_region@49)
[1652746.768]  -> org_kde_kwin_blur@48.set_region(wl_region@49)
[1652746.786]  -> org_kde_kwin_blur@48.commit()
Comment 5 Reiddragon 2021-10-14 14:20:00 UTC
(In reply to Vlad Zahorodnii from comment #4)
> [1652733.808]  -> xdg_surface@37.set_window_geometry(0, 0, 875, 600)
> [1652733.861]  -> xdg_surface@37.ack_configure(810)
> [1652734.567]  -> org_kde_kwin_appmenu_manager@25.create(new id
> org_kde_kwin_appmenu@40, wl_surface@23)
> [1652734.636]  -> org_kde_kwin_appmenu@40.set_address(":1.404", "/MenuBar/1")
> [1652734.671]  -> org_kde_kwin_blur_manager@32.create(new id
> org_kde_kwin_blur@41, wl_surface@23)
> [1652734.709]  -> wl_compositor@4.create_region(new id wl_region@42)
> [1652734.736]  -> org_kde_kwin_blur@41.set_region(wl_region@42)
> [1652734.756]  -> org_kde_kwin_blur@41.commit()
> [1652734.891]  -> wl_shm@6.create_pool(new id wl_shm_pool@43, fd 19, 2100000)
> [1652734.952]  -> wl_shm_pool@43.create_buffer(new id wl_buffer@44, 0, 875,
> 600, 3500, 0)
> [1652744.765]  -> wl_surface@23.frame(new id wl_callback@45)
> [1652744.840]  -> wl_surface@23.attach(wl_buffer@44, 0, 0)
> [1652744.882]  -> wl_surface@23.damage(0, 0, 875, 600)
> [1652744.927]  -> wl_surface@23.commit()
> [1652744.979] xdg_toplevel@38.configure(1, 1, array)
> 
> this one is weird. do you use any scripts?

nope, no scripts
Comment 6 Vlad Zahorodnii 2021-10-14 14:24:33 UTC
is there anything unorthodox about your setup, e.g. panel being at different location, etc? do you have window rules set?
Comment 7 Reiddragon 2021-10-14 14:35:46 UTC
(In reply to Vlad Zahorodnii from comment #6)
> is there anything unorthodox about your setup, e.g. panel being at different
> location, etc? do you have window rules set?

2 panels, one full width at the top, one panel configured as a hiding dock at the bottom, some window rules but none for the apps affected by this
Comment 8 Vlad Zahorodnii 2021-10-14 14:43:34 UTC
Nope, with two panels, konsole, okular, and gwenview have normal size. Can you create a new user and check if the initial size issue is present with the new account?
Comment 9 Reiddragon 2021-10-14 14:51:23 UTC
(In reply to Vlad Zahorodnii from comment #8)
> Nope, with two panels, konsole, okular, and gwenview have normal size. Can
> you create a new user and check if the initial size issue is present with
> the new account?

they behave normally in the new account
Comment 10 Reiddragon 2021-10-14 14:52:35 UTC
should I provide the config files for the affected apps from my main account?
Comment 11 Vlad Zahorodnii 2021-10-14 14:56:32 UTC
(In reply to Reid from comment #10)
> should I provide the config files for the affected apps from my main account?

yes, they may provide some clue. please make sure that the configs contain no sensitive or personal information before uploading them.
Comment 12 Reiddragon 2021-10-14 15:08:00 UTC
Created attachment 142435 [details]
config files for gwenview, okular, kate, and konsole (+ konsole profile)

upon further testing it looks like most KDE apps are affected when launching them with a file as argument like `kate .config/katerc` (any file will do)
Konsole is the only one to always do it

included the config files for a few apps I've confirmed to be affected
Comment 13 Vlad Zahorodnii 2021-10-14 15:14:43 UTC
I've checked the configs and there is nothing special. I still can't reproduce the issue.

Can you attach your kwinrc file to the bug report?
Comment 14 Reiddragon 2021-10-14 15:20:15 UTC
Created attachment 142436 [details]
kwinrc

here's my kwinrc
and since you'll probably mention it: the theme doesn't change anything, both Lightly and Breeze behave the same
Comment 15 Vlad Zahorodnii 2021-10-14 15:38:42 UTC
Besides the placement policy (centered), I see nothing suspicious. But on my machine, windows have normal size even with centered placement policy.

It will be helpful to know:

* what window rules you have, i.e. the contents of .config/kwinrulesrc
* list of enabled scripts, only listed in the "kwin scripts" tab in system settings

also, can you verify that this issue is present even with a fresh kwinrc file? (make a backup of your .config/kwinrc file before testing)
Comment 16 Reiddragon 2021-10-14 15:47:53 UTC
Created attachment 142437 [details]
kwinrulesrc

no active scripts, also happens with fresh kwinrc
Comment 17 Vlad Zahorodnii 2021-10-14 15:53:12 UTC
I've copied over your kwinrulesrc file and can reproduce the issue now.
Comment 18 Reiddragon 2021-10-14 16:11:52 UTC
the Window Class for the Vivaldi's Picture in Picture rule was set to unimportant instead of Exact Match and that seems to have caused it
weird it causes this in Wayland tho
Comment 19 Bug Janitor Service 2021-10-14 16:55:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1527
Comment 20 Vlad Zahorodnii 2021-10-15 05:39:12 UTC
Git commit ff3465a80e49da9537d4b4990605fe144112f070 by Vlad Zahorodnii.
Committed on 15/10/2021 at 05:38.
Pushed by vladz into branch 'master'.

Fix AbstractClient::adjustedSize() for wayland windows with no committed buffer

AbstractClient::constrainClientSize() forces the minimum client size of
1x1.

If AbstractClient::adjustedSize() is called before the XdgToplevelClient
is mapped, it will return 1x1 rather than 0x0 as expected, which will
confuse

    QSize s = adjustedSize();
    if (s != size() && s.isValid())
        resizeWithChecks(s);

in AbstractClient::applyWindowRules(). Since 1x1 is different from 0x0,
the xdg-toplevel surface is going to be resized to 1x1.

M  +6    -1    src/abstract_client.cpp

https://invent.kde.org/plasma/kwin/commit/ff3465a80e49da9537d4b4990605fe144112f070
Comment 21 Vlad Zahorodnii 2021-10-15 05:39:48 UTC
Git commit 65b878f6dfdb9ab73aee50a31ce05ed4cef97880 by Vlad Zahorodnii.
Committed on 15/10/2021 at 05:39.
Pushed by vladz into branch 'Plasma/5.23'.

Fix AbstractClient::adjustedSize() for wayland windows with no committed buffer

AbstractClient::constrainClientSize() forces the minimum client size of
1x1.

If AbstractClient::adjustedSize() is called before the XdgToplevelClient
is mapped, it will return 1x1 rather than 0x0 as expected, which will
confuse

    QSize s = adjustedSize();
    if (s != size() && s.isValid())
        resizeWithChecks(s);

in AbstractClient::applyWindowRules(). Since 1x1 is different from 0x0,
the xdg-toplevel surface is going to be resized to 1x1.


(cherry picked from commit ff3465a80e49da9537d4b4990605fe144112f070)

M  +6    -1    src/abstract_client.cpp

https://invent.kde.org/plasma/kwin/commit/65b878f6dfdb9ab73aee50a31ce05ed4cef97880
Comment 22 Nate Graham 2021-10-18 16:33:07 UTC
*** Bug 443915 has been marked as a duplicate of this bug. ***