History

wayland: unset hidden state in frame callback

More wayland weirdness. So previously, flipping a hidden state from true to false was done in vo_wayland_wait_frame. In theory, this would be after you get the frame callback and all those events so there's no problem. However since the function also does a bunch of flushing/dispatching/etc. to the default display queue so a lot of unknown things can happen before we actually set the hidden variable back to false. For example if a single image was paused and left on another virtual desktop long enough (~5 minutes) while also not having focus, switching back to that desktop could render it a black frame. This edge case was supposed to be handled by the surface being activated again in the toplevel event but apparently that doesn't always work. The fix is to just delete all of that junk and set wl->hidden = false in the frame callback. What's actually happening is kind of a mystery honestly. Probably the compositor drops the buffers after a while as an optimization (sensible) and forces a repaint if you switch back to the virtual desktop. Somehow wl->hidden not being set to false would not properly trigger a repaint (likely because it also sends a toplevel event which does stuff) thus you just get a black window. If you just make sure to set hidden in the frame callback, it appears like all of these problems and edge cases are solved. Since this event must happen first, that makes sense. That simplifies a lot of stuff and fixes some subtle bugs at the same time so just go with this approach.

Dudemanguy committed 5 years ago

Commit e2c24ad1 parent f8e62d31 file · +1 −8Browse files

Unified · Split

video/out/wayland_common.c+1−8
@@ -838,12 +838,6 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, · 837 unmodified lines
838 {838 {
839 wl->focused = !wl->focused;839 wl->focused = !wl->focused;
840 wl->pending_vo_events |= VO_EVENT_FOCUS;840 wl->pending_vo_events |= VO_EVENT_FOCUS;
841
842 if (wl->activated) {
843 /* If the surface comes back into view, force a redraw. */
844 vo_wayland_wait_frame(wl);
845 wl->pending_vo_events |= VO_EVENT_EXPOSE;
846 }
847 }841 }
848 }842 }
849 843
@@ -994,6 +988,7 @@ static void frame_callback(void *data, struct wl_callback *callback, uint32_t ti · 144 unmodified lines
994 }988 }
995 989
996 wl->frame_wait = false;990 wl->frame_wait = false;
991 wl->hidden = false;
997}992}
998 993
999static const struct wl_callback_listener frame_listener = {994static const struct wl_callback_listener frame_listener = {
@@ -1992,13 +1987,11 @@ void vo_wayland_wait_frame(struct vo_wayland_state *wl) · 992 unmodified lines
1992 return;1987 return;
1993 } else {1988 } else {
1994 wl->timeout_count += 1;1989 wl->timeout_count += 1;
1995 wl->hidden = false;
1996 return;1990 return;
1997 }1991 }
1998 }1992 }
1999 1993
2000 wl->timeout_count = 0;1994 wl->timeout_count = 0;
2001 wl->hidden = false;
2002}1995}
2003 1996
2004void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us)1997void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t