Bug 456686 - kwin_wayland_drm: an error occurred while swapping buffers "EGL_BAD_ALLOC" when Kwin tries to update the cursor image
Summary: kwin_wayland_drm: an error occurred while swapping buffers "EGL_BAD_ALLOC" wh...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 5.25.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland-only
Depends on:
Blocks:
 
Reported: 2022-07-13 17:45 UTC by postix
Modified: 2022-08-12 20:09 UTC (History)
3 users (show)

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


Attachments
kWin Support Info (7.06 KB, text/plain)
2022-07-13 17:45 UTC, postix
Details
journalctl | grep -i kwin > journalctl.txt (199.38 KB, application/zip)
2022-07-16 16:50 UTC, postix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2022-07-13 17:45:00 UTC
Created attachment 150589 [details]
kWin Support Info

SUMMARY

When moving the cursor eg over
- the content in Firefox
- between two different windows
- between two elements of a window like Konsole's tabbar and Konsole's content

journalctl gets spammed with
kwin_wayland[2823]: kwin_wayland_drm: an error occurred while swapping buffers "EGL_BAD_ALLOC"


SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220711
KDE Plasma Version: 5.25.2
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5
Kernel Version: 5.18.9-2-default (64-bit)
Graphics Platform: Wayland
Graphics Processor: AMD Radeon RX 580 Series
Comment 1 Zamundaaa 2022-07-16 15:31:58 UTC
So I looked through Mesa and the only situation I can see where EGL_BAD_ALLOC can be caused is when the surface never got rendered to. In KWin all code paths do render to the cursor surface though...
Are there any other errors or warnings from kwin in the log?
Comment 2 postix 2022-07-16 16:50:57 UTC
Created attachment 150678 [details]
journalctl | grep -i kwin > journalctl.txt

(In reply to Zamundaaa from comment #1)
> Are there any other errors or warnings from kwin in the log?

Yes there are. Here's the journalctl output regarding kwin for the last two days. 
There are often but not always the following log lines

`kwin_wayland[2823]: QMetaProperty::read: Unable to handle unregistered datatype 'KWin::SessionState' for property 'KWin::EffectsHandlerImpl::sessionState'`

or 

`kwin_screencast: Dropping a screencast cursor update because the compositor is slow`

 followed by 

`kwin_wayland_drm: an error occurred while swapping buffers "EGL_BAD_ALLOC"`

At least that is what was most obvious to me at a first glance. Thanks for looking into it.
Comment 3 postix 2022-07-16 16:56:58 UTC
Regarding the SUMMARY of the OT: The EGL error is not always reported when moving the cursor. So at this state, it's not clear to me by what the issue is initially triggered.
Comment 4 Zamundaaa 2022-07-23 12:23:07 UTC
The warning will only be printed when the cursor image changes, as that's the only time that KWin tries to repaint the cursor.
Of the other warnings, none are really relevant.

One thing we can try is if you put
> KWIN_DRM_NO_AMS=1
into /etc/environment and reboot. Do the warnings go away with that?
Comment 5 postix 2022-07-25 12:17:29 UTC
I had seen it between Jun 16 and Jul 15, but the issue seem to have disappeared since then. I will change the status of the report to "waiting for info" and add the requested information whenever it appears again.
Comment 6 Bug Janitor Service 2022-08-09 04:35:33 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Zamundaaa 2022-08-12 15:25:01 UTC
So this warning is now appearing on my laptop as well, it happens after I plug in a new monitor and then remove it again.
The cause is that one or even two of the cursor buffers got stored on the plane for the second monitor and never released, which sometimes causes Mesa to run out of buffers for the surface.
Comment 8 Bug Janitor Service 2022-08-12 15:26:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2814
Comment 9 Zamundaaa 2022-08-12 20:09:03 UTC
Git commit f4e917f734056d9e957aeb2af7e9687a4beb7bc8 by Xaver Hugl.
Committed on 12/08/2022 at 19:52.
Pushed by zamundaaa into branch 'master'.

backends/drm: release buffers for disabled objects

M  +1    -0    src/backends/drm/drm_object_plane.cpp
M  +9    -2    src/backends/drm/drm_pipeline.cpp

https://invent.kde.org/plasma/kwin/commit/f4e917f734056d9e957aeb2af7e9687a4beb7bc8