Skip to content

ClutterShaderEffect never releases offscreen buffer once applied to a ClutterActor #865

Description

@programmer2514

Distribution

Mint 22.3

Package version

6.6.9

Graphics hardware in use

NVIDIA GeForce RTX 3070 Mobile Max-Q

Frequency

Always

Bug description

[ Note: I have only attempted this via CJS, so perhaps it is an issue there? ]

ClutterShaderEffects allocate VRAM for an offscreen buffer when applied to a ClutterActor. However, once the effect and actor are both dereferenced and destroyed, the buffer's VRAM remains allocated indefinitely.

Steps to reproduce

Here is a minimal Cinnamon extension to reproduce the issue:

const Clutter = imports.gi.Clutter;
const Main = imports.ui.main;

function init() {}

function enable() {
  // Create dummy Actor with a reasonable texture size
  this.actor = new Clutter.Actor({ width: 1920, height: 1080 });
  Main.uiGroup.add_child(this.actor);

  // Add 100 ShaderEffects to the dummy Actor
  for (let i = 0; i < 100; i++) {
    let effect = new Clutter.ShaderEffect();
    effect.set_shader_source('void main() { cogl_color_out = vec4(0); }');
    this.actor.add_effect(effect);
  }
}

function disable() {
  // Remove all ShaderEffects and delete actor
  this.actor.clear_effects();
  Main.uiGroup.remove_child(this.actor);
  delete this.actor;
}

Before enabling the extension:

After enabling the extension:

After disabling the extension:

Each subsequent enable/disable cycle leaks an additional ~1GB of VRAM until it overflows and Cinnamon crashes.

Expected behavior

Buffer VRAM allocated by a ClutterShaderEffect should be freed when the object allocating it is dereferenced.

Additional information

I have already ensured that the ClutterShaderEffect/ClutterActor objects are being properly dereferenced by storing them all in an array, explicitly calling unref() on each, ensuring ref_count drops to 0, and setting each object to null before deleting the array.

This issue also appears when using currently published and popular extensions such as "Blur Cinnamon" that make use of ClutterShaderEffect, and can destabilize the entire desktop environment in a matter of minutes.

This occurs on both the dGPU (RTX 3070 Max-Q; VRAM) and the iGPU (TigerLake-H GT1 UHD; system RAM) of my laptop, so it is not an issue with the NVIDIA graphics driver.

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