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
838838 {
839839 wl->focused = !wl->focused;
840840 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− }
847841 }
848842 }
849843
@@ -994,6 +988,7 @@ static void frame_callback(void *data, struct wl_callback *callback, uint32_t ti · 144 unmodified lines
994988 }
995989
996990 wl->frame_wait = false;
991+ wl->hidden = false;
997992 }
998993
999994 static const struct wl_callback_listener frame_listener = {
@@ -1992,13 +1987,11 @@ void vo_wayland_wait_frame(struct vo_wayland_state *wl) · 992 unmodified lines
19921987 return;
19931988 } else {
19941989 wl->timeout_count += 1;
1995− wl->hidden = false;
19961990 return;
19971991 }
19981992 }
19991993
20001994 wl->timeout_count = 0;
2001− wl->hidden = false;
20021995 }
20031996
20041997 void 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