Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of GrabServer #1283

Merged
merged 18 commits into from
Jun 28, 2024
Merged

Remove uses of GrabServer #1283

merged 18 commits into from
Jun 28, 2024

Conversation

yshui
Copy link
Owner

@yshui yshui commented Jun 27, 2024

See the changelog for why this is done. The Xorg bug referenced is https://gitlab.freedesktop.org/xorg/xserver/-/issues/1691

... this might break everything.

@yshui yshui force-pushed the no-more-server-grabs branch 3 times, most recently from eca64b2 to e4087f9 Compare June 27, 2024 18:16
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 62.74510% with 95 lines in your changes missing coverage. Please review.

Project coverage is 52.21%. Comparing base (732f365) to head (ca3ea85).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #1283      +/-   ##
==========================================
- Coverage   52.31%   52.21%   -0.11%     
==========================================
  Files          64       64              
  Lines       13775    13798      +23     
==========================================
- Hits         7207     7205       -2     
- Misses       6568     6593      +25     
Files Coverage Δ
src/common.h 44.82% <ø> (ø)
src/renderer/layout.c 98.61% <100.00%> (+0.01%) ⬆️
src/wm/win.h 100.00% <ø> (ø)
src/wm/wm_internal.h 100.00% <ø> (ø)
src/x.h 77.77% <ø> (ø)
src/wm/win.c 72.32% <89.18%> (+0.82%) ⬆️
src/wm/wm.c 84.18% <76.47%> (-1.23%) ⬇️
src/vblank.c 0.00% <0.00%> (ø)
src/wm/tree.c 90.38% <80.00%> (+0.91%) ⬆️
src/picom.c 63.85% <71.42%> (+0.18%) ⬆️
... and 2 more

yshui added 18 commits June 27, 2024 19:43
The way we set and use it, it's completely equivalent to checking if
w->win_image == NULL. So it's redundant.

Signed-off-by: Yuxuan Shui <[email protected]>
… one

Might break on NVIDIA, needs testing.

Signed-off-by: Yuxuan Shui <[email protected]>
Previously `win->tree_ref` could reference a freed tree node up until all
tree changes are handled in `handle_new_windows`. The result is that
certain operations can be only performed after all tree changes are
handled, because they might use `win->tree_ref`. Such operations include
updating the focused window, for example.

This commit makes sure `win->tree_ref` is valid at all times.

Also split up wm_tree_enqueue_change, because enqueueing a
TOPLEVEL_KILLED now needs to return whether the event cancels out a
previous TOPLEVEL_NEW, in which case the zombie is freed and there's no
need for tree_ref update.

Signed-off-by: Yuxuan Shui <[email protected]>
This way focus changes are processed in order with all other events, so
we are less likely to run into the issue where the focused window isn't
yet in our window tree.

Known issue: it is still possible for the window to not be in our window
tree. And when that happens, we won't update focus again after the
focused window is imported.

Signed-off-by: Yuxuan Shui <[email protected]>
The old name is inaccurate, this flag is not limited to ewmh.

Signed-off-by: Yuxuan Shui <[email protected]>
Moving it out of the X critical section.

Signed-off-by: Yuxuan Shui <[email protected]>
This is an alternative fix for #357. Previous fix is moving
configure_root into the X critical section, and now we are removing the
critical section so we can't do that anymore.

Signed-off-by: Yuxuan Shui <[email protected]>
It doesn't really make any X requests besides querying the root window
geometry.

Signed-off-by: Yuxuan Shui <[email protected]>
This is to solve a race condition that was previously impossible, and
only became possible because the X critical section was removed.

Currently, in `handle_new_windows`, after we created a managed window
object, we check if its map state is already mapped, if so, we call
`win_map_start`. But there is a problem if the window is mapped before
we reached `handle_new_windows`.

There will be an event generated for that map, because managed windows
are toplevels, and we have event mask set up for the root window at the
very beginning, so we won't miss any map events from toplevels. (Except
when picom has just started, and is trying to manage existing windows).

There are two cases, based on whether this map event is handled before
we reach `handle_new_windows`.

1) If the map event is handled after. It itself will trigger another
   `win_map_start` call, which is an error, and we have an assertion for
   that.

But on the other hand, if we don't call `win_map_start` in
`handle_new_windows`:

2) If the map event is handled before. It will do nothing since we
   haven't created a managed window object for that tree node yet. And
   later, since we don't call `win_map_start` in `handle_new_windows`,
   this window will just never be mapped. (This would be the same
   scenario for pre-existing windows when picom just started).

All these problem came from the map event being handled out-of-order
w.r.t. the reply to the GetWindowAttributes request sent by
`win_maybe_allocate`. So we use async requests to make sure they are
handled in order.

Signed-off-by: Yuxuan Shui <[email protected]>
The property being fetched might change between x_get_prop_info and
actually fetching the property. So instead we do this all in one request
by setting the length to UINT_MAX.

Signed-off-by: Yuxuan Shui <[email protected]>
If PresentNotifyMsc event is stuck in the out buffer, we will stop
rendering frames.

Signed-off-by: Yuxuan Shui <[email protected]>
I found sometimes, when we receive an invalid PresentCompleteNotify,
keep requesting new present notifys using `last_msc + 1` doesn't really
help us recover. Instead X just keeps sending us bad
PresentCompleteNotifys, and we stuck in a loop. (This is more likely to
happen during screen resolution change. Also this did not seem to be
possible previously, when we were still handling resolution changes
inside the X critical section.)

This commit tries to test out a different approach. The hypothesis is,
maybe doing something to the screen (e.g. render and present a new frame)
helps change the internal state of the X server, thus kicks us out of the
loop. So whenever we get an invalid notify, we fake a vblank event so
rendering can happen. And we keeps doing this until we are (hopefully)
fine.

Signed-off-by: Yuxuan Shui <[email protected]>
There are some cases where a window might be missing its pixmap. Mainly
when a window is unmapped/destroyed during a backend reset (there are
many reasons for backend resets, e.g. resolution change,
unredir-if-possible, etc.). We skip windows like this.

Signed-off-by: Yuxuan Shui <[email protected]>
I checked, functions called by refresh_windows should mostly be robust
against window disappearing, unless I missed something. (We will find
out).

Signed-off-by: Yuxuan Shui <[email protected]>
@yshui yshui merged commit 562529f into next Jun 28, 2024
18 checks passed
@yshui yshui deleted the no-more-server-grabs branch June 28, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant