Find a file
Pekka Paalanen 853aa1c564 backend-drm: destroy_sprites() after outputs
I want to consolidate 'struct drm_device' destruction into a single
function in the next patch, and that function needs to be usable for
both the primary device drm_backend::drm, and the secondary KMS devices
drm_backend::kms_list.

Sprites, a.k.a drm_planes, are objects fundamentally owned by their
drm_device. To encapsulate drm_device destruction into a single function
(that assumes that all outputs on that device are already destroyed),
one cannot call destroy_sprites() from drm_shutdown() anymore - it
logically belongs in drm_device_destroy().

The problem is that that will reverse the order of destroying drm_planes
vs. output (GBM) surfaces. drm_plane_state holds a reference to drm_fb
which points to a GBM BO that was received from a GBM surface. When the
GBM surface is destroyed, all its GBM BOs are destroyed as well, which
will cause all drm_fb pointing to them to be destroyed as well
regardless of drm_fb reference count. Therefore, if any object was
thought to hold a reference to a drm_fb, it now holds a dangling
pointer.

Why is drm_output_deinit() not clearing the drm_plane state it used,
releasing all the drm_fb references? And do that before destroying the
GBM surface?

Because drm_output_deinit_planes() explicitly skips clearing the
drm_plane state during compositor shutdown, because during shutdown the
drm_planes have already been destroyed.

If we change both, we get a much simpler tear-down logic:

- drm_output_deinit_planes() will always clear drm_plane states, no
  special handling for shutdown (which is an elaborate way of saying
  "before outputs are destroyed").

- drm_output_deinit() calls drm_output_deinit_planes() before it
  destroys the GBM surface, which ensures no dangling drm_fb pointers
  are left.

- destroy_sprites() call is moved *after* destruction of outputs where
  it logically belongs.

This also means that the per-renderer fini functions do not need to
clean up manually when the compositor is not shutting down. They can
just assert the scanout_plane has already been cleaned up.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-02-27 10:19:21 -06:00
.gitlab-ci gitlab-ci: Bump mesa from 25.3.0 to 25.3.2 2025-12-19 18:52:26 +01:00
clients clients/window: Fix segfault when dragging with touchscreen 2026-02-09 00:32:42 -08:00
data clients/ivi-shell-user-interface.c: Add 'command' config 2024-12-04 12:36:20 +00:00
desktop-shell Revert "desktop-shell: Add a placeholder curtain on new outputs" 2025-10-27 05:55:51 +00:00
doc doc: Fix index.rst still mentioning Weston ref compositor 2026-02-25 11:01:14 +02:00
frontend add NLA support an the nla-ntlm-db option 2026-02-23 13:30:29 +02:00
fullscreen-shell compositor/shells: Require shells to flag outputs as ready to allow repaint 2025-10-27 05:55:51 +00:00
include add NLA support an the nla-ntlm-db option 2026-02-23 13:30:29 +02:00
ivi-shell ivi-shell: Remove black curtain/set output ready in HMI controller 2025-10-27 05:55:51 +00:00
kiosk-shell compositor/shells: Require shells to flag outputs as ready to allow repaint 2025-10-27 05:55:51 +00:00
libweston backend-drm: destroy_sprites() after outputs 2026-02-27 10:19:21 -06:00
lua-shell lua-shell: Use local pd to store background curtains 2026-01-09 22:12:47 +02:00
man add NLA support an the nla-ntlm-db option 2026-02-23 13:30:29 +02:00
pam libweston: Add user authentication support via PAM 2022-11-23 16:58:48 +01:00
pipewire backend-drm,pipewire,remoting: do not set monitor serial to "unknown" 2023-09-15 06:56:59 +00:00
protocol libweston: Implement color-representation protocol 2025-12-19 17:08:29 +01:00
remoting Revert "shared/helpers.h: Migrate helpers.h to libweston" 2025-01-17 10:18:26 +02:00
shared shared: add safe_strtofloat() 2025-10-09 16:17:57 +00:00
subprojects libweston: Add support for perfetto profiling 2025-01-24 12:22:13 +00:00
tests tests: weston-test-assert needs is_pow2_64() 2026-02-23 13:55:53 +02:00
tools tests: Remove zunitc testing framework 2025-02-26 23:50:45 +01:00
wcap build: simplify include_directories 2019-10-04 17:14:22 +03:00
westinyplus meson.build: Bump libweston to 15 2025-03-07 14:30:20 +00:00
xwayland xwayland: Fix some memory leaks on compositor shutdown path 2025-12-15 11:35:04 +02:00
.editorconfig Fix .editorconfig: use tabs for Meson files 2019-02-18 11:21:07 +01:00
.gitignore gitignore: Ignore the build/ directory. 2021-07-06 18:46:09 +00:00
.gitlab-ci.yml gitlab-ci: Bump mesa from 25.3.0 to 25.3.2 2025-12-19 18:52:26 +01:00
.mailmap Add a .mailmap file 2023-03-25 11:18:10 -05:00
CONTRIBUTING.md CONTRIBUTING.md: Fix link for patchwork 2023-04-20 09:46:51 +03:00
COPYING COPYING: Specify origin of the library 2015-06-15 13:04:19 -07:00
DCO-1.1.txt contributing: add copy of DCO 2019-07-16 11:43:57 +00:00
meson.build build: drop redundant Meson version check 2026-02-23 13:53:18 +02:00
meson_options.txt backend-drm: Deprecate DRM VA-API recorder 2025-10-28 07:55:43 +00:00
notes.txt notes: fix a typo 2017-01-03 11:59:01 +00:00
README.md frontend: Use short-form names for shell argument 2023-01-10 10:53:02 +02:00
RELEASING.md releasing.md: Add a section about using glab client 2026-02-26 11:56:13 +00:00
weston.ini.in doc: Update to the new --no-resizable RDP flag 2025-06-04 15:38:05 -04:00

Weston

screenshot of skeletal Weston desktop

Weston is a Wayland compositor designed for correctness, reliability, predictability, and performance.

Out of the box, Weston provides a very basic desktop, or a full-featured environment for non-desktop uses such as automotive, embedded, in-flight, industrial, kiosks, set-top boxes and TVs.

It also provides a library called libweston which allows users to build their own custom full-featured environments on top of Weston's core.

Building Weston

Weston is built using Meson. Weston often depends on the current release versions of Wayland and wayland-protocols.

If necessary, the latest Meson can be installed as a user with:

$ pip3 install --user meson

Weston's Meson build does not do autodetection and it defaults to all features enabled, which means you likely hit missing dependencies on the first try. If a dependency is avoidable through a build option, the error message should tell you what option can be used to avoid it. You may need to disable several features if you want to avoid certain dependencies.

$ git clone https://gitlab.freedesktop.org/wayland/weston.git
$ cd weston
$ meson build/ --prefix=...
$ ninja -C build/ install
$ cd ..

The meson command populates the build directory. This step can fail due to missing dependencies. Any build options you want can be added on that line, e.g. meson build/ --prefix=... -Ddemo-clients=false. All the build options can be found in the file meson_options.txt.

Once the build directory has been successfully populated, you can inspect the configuration with meson configure build/. If you need to change an option, you can do e.g. meson configure build/ -Ddemo-clients=false.

Every push to the Weston master repository and its forks is built using GitLab CI. Reading the configuration may provide a useful example of how to build and install Weston.

More detailed documentation on building Weston is available on the Wayland site. There are also more details on how to run and write tests.

For building the documentation see documentation.

Running Weston

Once Weston is installed, most users can simply run it by typing weston. This will launch Weston inside whatever environment you launch it from: when launched from a text console, it will take over that console. When launched from inside an existing Wayland or X11 session, it will start a 'nested' instance of Weston inside a window in that session.

By default, Weston will start with a skeletal desktop-like environment called desktop-shell. Other shells are available; for example, to load the kiosk shell designed for single-application environments, you can start with:

$ weston --shell=kiosk

Help is available by running weston --help, or man weston, which will list the available configuration options and display backends. It can also be configured through a file on disk; more information on this can be found through man weston.ini.

A small suite of example or demo clients are also provided: though they can be useful in themselves, their main purpose is to be an example or test case for others building compositors or clients.

Using libweston

libweston is designed to allow users to use Weston's core - its client support, backends and renderers - whilst implementing their own user interface, policy, configuration, and lifecycle. If you would like to implement your own window manager or desktop environment, we recommend building your project using the libweston API.

Building and installing Weston will also install libweston's shared library and development headers. libweston is both API-compatible and ABI-compatible within a single stable release. It is parallel-installable, so multiple stable releases can be installed and used side by side.

Documentation for libweston's API can be found within the source (see the documentation section), and also on Weston's online documentation for the current stable release.

Reporting issues and contributing

Weston's development is hosted on freedesktop.org GitLab. Please also see the contributing document, which details how to make code or non-technical contributions to Weston.

Weston and libweston are not suitable for severely memory-constrained environments where the compositor is expected to continue running even in the face of trivial memory allocations failing. If standard functions like malloc() fail for small allocations, you can expect libweston to abort. This is only likely to occur if you have disabled your OS's 'overcommit' functionality, and not in common cases.

Documentation

To read the Weston documentation online, head over to the Weston website.

For documenting weston we use sphinx together with breathe to process and augment code documentation from Doxygen. You should be able to install both sphinx and the breathe extension using pip3 command, or your package manager. Doxygen should be available using your distribution package manager.

Once those are set up, run meson with -Ddoc=true option in order to enable building the documentation. Installation will place the documentation in the prefix's path under datadir (i.e., share/doc).

Adding and improving documentation

For re-generating the documentation a special docs target has been added. Although first time you build (and subsequently install) weston, you'll see the documentation being built, updates to the spinx documentation files or to the source files will only be updated when using docs target!

Example:

$ ninja install # generates and installs the documentation
# time passes, hack hack, add doc in sources or rST files
$ ninja install # not sufficient, docs will not be updated
$ ninja docs && ninja install # run 'docs' then install

Improving/adding documentation can be done by modifying rST files under doc/sphinx/ directory or by modifying the source code using doxygen directives.