https://bugs.kde.org/show_bug.cgi?id=519884

            Bug ID: 519884
           Summary: Mali-T860/Panfrost: client surfaces (video) composited
                    as black, presentation feedback claims success
    Classification: Plasma
           Product: kwin
      Version First unspecified
       Reported In:
          Platform: Debian stable
                OS: Linux
            Status: REPORTED
          Severity: major
          Priority: NOR
         Component: wayland-generic
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 192111
  --> https://bugs.kde.org/attachment.cgi?id=192111&action=edit
The video player

# KWin 6.3.6 + Mali-T860 (Panfrost): video surfaces composited as black despite
presentation feedback claiming success

## Summary

On a NanoPi M4V2 (Rockchip RK3399) with Mali-T860 GPU on the Panfrost driver
(Mesa 25.0.7-2), all Wayland clients that present video-sized surfaces produce
a black region in KWin's composited output. KWin's `wp_presentation_feedback`
protocol replies with `presented` and `flags=0x7` (VSYNC | HW_CLOCK |
HW_COMPLETION),
i.e. claims the buffer was scanned out, but a screenshot taken via Spectacle
(which captures KWin's framebuffer, not the scanout) shows the surface area as
black. The window decorations and other surfaces composite correctly.

The failing path is reproducible across every Wayland client surface tested:
`mpv --vo=dmabuf-wayland`, `mpv --vo=gpu`, `mpv --vo=gpu-next`, and even
`mpv --vo=wlshm` (CPU-rendered SHM, no dmabuf at all). Direct DRM/KMS output
(`mpv --vo=drm` from a TTY, bypassing KWin) works perfectly with the same
hardware decode pipeline. Software-rendered RGB test patterns at small sizes
(`mpv lavfi:testsrc size=1280x720`) display correctly through KWin; full-screen
sized YUV/RGB video does not.

## Environment

| Component | Version |
|---|---|
| OS | Armbian 26.2.1 trixie (Debian 13) |
| Kernel | 6.18.10-current-rockchip64 |
| KWin | 6.3.6-1 (Debian package) |
| Plasma | 6.3.6 |
| Session type | Wayland |
| GPU | Mali-T860 (Panfrost) |
| Mesa | 25.0.7-2 |
| Display | Fujitsu Siemens P24-9 TE, 1920x1080 @ 60 Hz |
| Test client | mpv 0.38.0 (Kwiboo v4l2request fork, custom build) |

`KWin support information` excerpt:
- Compositing Type: OpenGL
- OpenGL renderer string: Mali-T860 (Panfrost)
- GLSL: 1.40, GLES: 3.10
- Direct rendering: yes
- compositingMode: 1, useCompositing: true, allowTearing: true

## Steps to reproduce

1. Boot Plasma 6.3.6 Wayland session on Mali-T860 + Panfrost.
2. Play any 1080p video with any Wayland video output:
   ```
   mpv --vo=dmabuf-wayland --hwdec=v4l2request video.mkv
   mpv --vo=gpu video.mkv
   mpv --vo=wlshm video.mkv
   ```
3. Observe the mpv window: decorations are correct, video region is black.
4. Take a screenshot with Spectacle (`spectacle -b -n -o /tmp/shot.png`).
5. Open the screenshot — the video region is black there too.

## Expected behaviour

mpv's video frames composite into the window and become visible.

## Actual behaviour

- mpv window decorations are correctly drawn.
- Surface region remains black.
- After seeking, **one or two frames flash briefly**, then back to black.
- Audio plays normally.
- KWin sends `wp_presentation_feedback.presented` with flags `0x7` for
  most committed frames as if scanout succeeded.

## Diagnostic data — instrumented mpv

I added `fprintf(stderr, ...)` prints to mpv's `video/out/wayland_common.c`
at `frame_callback`, `feedback_presented`, `feedback_discarded`, and the
`vo_wayland_wait_frame` loop. Over ~5 s of playback (expecting ~120 frames
at 24 fps):

```
frame_callback FIRED:           29
feedback_presented (success):   25
feedback_DISCARDED:              3
vo_wayland_wait_frame TIMED OUT: many
```

KWin reports 25 frames presented in 5 s yet none reached the screen. Sample
log shows large gaps and bursts inconsistent with steady 60 Hz scanout:

```
[DIAG] frame_callback FIRED (time=513556)
[DIAG] frame_callback FIRED (time=513640)   +84  ms
[DIAG] frame_callback FIRED (time=513706)   +66  ms
[DIAG] frame_callback FIRED (time=514807)   +1101 ms ← stall
...
[DIAG] frame_callback FIRED (time=575181)
[DIAG] frame_callback FIRED (time=575214)   +33  ms
[DIAG] frame_callback FIRED (time=575231)   +17  ms ← faster than 60 Hz!
[DIAG] frame_callback FIRED (time=575264)   +33  ms
```

The full log is available on request.

## What this rules out

- **Hardware decoder**: `mpv --vo=drm --hwdec=v4l2request` from a Linux TTY
  plays the same file flawlessly using the same custom mpv binary. The
  rkvdec → v4l2request → NV12 dmabuf pipeline is fine outside KWin.
- **Mali rendering**: `mpv lavfi:testsrc size=1280x720` (RGB, software
  generated) displays correctly through KWin. Mali GL composition works
  for small/RGB surfaces.
- **mpv buffer submission**: Diagnostic prints confirm mpv submits buffers,
  receives frame callbacks, and successfully completes `vo_wayland_wait_frame`
  — but the result is black on screen.
- **Scanout/display path**: A Spectacle screenshot of the desktop (which
  captures KWin's compositor framebuffer, not the kernel scanout) also
  shows the surface region as black. The frame is not on screen because
  it's not in the composited image.

## Hypothesis

Either:

1. KWin's EGL dmabuf import on Mali Panfrost (`src/opengl/egldisplay.cpp`
   lines 215 / 236, calling `eglCreateImageKHR` with `EGL_LINUX_DMA_BUF_EXT`)
   silently produces a sampler that resolves to black for client video
   buffers, while still appearing valid to KWin. **But this cannot fully
   explain the bug** — `vo=wlshm` uses `wl_shm` not dmabuf and is also black.

2. KWin's `SurfaceItemWayland` GL texture creation path for client buffers
   produces an opaque-black texture on Panfrost when the surface is large
   relative to the screen. Could be related to GLES texture-size limits or
   an external_only/YUV format path.

3. The `wp_presentation_feedback_send_presented` call in
   `src/wayland/presentationtime.cpp:86` is reached unconditionally after
   the next page-flip, regardless of whether the surface's texture was
   actually included in the composited frame.

The combination of (1) "wlshm is also black" and (3) "presentation feedback
reports success" suggests two distinct bugs, or one bug in a layer common
to all client-buffer types (e.g. `SurfaceItemWayland::updateTexture()`).

## Workaround for affected users

Use direct DRM/KMS output, bypassing KWin:
```
sudo mpv --vo=drm --hwdec=v4l2request video.mkv  # from a TTY
```

## Reproducer hardware availability

NanoPi M4V2 + Mali-T860 + Panfrost is widely available. I am happy to run
further diagnostics, additional patches, or builds on this hardware to
help isolate the problem.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to