Skip to content

Deprecate Shell.GenericContainer

Description

Shell.GenericContainer is a workaround added back in time to allow overriding the size negotiation vfuncs (get_preferred_width, get_preferred_height, andallocate) from JavaScript side.

Over time, however, GJS gained the ability to override vfuncs, but the workaround was never removed. This merge request removes all the usages of Shell.GenericContainer throughout the codebase.

Justification

Shell.GenericContainer exposes the size negotiation machinery through the use of signals. Signals are not specially performant. One of the reasons is that they acquire a global lock for signal handlers lookup. GNOME Shell has more than 2,000 actors at any given point in time, up to 20 levels deep in hierarchy, making size negotiation and painting non-trivial tasks. Such a critical section of Clutter's machinery shouldn't rely on signals whatsoever.

Besides that, Shell.GenericContainer is a workaround to a non-existing issue anymore. It shouldn't be used anyway, regardless of any performance improvements that removing it can potentially yield.

Details

Most of the work of removing this class were centered in turning the JavaScript classes that used it into St.Widget subclasses. That way, it was possible to override the size negotiation vfuncs.

The this.actor pattern was kept for compatibility purposes -- even though the JavaScript classes are the actors themselves. This is mainly to avoid breaking extensions. Even if the pattern was kept, internally, all the foo.actor usages were converted to only foo.

The commit messages, in particular the first ones, expose the challenges and solutions of removing this class. Fortunately, no outstanding hacks were introduced, and overall the code looks cleaner.

Performance

This merge request may have a small but consistent performance benefit. In average, the framerate became more stable and predictable. In addition to that, it became slightly shorter. That leads to better framerate measurements over time:

ShellGenericContainer

When using Shell.GenericContainer, the framerate is more unstable compared to this branch. There are moments where the framerate matches this work, but most of the time, it sits comfortably below it. Early results give an improvement of about 3~6 FPS when running GNOME Shell animations, like the spring animation of the Icon Grid, or moving in and out of the Overview.

Other random findings:

  • The icon grid itself loads faster with this branch. This is the first data point in the graph.
  • There are still stutterings when running the app grid spring animation, but they're apparently shorter and less proeminent. It is likely that this will be most affected by !22 (merged).
  • Overview animations are smoother with lots of windows opened here.

To Do

  • Fix remaining issues
  • Measure performance improvements
  • Test more
Edited by Georges Basile Stavracas Neto

Merge request reports