Commit graph

7679 commits

Author SHA1 Message Date
Pekka Paalanen 90687e1fc6 libweston: fix weston_view::geometry.parent comment
There is no weston_surface_set_transform_parent(), it is called
weston_view_set_transform_parent() now since
a7af70436b .

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-01-24 14:26:47 +02:00
Marius Vlad 3151220a9b clients/simple-*: Add appids for other clients
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 18:39:23 +00:00
Marius Vlad b3544c26ad clients/window: Add functions to set/retrieve app_id
Adds appid for all clients using the toolkit, flower, fullscreen, image,
resizor, scaler, smoke, stacking, subsurfaces, terminal,
touch-calibrator, transformed, etc.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 18:39:23 +00:00
Derek Foreman 713f02327d compositor: Fix opaque regions
Commit 0e4f097d broke opaque regions, and since then weston will waste
time rendering occluded areas.

I think this is because we're taking the intersection of the opaque
and scissor regions even when the scissor region isn't enabled.

An easy test is to turn on triangle fan debugging with the gl renderer,
then run weston-simple-damage and move another opaque application such as
weston-terminal over it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-21 15:44:32 +00:00
Marius Vlad 349252788f doc/sphinx/conf.py.in: Remove year and use VERSION
Just avoid using years as that will not age well. VERSION follows
the libweston version.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 12:14:21 +00:00
Marius Vlad 4e003626cf running-weston.rst: Document how to run weston as user service
With the recent changes, weston could be started as user service. This
adds some examples and howtos one might do that. Includes some simple
systemd unit files.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-21 12:14:21 +00:00
Leandro Ribeiro b985c6bf83 tests: fix leak in drm-smoke-test.c
Leak found running drm-smoke-test with ASan.

Do not forget to destroy the SHM buffer by the end of the test.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-01-21 11:49:34 +00:00
Leandro Ribeiro 5911d2a762 tests: fix leak when we won't run DRM-backend tests
This fixes a leak found running drm-smoke-test with ASan. Do not forget
to call prog_args_fini() when:

- skipping DRM-backend tests because we don't have
  WESTON_TEST_SUITE_DRM_DEVICE set.

- we fail to acquire the lock needed to run DRM-backend tests.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-01-21 11:49:34 +00:00
Leandro Ribeiro d42fa30d14 launcher: fix leak in launcher_weston_launch_connect()
Leak found running drm-smoke-test with ASan.

Do not forget to free the launcher before returning when we can't open
the launcher fd. Also, just set 'out = launcher' after all error paths,
otherwise we give the caller a stale pointer.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-01-21 11:49:34 +00:00
Leandro Ribeiro bd4f250d48 compositor: fix leak in load_drm_backend()
Leak found running drm-smoke-test with ASan.

Do not forget to free string specific_device in load_drm_backend().

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2022-01-21 11:49:34 +00:00
Derek Foreman c826d8fa0d xwayland: Fix user after free on shutdown
We need to remove our listener link before we free the structure
it's inside, or the signal list walk will try to dereference it.

Remove the improbable NULL check at the same time.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-21 11:42:03 +00:00
Marek Vasut 6c2646e967 screen-share: Fix start-on-startup config option handling
The code currently checked the return value of weston_config_section_get_bool()
which is incorrect. The return value of weston_config_section_get_bool() is
zero whether the config option is present or not, and it is non-zero in case
the config option is not present.

The code must check whether the config option is either true or false,
or in case the option is not present then default to false. Adjust the
code accordingly.

Reviewed-by: Marius Vlad <marius.vlad@collabora.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2022-01-21 11:35:07 +00:00
Derek Foreman f079f43658 clients/window: Fix animated cursors
Since commit 992ee045f1 we create a new surface when we update the cursor
image. This broke animated cursors by discarding any existing frame
callback used for timing, and moving the setup for frame callbacks to
after the commit on the pointer surface.

To fix this we need another surface commit for the frame callbacks, but
this alone is not enough to fix the regression, as a lingering kludge
intended to fix problems when reusing the pointer surface is no longer
working as intended.

Since we no longer re-use the same surface, we can delete the old surface
on pointer exit, along with any callbacks set on it. Then a frame callback
will be recreated naturally. This lets us remove the now broken kludge
from the past and restore animated cursor functionality.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-20 10:23:59 +00:00
Derek Foreman 3759ad1538 tests: Fix use after free on exit
We need to unlink this before freeing it since it's being called from
weston_signal_emit_mutable.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-01-19 10:55:04 -06:00
Daniel Stone 37a0544edf backend-wayland: Destroy touch device before seat
weston_touch_destroy(), which is called from weston_seat_release(),
asserts that all its touch devices have been destroyed. The Wayland
backend currently destroys the touch devices ... immediately after
calling weston_seat_release().

Invert the ordering so that touch devices are destroyed first and we
don't trip over the assert.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-01-15 14:25:40 +00:00
Simon Ser 2c1ed289e6 build: bump to version 9.0.92 for the beta release 2022-01-12 15:03:11 +01:00
Marius Vlad bb55d86300 backend-drm/drm-gbm: gbm_device_destroy on an invalid gbm device
When EGL initialization fails (failure to create a GLES3 or GLES2
context) we will end up calling gbm_device_destroy() twice, once
in init_egl() and once in the drm_backend_create() error path.

Given that we should also take care of properly destroying the gbm
device when we don't have any inputs for instance, mark the gbm device
as NULL to avoid calling gbm_device_destroy() once more when destroying
the DRM-backend.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-12 13:52:26 +00:00
Marius Vlad 3c5e6c536f clients/meson:build: Conditionally build dmabuf-feedback client
As mesa includes gbm_bo_get_fd_for_plane() from 21.1.0 version onwards,
build the dma-buf feedback client only after that. This should provide
some sanity for package maintainers, as this would need pulling a
rather newer mesa version to build it (which might not be available).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-12 13:39:04 +00:00
Marius Vlad 9b82be0792 simple-egl: Don't set-up alpha for opaque/fullscreen
When setting the window as opaque or fullscreen (which creates an opaque
region) make it so we don't have any alpha pixels set.
This was mistakenly dropped from a previous patch series update to
simple-egl.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-01-12 13:35:31 +02:00
Marius Vlad c3f7a496a6 kiosk-shell: Do not leave views on layers on shell destroy
Nothing special, but avoids hitting the warning about
terminating/finishing a layer with views on it.

Fixes #509.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-17 11:08:26 +02:00
Marius Vlad d25d63e692 desktop-shell: Do not leave views in layers upon shell destruction
This properly takes care of removing any of the views being added into
different layers upon shell destruction. Aggregates the shell_surface
destruction into one place to make things much more clearer. Keep  the
animation part only the weston_desktop_surface destruction rather than
doing it at shutdown.

Fixes #509.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-17 11:04:28 +02:00
Marius Vlad f2452d6006 libweston: Convert remaning destroy signals
Replaces potential corruption signal emit call sites with the more safer
weston_signal_emit_mutable().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Marius Vlad ee5716798a tests/safe-signal-output-removal: Add test for output removal
This simulates an output removal which should trigger a crash when
the compositor is shutdown abruptly by having a view with a listener installed
on its output_destroy signal.

This patch assumes that weston_compositor_remove_output() has already
been amended to use the more safer version for triggering signal
emission.

As both shells use this construct it should catch any potential signal
corruption.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Marius Vlad 2015dfc325 compositor: Fix removal of an output
This uses the more safer version of signal emission to avoid a potential
crash when the output is destroyed that will follow a surface/view
destruction for which it has a listener attached (to the output_destroy
signal).

Fixes: #734

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Alexandros Frantzis fa48c5ee41 libweston: Use weston_signal_emit_mutable for surface destruction
This avoids crashes due to removal of notification listeners from within
invocations of other listener callbacks in the same signal emission.

Fixes: #415

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-12-14 17:55:06 +00:00
Marius Vlad 990173050c test/safe-signal: Add a basic test for weston_signal_emit_mutable
Basic test to verify that weston_signal_emit_mutable() would not
corrupt the signal list.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-14 17:55:06 +00:00
Alexandros Frantzis 8b6daa41ab libweston: Introduce a safer wayland signal emission
Wayland signals (wl_signal) do not reliably handle changes to the
notification list during signal emission. Such scenarios occasionally
come up and can be difficult to investigate and debug.

This commit introduces the weston_signal_emit_mutable() function which can be
used in place of wl_signal_emit() and safely implements the following
behavior regarding notification list changes:

1. Listeners deleted during a signal emission and which have not already been
   notified at the time of deletion are not notified by that emission.

2. Listeners added during signal emission are ignored by that emission.

The implementation of weston_signal_emit_mutable() is copied from the
wlr_signal_emit_safe() function of the wlroots project.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2021-12-14 17:55:06 +00:00
Daniel Stone 23f7e26978 tests/xwayland: Remove manual timeout implementation
One of the best things about a real test framework is that they handle
timeouts for you.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Simon Ser <contact@emersion.fr>
2021-12-14 14:57:40 +00:00
Simon Ser 1cca054ddb build: bump to version 9.0.91 for the alpha release 2021-12-14 15:07:47 +01:00
Marius Vlad 07326040b9 .gitlab-ci: Retrieve return value before any other command
This was previously introduced with commit '.gitlab.ci: Enable debug for
libsteat and for the DRM backend' in order to figure out another CI
issue we were seeing.

Unfortunatelly, not keeping the return value after the tests ran it
would silently make the entire CI succeed when it should actually fail.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-12-13 14:48:46 +02:00
Marius Vlad 6eabd93d59 clients/simple-damage,simple-shm: Use calloc instead of malloc
This avoids some unwarranted errors about conditional jumps or
invalid access from ASan as malloc doesn't set the memory to zero.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-09 18:06:03 +02:00
Marius Vlad f676a8f54e kiosk-shell: Add a border fill to non-fullscreen views
According to xdg-shell spec, if the surface doesn't cover the whole
output we should center it and install a border fill covering the rest
of the output.

While we center out the surface we never got around installing the
border fill. This patch re-uses the activation of a surface to control
this bit as well, by making use of an new layer to place the
surface while not being active.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-12-08 17:35:26 +02:00
Daniel Stone 57d609a47e backend-drm: Cache fb<->plane format compatibility list
Walking the format/modifier list to try to find out if our FB is
compatible with the plane is surprisingly expensive. Since the plane's
capabilities are static over the lifetime of the KMS device, cache the
set of planes for which the FB is theoretically
format/modifier-compatible when it's created, and use that to do an
early cull of the set of acceptable planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 7d27df4c4c backend-drm: Cache drm_fb for each weston_buffer
When we first create a drm_fb from a weston_buffer, cache it and keep it
alive as long as the buffer lives. This allows us to reuse the gbm_bo
and kernel-side DRM framebuffer, rather than constantly creating and
destroying them at every repaint. The overhead of doing so (e.g. MMU
updates) can be significant on some platforms.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 2ecc38b042 backend-drm: Move fb -> buffer reference to plane state
Currently each drm_fb takes a reference on a client buffer it wraps.
This prevents us from being able to reuse a drm_fb in multiple places
(e.g. two views of the same client buffer) simultaneously, or even back
to back.

Move the buffer reference to the plane state, as preparation for
allowing drm_fb to be cached inside the weston_buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 267f6cc6a1 backend-drm: Move drm_fb reference to state-propose
Currently we take a reference on the underlying client buffer every time
we materialise a drm_fb from a view, and release it when the drm_fb is
destroyed. This means that we need to create and destroy a drm_fb every
time we want to use it, which is pathologically unperformant on some
platforms.

To start working towards being able to cache drm_fb, only take the
reference when we apply it to a plane state.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 9e379db082 backend-drm: Early-out in plane assignment for unimportable buffers
No sense walking the plane list every frame if we can't use it because
it's neither a SHM buffer nor a client buffer we can directly import as
a framebuffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone f508603420 backend-drm: Free scanout format table after use
We were deinitialising the array, but not also freeing the allocation.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Daniel Stone 61851f5c37 content-protection: Don't leak update timer on shutdown
If we still have a pending idle timer when the compositor is being
destroyed, make sure to free it first.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-12-08 13:38:18 +00:00
Leandro Ribeiro a272604c00 clients/simple-dmabuf-feedback: pretty print format/modifier pairs
As [1] has already landed, use it to pretty print format/modifier pairs
of each dma-buf feedback tranche.

[1] https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/108

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2021-12-07 11:55:40 -03:00
Pekka Paalanen 3569de7cd1 CI: emit cobertura artifact from only one job
I do not know what happens if multiple jobs declare
artifacts:reports:cobertura. Maybe the last job to finish wins? Who
cares, Gitlab can only show the results from one cobertura report in the
MR diff view.

Recently, the MR diffs have the coverage annotations, but there was a
time when they seemed to be missing. I don't know why.

Let's make sure the cobertura report Gitlab will use is from the "main"
build only: 64-bit Debian with full features and gcc.

I do not move the after_script, because maybe someone could have a
reason to look at arch-specific coverage reports, so I want to leave the
HTML there in the artifacts.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-12-02 15:51:55 +02:00
Daniel Stone 533950cc31 tests: Serialise drm-smoke-test against everything else
drm-smoke-test can't run at the same time as anything else which touches
DRM devices. This includes any test which would use the GL renderer or
GL/GBM on the client side, since they will open DRM devices to probe
them at init time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-11-30 15:56:42 +00:00
Marius Vlad 288214323c .gitlab.ci: Enable debug for libsteat and for the DRM backend
As the drm-smoke test randomly reports having the connector disabled,
and with it libseat reports setMaster errors, this enables DRM backend
debug messages for the kernel, and for libseat in an attempt to
track down the issue, whenever it might happen again.

These are pretty harmless, in terms of data being generated as we only
have a single DRM test using VKMS, and the libseat debug message aren't
that verbose, so we're safe keeping them for the time being.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-11-30 17:36:58 +02:00
Daniel Stone 78ba71191a simple-egl: Avoid 30bpc configs
[XA]RGB8888 is almost universally the thing people want to use.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-11-27 09:57:46 +00:00
Daniel Stone 8817a5f163 backend-x11: Fix EGL compile warning
EGLNativeWindowType can be a lot of different things, including a
pointer which an XID is not. Explicitly cast it through uintptr_t so we
don't throw build warnings either way.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-11-27 09:57:46 +00:00
Daniel Stone b25f8aebf5 remoting: Fix warnings for multi-planar interface
GStreamer can accept up to four planes for a buffer; gcc isn't _quite_
smart enough to figure out that only the first plane of offset/stride
will be accessed and so throws a warning that the params are too small.
Fix that by making them arrays.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2021-11-27 09:57:46 +00:00
Leandro Ribeiro 18d9ad98b1 clients: add client to test the dma-buf feedback implementation
Simple client to test the dma-buf feedback implementation. This does not
replace the need to implement a dma-buf feedback test that can be run in
the CI. But as we still don't know exactly how to do this, this client
can be helpful to run tests manually.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:54 -03:00
Leandro Ribeiro 5429302e78 backend-drm: add KMS plane's formats to per-surface dma-buf feedback
In commit "libweston: add initial dma-buf feedback implementation" we've
added initial support to dma-buf feedback, but it was not using the
feedback from DRM-backend to add useful per-surface feedback.

In this patch we add this. The scanout tranche of the per-surface
feedback is based on the union of formats/modifiers of the primary and
overlay planes available. These are intersected with the
formats/modifiers supported by the renderer device.

Also, it's important to mention that the scene can change a lot and we
can't predict much. So this patch also adds hysteresis to the dma-buf
feedback. We wait a few seconds to be sure that we reached stability
before adding or removing the scanout tranche from dma-buf feedback and
resending them. This help us to avoid spamming clients and leading to
unnecessary buffer reallocations on their end.

Here's an example of what we want to avoid:

1. We detect that a view was not placed in a plane only because its
   format is not supported by the plane, so we add the scanout tranche
   to the feedback and send the events.

2. A few milliseconds after, the view gets occluded. So now the view
   can't be placed in a plane anymore. We need to remove the scanout
   tranche and resend the feedback with formats/modifiers optimal for
   the renderer device. The client will then reallocate its buffers.

3. A few milliseconds after, the view that was causing the occlusion
   gets minimized. So we got back to the first situation, in which the
   format of the view is not compatible with the plane. Then we need to
   add a scanout tranche and resend the feedback...

This patch is based on previous work of Scott Anderson (@ascent).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:52 -03:00
Leandro Ribeiro 0a7034c0cb backend-drm: keep track of the reason why promoting view to a plane failed
Add enum try_view_on_plane_failure_reasons to help us to keep track of
the reason why promoting view to a plane failed. We also add a variable
to struct weston_paint_node so that we can update this information in
each output repaint.

This will be used in the next commits, in which we add proper surface
dma-buf feedback support.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:21 -03:00
Leandro Ribeiro 8eb8414fcd libweston: add initial dma-buf feedback implementation
This adds the initial dma-buf feedback implementation, following the
changes in the dma-buf protocol extension.

The initial dma-buf feedback implementation gives support to send
default feedback and per-surface feedback. For now the per-surface
feedback support is very basic and is still not implemented in the
DRM-backend, what basically means that KMS plane's formats/modifiers are
not being exposed to clients. In the next commits of this series we add
the DRM-backend implementation.

This patch is based on previous work of Scott Anderson (@ascent).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2021-11-25 11:16:14 -03:00