]> git.mdlowis.com Git - proto/labwc.git/commitdiff
magnifier: fix high CPU usage even with magnifier disabled
authortokyo4j <hrak1529@gmail.com>
Mon, 20 May 2024 11:36:30 +0000 (20:36 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 21 May 2024 15:41:01 +0000 (17:41 +0200)
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

index f09cd9c0fda0b39527b58790b817e2fca4f0951a..755d65d42a486ea3654b42658854654b7f6d78f1 100644 (file)
@@ -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);