From ed2b0736ddc0792af262e0acd3cbe880b8b16f3e Mon Sep 17 00:00:00 2001 From: Inhong Han Date: Mon, 18 Dec 2023 15:41:56 +0900 Subject: [PATCH] Add trace tags and logs for Input Change-Id: I2313d403c26ed8906cf81ac580ce57dca39510a0 --- src/bin/e_comp_wl.c | 36 ++++++++++++++++++++ src/bin/e_config.c | 2 ++ src/bin/e_config.h | 1 + src/bin/e_input_evdev.c | 12 +++++++ src/bin/e_input_inputs.c | 81 ++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_keyrouter_events.c | 37 ++++++++++++++++++++ src/bin/e_keyrouter_wl.c | 24 +++++++++++++ 7 files changed, 193 insertions(+) diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index 9d15f8c..89b387c 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -263,9 +263,21 @@ e_comp_wl_display_flush() { if (e_comp_wl && e_comp_wl->wl.disp) { + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(wl_display_flush_clients); + ELOGF("INPUT", "wl_display_flush_clients|B|", NULL); + } + g_mutex_lock(&flush_mutex); wl_display_flush_clients(e_comp_wl->wl.disp); g_mutex_unlock(&flush_mutex); + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "wl_display_flush_clients|E|", NULL); + } } } @@ -4346,6 +4358,12 @@ _e_comp_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_key_sta wc = wl_resource_get_client(surface); } + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname); + ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname); + } + EINA_LIST_FOREACH(key_list, l, res) { if (wl_resource_get_client(res) != wc) continue; @@ -4372,6 +4390,12 @@ _e_comp_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_key_sta keycode, state); TRACE_INPUT_END(); } + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL); + } } EINTERN Eina_Bool @@ -4756,6 +4780,12 @@ e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint comp_conf = e_comp_config_get(); e_keyrouter_event_surface_send(ec, keycode); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%d, (state ? "PRESS" : "RELEASE"), keycode); + ELOGF("INPUT", "wl_keyboard_send_key:%s:%d|B|", NULL, (state ? "PRESS" : "RELEASE"), keycode); + } + g_mutex_lock(&e_comp_wl->kbd.resource_mutex); EINA_LIST_FOREACH(e_comp_wl->kbd.resources, l, res) { @@ -4790,6 +4820,12 @@ e_comp_wl_key_send(E_Client *ec, int keycode, Eina_Bool pressed, void *dev, uint } g_mutex_unlock(&e_comp_wl->kbd.resource_mutex); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL); + } + return EINA_TRUE; } diff --git a/src/bin/e_config.c b/src/bin/e_config.c index 8625bcf..fb9fa6d 100644 --- a/src/bin/e_config.c +++ b/src/bin/e_config.c @@ -311,6 +311,7 @@ _e_config_edd_init(Eina_Bool old) E_CONFIG_VAL(D, T, calc_vis_ignore_geometry, UINT); E_CONFIG_VAL(D, T, input_thread_mode, UCHAR); E_CONFIG_VAL(D, T, key_input_time_limit, UINT); + E_CONFIG_VAL(D, T, key_input_ttrace_enable, UCHAR); } static Eina_Bool @@ -572,6 +573,7 @@ e_config_load(void) E_CONFIG_LIMIT(e_config->calc_vis_ignore_geometry, 0, 1); E_CONFIG_LIMIT(e_config->input_thread_mode, 0, 1); E_CONFIG_LIMIT(e_config->key_input_time_limit, 0, 500); + E_CONFIG_LIMIT(e_config->key_input_ttrace_enable, 0, 1); } EINTERN int diff --git a/src/bin/e_config.h b/src/bin/e_config.h index c1ba253..139e90c 100644 --- a/src/bin/e_config.h +++ b/src/bin/e_config.h @@ -312,6 +312,7 @@ struct _E_Config Eina_Bool calc_vis_ignore_geometry; // 0: unset ignore geometry, 1: ignore geometry calculate when the calculation of visibility. Eina_Bool input_thread_mode; // 0: process key input event in main thread, 1: process key input event in input thread unsigned int key_input_time_limit; + Eina_Bool key_input_ttrace_enable; // 0: disable the performance measurement of key inputs , 1: enable the performance measurement of key inputs }; struct _E_Config_Desklock_Background diff --git a/src/bin/e_input_evdev.c b/src/bin/e_input_evdev.c index 3f5f079..5cd53f4 100644 --- a/src/bin/e_input_evdev.c +++ b/src/bin/e_input_evdev.c @@ -799,6 +799,12 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar if (comp_conf && comp_conf->input_log_enable) ELOGF("Key", "%s (keyname: %s, keycode: %d, timestamp: %u, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e->timestamp, device_name); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(ECORE_EVENT_KEY:%s:%s:%u:%lld, state ? "PRESS" : "RELEASE", e->keyname, timestamp, libinput_event_keyboard_get_time_usec(event)); + ELOGF("INPUT", "ECORE_EVENT_KEY:%s:%s:%u:%lld|B|", NULL, state ? "PRESS" : "RELEASE", e->keyname, timestamp, libinput_event_keyboard_get_time_usec(event)); + } + _e_input_key_event_list_add(e); if (e_input_thread_mode_get()) @@ -812,6 +818,12 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL); } + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "ECORE_EVENT_KEY|E|", NULL); + } + if (tmp) free(tmp); } diff --git a/src/bin/e_input_inputs.c b/src/bin/e_input_inputs.c index f87565b..50eadfe 100644 --- a/src/bin/e_input_inputs.c +++ b/src/bin/e_input_inputs.c @@ -565,10 +565,34 @@ _udev_event_process(struct libinput_event *event) switch (libinput_event_get_type(event)) { case LIBINPUT_EVENT_DEVICE_ADDED: + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(_device_added); + ELOGF("INPUT", "_device_added|B|", NULL); + } + _device_added(input, device); + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "_device_added|E|", NULL); + } break; case LIBINPUT_EVENT_DEVICE_REMOVED: + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(_device_removed); + ELOGF("INPUT", "_device_removed|B|", NULL); + } + _device_removed(input, device); + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "_device_removed|E|", NULL); + } break; default: ret = EINA_FALSE; @@ -610,12 +634,24 @@ _cb_input_dispatch(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED) if (!(input = data)) return EINA_TRUE; + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(_cb_input_dispatch); + ELOGF("INPUT", "_cb_input_dispatch|B|", NULL); + } + if (libinput_dispatch(input->libinput) != 0) ERR("Failed to dispatch libinput events: %m"); /* process pending events */ _input_events_process(input); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "_cb_input_dispatch|E|", NULL); + } + return EINA_TRUE; } @@ -648,12 +684,24 @@ _e_input_delayed_key_events_print() static gboolean input_thread_prepare(GSource *source, gint *time) { + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(e_comp_wl_focused_client_flush); + ELOGF("INPUT", "e_comp_wl_focused_client_flush|B|", NULL); + } + /* flush only focused client events */ e_comp_wl_focused_client_flush(); if (_key_event_list) _e_input_delayed_key_events_print(); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "e_comp_wl_focused_client_flush|E|", NULL); + } + if (time) *time = -1; @@ -668,6 +716,12 @@ input_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) if (!src) return G_SOURCE_REMOVE; if (!input) return G_SOURCE_REMOVE; + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(input_dispatch); + ELOGF("INPUT", "input_dispatch|B|", NULL); + } + E_Input *e_input = e_input_get(); GIOCondition cond; @@ -685,15 +739,42 @@ input_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) if (e_input) g_rec_mutex_lock(&e_input->libinput_mutex); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(libinput_dispatch); + ELOGF("INPUT", "libinput_dispatch|B|", NULL); + } + if (libinput_dispatch(input->libinput) != 0) ERR("Failed to dispatch libinput events: %m"); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "libinput_dispatch|E|", NULL); + } + if (e_input) g_rec_mutex_unlock(&e_input->libinput_mutex); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(_input_events_process); + ELOGF("INPUT", "_input_events_process|B|", NULL); + } + /* process pending events */ _input_events_process(input); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "_input_events_process|E|", NULL); + + TRACE_INPUT_END(); + ELOGF("INPUT", "input_dispatch|E|", NULL); + } + e_input_event_process((GSource *)input->event_source); return G_SOURCE_CONTINUE; diff --git a/src/bin/e_keyrouter_events.c b/src/bin/e_keyrouter_events.c index 23403af..260f754 100644 --- a/src/bin/e_keyrouter_events.c +++ b/src/bin/e_keyrouter_events.c @@ -472,11 +472,36 @@ e_keyrouter_event_process(void *event, E_Device *dev, int type) //KLDBG("The key(%d) is going to be sent to the proper wl client(s) !", ev->keycode); KLDBG("[%s] keyname: %s, key: %s, keycode: %d", (type == ECORE_EVENT_KEY_DOWN) ? "KEY_PRESS" : "KEY_RELEASE", ev->keyname, ev->key, ev->keycode); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(_e_keyrouter_send_key_events); + ELOGF("INPUT", "_e_keyrouter_send_key_events|B|", NULL); + } + _e_keyrouter_send_key_events(type, ev, dev); + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "_e_keyrouter_send_key_events|E|", NULL); + } + return EINA_FALSE; focus_deliver: + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(e_comp_wl_key_process); + ELOGF("INPUT", "e_comp_wl_key_process|B|", NULL); + } + res = e_comp_wl_key_process(event, dev, type); + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "e_comp_wl_key_process|E|", NULL); + } finish: return res; } @@ -920,8 +945,20 @@ _e_keyrouter_send_key_event(int type, struct wl_resource *surface, struct wl_cli e_keyrouter_prepend_to_keylist(surface, wc, ev->keycode, TIZEN_KEYROUTER_MODE_PRESSED, focused); } + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(e_keyrouter_wl_key_send); + ELOGF("INPUT", "e_keyrouter_wl_key_send|B|", NULL); + } + e_keyrouter_wl_key_send(ev, dev, pressed, wc_send, surface, focused); + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "e_keyrouter_wl_key_send|E|", NULL); + } + return; } diff --git a/src/bin/e_keyrouter_wl.c b/src/bin/e_keyrouter_wl.c index 7770df0..16eb869 100644 --- a/src/bin/e_keyrouter_wl.c +++ b/src/bin/e_keyrouter_wl.c @@ -18,7 +18,19 @@ e_keyrouter_wl_event_surface_send(struct wl_resource *surface, int key, int mode if (wl_resource_get_client(res_data) != wc) continue; if (wl_resource_get_version(res_data) < 2) continue; + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(tizen_keyrouter_send_event_surface); + ELOGF("INPUT", "tizen_keyrouter_send_event_surface|B|", NULL); + } + tizen_keyrouter_send_event_surface(res_data, surface, key, mode); + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "tizen_keyrouter_send_event_surface|E|", NULL); + } } } @@ -42,6 +54,12 @@ _e_keyrouter_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_ke e_keyrouter_wl_event_surface_send(surface, ev->keycode, TIZEN_KEYROUTER_MODE_NONE); } + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_BEGIN(wl_keyboard_send_key:%s:%s, (state ? "PRESS" : "RELEASE"), ev->keyname); + ELOGF("INPUT", "wl_keyboard_send_key:%s:%s|B|", NULL, (state ? "PRESS" : "RELEASE"), ev->keyname); + } + EINA_LIST_FOREACH(key_list, l, res) { wc = wl_resource_get_client(res); @@ -64,6 +82,12 @@ _e_keyrouter_wl_key_send(Ecore_Event_Key *ev, E_Device *dev, enum wl_keyboard_ke keycode, state); TRACE_INPUT_END(); } + + if (e_config->key_input_ttrace_enable) + { + TRACE_INPUT_END(); + ELOGF("INPUT", "wl_keyboard_send_key|E|", NULL); + } } Eina_Bool -- 2.7.4