Skip to content

Video area flickers during playback on Linux/NVIDIA/Wayland when Ambient blur is enabled (toImage() imports media_kit GL texture into a second GrContext) #1148

Description

@kasztral

Description

When Ambient blur is enabled, the video area of the player flickers (the surrounding UI stays intact) during hardware-accelerated playback on Linux + NVIDIA + Wayland. The UI chrome is stable — only the video texture blinks/stutters, roughly every few seconds, in bursts.

Root cause is in the ambient blur implementation: it forces Skia to import media_kit's foreign OpenGL texture into a second GrContext, which is invalid across GL contexts and produces corrupted/stale frames on NVIDIA.

Relevant code:

  • lib/screens/video_player/video_player.dart:126 — when ambientBlur is on, a second Video widget (VideoPlayerBlur) for the same media_kit controller is rendered inside a RepaintBoundary.
  • lib/widgets/shared/ambient_blur.dart:97 — boundary.toImage() runs every 4 seconds (re-triggered by the blend controller's status listener) to build the blurred backdrop, i.e. a GPU readback of a subtree containing the foreign GL texture.

The Skia warning below was captured at the exact second the first flicker appeared:

GrBackendTextureImageGenerator: Trying to use texture on two GrContexts!

Additionally, the capture path itself sometimes throws:

AmbientBlur capture error: Null check operator used on a null value

Disabling Ambient blur stopped the flicker completely (8+ minutes of clean playback, hardware acceleration left on). The in-app warning for this setting only mentions performance, not flickering.

Possible fix directions: avoid toImage() on a subtree containing the video Texture (e.g. capture the backdrop via mpv's own screenshot API, or skip the duplicate VideoPlayerBlur widget readback on desktop/GL platforms).

Possibly related upstream: flutter/flutter#179322 and media-kit/media-kit#1325 (same class of cross-context FlTextureGL artifacts).

Reproduction steps

1. Settings → Player → enable "Ambient blur"
2. Confirm "Hardware acceleration" stays enabled (default)
3. Play any video (streamed, direct play)
4. Watch the video area: it flickers periodically while the UI remains stable
5. Settings → Player → disable "Ambient blur"
6. Replay: flicker is gone, playback stays hardware accelerated

Screenshots

n/a — visual artifact, not reproducible in a static screenshot.

Logs

Captured with flatpak run nl.jknaapen.fladder while the flicker occurred:

media_kit: VideoOutput: Using H/W rendering.
GrBackendTextureImageGenerator: Trying to use texture on two GrContexts!
AmbientBlur capture error: Null check operator used on a null value
media_kit: TextureGL: Resize: (1920, 1080)

No EGL/GL errors before, during, or after — only the two GrContexts warning lines up with the flicker.

Platform

Linux — GNOME on Wayland, Fedora 44, NVIDIA RTX 3050, driver 615.71.09.

App version

Fladder v0.11.1 (Flathub Flatpak, runtime org.freedesktop.Platform 26.08, Flutter 3.35.7)

Jellyfin server

Local server behind Nginx Proxy Manager, direct play (not a factor — the bug is client-side rendering; it reproduces with ambient blur on/off as the only variable).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions