Bug 477027 - Changing the screen dimensions while an effect is open causes the effect to go black
Summary: Changing the screen dimensions while an effect is open causes the effect to g...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: master
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-11-15 05:13 UTC by Devin Lin
Modified: 2023-11-21 19:22 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Lin 2023-11-15 05:13:37 UTC
SUMMARY
When the screen dimensions change while an effect is open, the effect goes black. This is easily triggered from Plasma Mobile by opening the task switcher and rotating the phone.

STEPS TO REPRODUCE
1. Open Plasma in a window (KWin windowed mode)
2. Open an effect (ex. Overview)
3. Resize the window

Video: https://invent.kde.org/teams/plasma-mobile/issues/uploads/67f94e91afee245c39a51ba140f8140b/Screencast_20231113_203755.webm

OBSERVED RESULT
The screen goes black

EXPECTED RESULT
The screen doesn't go black

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora
(available in About System)
KDE Plasma Version: git master
KDE Frameworks Version: git master
Qt Version: 6.6

ADDITIONAL INFORMATION
https://invent.kde.org/teams/plasma-mobile/issues/-/issues/229
Comment 1 Zamundaaa 2023-11-15 12:20:46 UTC
Can confirm. The log spams
> kwin_scene_opengl: 0x3: GL_INVALID_OPERATION in glBindBuffer(non-gen name)
on every rendered frame, so presumably something's wrong with the code blitting the effect results to the screen
Comment 2 Bug Janitor Service 2023-11-21 14:57:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4681
Comment 3 Vlad Zahorodnii 2023-11-21 19:22:17 UTC
Git commit 6a997b41ae9acccaba8169eb69c354774085fd00 by Vlad Zahorodnii.
Committed on 21/11/2023 at 20:11.
Pushed by vladz into branch 'master'.

Fix screen becoming black when its geometry changes while overview is active

Offscreen quick views are repainted in the pre paint step because that
requires a QOpenGLContext and we don't want it to mess with kwin's
opengl context. After a view is updated, its QOpenGLContext is going to
be unbound.

During normal operation mode, it works as expected:

- the view gets updated in the pre paint stage
- kwin opengl context is made current when starting the paint stage
- the offscreen view is painted on the screen

However, effects->renderScreen() has no such separation. The OpenGL
context changes from the pre paint stage will leak to the paint stage.
So we have

- the workspace notifies that the screens have changed
- the screen transform effect sees that, makes opengl context current
  and renders the screen
- the offscreen quick view is updated and after OffscreenQuickView
  is done, it's going to call QOpenGLContext::doneCurrent()
- effects->renderScreen() calls m_scene->paint()
- since there's no current opengl context, vbo allocation in
  GLTexture::render() will fail and nothing will be rendered on the
  screen

As a way around it, this change adds a makeOpenGLContextCurrent() call
before the paint stage. It doesn't quite belong there, the opengl
context has to be made current in the paint stage, e.g. by the
ItemRenderer or something. But atm we have no good place where we
could stick it in.

M  +5    -1    src/effect/effecthandler.cpp

https://invent.kde.org/plasma/kwin/-/commit/6a997b41ae9acccaba8169eb69c354774085fd00