Fixing 100% CPU load after first mouse move 42/302742/1 accepted/tizen/8.0/unified/20231214.075346
authorDaniil Ruban <intx82@gmail.com>
Fri, 1 Dec 2023 12:16:22 +0000 (13:16 +0100)
committerYunhee Seo <yuni.seo@samsung.com>
Wed, 13 Dec 2023 04:21:27 +0000 (13:21 +0900)
The issue could be found in `input_callback`. Due to not proper
initialization of `input_event_handler_list` `input_callback` just
exits before read the incoming `libinput` event (ie call `libinput_dispatch`).
So these events are collected and lead to memeory/cpu-load leak.
Because the same event will try to call the callback while it will not be
'dispatched'

Change-Id: I3ad336faba40e88caaba988c1e9c0efdc8906823
Signed-off-by: Daniil Ruban <intx82@gmail.com>
src/input/input.c

index 6e302e9..9053975 100644 (file)
@@ -134,14 +134,16 @@ static gboolean input_callback(gint fd, GIOCondition cond, void *data)
        struct libinput *li = (struct libinput *) data;
        struct libinput_event *li_event = NULL;
 
-       if (!input_event_handler_list)
+       if (!li) {
                return G_SOURCE_CONTINUE;
+       }
 
-       if (!li)
+       if (!input_event_handler_list) {
+               libinput_dispatch(li);
                return G_SOURCE_CONTINUE;
+       }
 
        libinput_dispatch(li);
-
        while ((li_event = libinput_get_event(li))) {
                struct input_event event = { 0 , };
 
@@ -209,7 +211,6 @@ int input_register_event_callback(input_event_callback cb, input_destroy_callbac
        };
 
        input_event_handler_list = g_list_append(input_event_handler_list, h);
-
        if (cb_id)
                *cb_id = h->id;