From 48742163fd0c1626897b607b3c8adfa7f42093da Mon Sep 17 00:00:00 2001 From: tokyo4j Date: Mon, 20 May 2024 20:36:30 +0900 Subject: [PATCH] magnifier: fix high CPU usage even with magnifier disabled Fixes the high CPU usage issue reported by @droc12345. Changing `last_mag != is_magnify_on()` to `last_mag == is_magnify_on()` works fine, but this check isn't needed in the first place because magnifier state changes call `wlr_output_schedule_frame()`, which sets `wlr_output->needs_frame`. Also added a FIXME comment regarding the performance issue when the magnifier is enabled. --- src/common/scene-helpers.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/scene-helpers.c b/src/common/scene-helpers.c index f09cd9c0..755d65d4 100644 --- a/src/common/scene-helpers.c +++ b/src/common/scene-helpers.c @@ -47,16 +47,18 @@ lab_wlr_scene_output_commit(struct wlr_scene_output *scene_output) struct wlr_output_state *state = &wlr_output->pending; struct output *output = wlr_output->data; bool wants_magnification = output_wants_magnification(output); - static bool last_mag = false; + /* + * FIXME: Regardless of wants_magnification, we are currently adding + * damages to next frame when magnifier is shown, which forces + * rendering on every output commit and overloads CPU. + * We also need to verify the necessity of wants_magnification. + */ if (!wlr_output->needs_frame && !pixman_region32_not_empty( - &scene_output->damage_ring.current) && !wants_magnification - && last_mag != is_magnify_on()) { + &scene_output->damage_ring.current) && !wants_magnification) { return false; } - last_mag = is_magnify_on(); - if (!wlr_scene_output_build_state(scene_output, state, NULL)) { wlr_log(WLR_ERROR, "Failed to build output state for %s", wlr_output->name);