[PATCH weston v2] desktop-shell: Send fewer pings
Giulio Camuffo
giuliocamuffo at gmail.com
Mon Aug 8 10:04:27 UTC 2016
Hi,
looks good.
Reviewed-by: Giulio Camuffo <giuliocamuffo at gmail.com>
2016-07-08 20:20 GMT+02:00 Derek Foreman <derekf at osg.samsung.com>:
> Currently we can end up sending pings to popups every screen redraw and every
> pointer move when they're focused. Instead let's send a maximum of 1 every 200ms
> by letting the ping timer expire before we send another ping.
>
> With the old code I've logged 400+ pings per second on the right click pop-up.
> This is easily reproducible with a high refresh rate mouse.
>
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
> Changes from v1:
> Bill caught me - I've now removed the always-true conditional...
>
> desktop-shell/shell.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index 4945bc1..f0b6596 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -243,6 +243,7 @@ struct shell_client {
> uint32_t ping_serial;
> int unresponsive;
> struct wl_list surface_list;
> + bool ponged;
> };
>
> static struct desktop_shell *
> @@ -2092,6 +2093,11 @@ xdg_ping_timeout_handler(void *data)
> struct weston_seat *seat;
> struct shell_surface *shsurf;
>
> + if (sc->ponged) {
> + wl_event_source_remove(sc->ping_timer);
> + sc->ping_timer = NULL;
> + return 1;
> + }
> /* Client is not responding */
> sc->unresponsive = 1;
> wl_list_for_each(seat, &sc->shell->compositor->seat_list, link) {
> @@ -2125,13 +2131,16 @@ handle_xdg_ping(struct shell_surface *shsurf)
> return;
> }
>
> + if (sc->ping_timer)
> + return;
> +
> serial = wl_display_next_serial(compositor->wl_display);
> sc->ping_serial = serial;
> loop = wl_display_get_event_loop(compositor->wl_display);
> - if (sc->ping_timer == NULL)
> - sc->ping_timer =
> - wl_event_loop_add_timer(loop,
> - xdg_ping_timeout_handler, sc);
> + sc->ponged = false;
> + sc->ping_timer = wl_event_loop_add_timer(loop,
> + xdg_ping_timeout_handler,
> + sc);
> if (sc->ping_timer == NULL)
> return;
>
> @@ -2218,11 +2227,7 @@ shell_client_pong(struct shell_client *sc, uint32_t serial)
> sc->unresponsive = 0;
> end_busy_cursor(sc->shell->compositor, sc->client);
>
> - if (sc->ping_timer) {
> - wl_event_source_remove(sc->ping_timer);
> - sc->ping_timer = NULL;
> - }
> -
> + sc->ponged = true;
> }
>
> static void
> --
> 2.8.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list