Closed Bug 1724405 Opened 3 years ago Closed 3 years ago

The caret blinking forever wastes CPU/power

Categories

(Core :: Layout, defect)

defect

Tracking

()

RESOLVED FIXED
93 Branch
Tracking Status
firefox93 --- fixed

People

(Reporter: florian, Assigned: emilio)

References

(Blocks 1 open bug)

Details

(Keywords: power)

Attachments

(1 file)

Here is a profile of starting Firefox and doing nothing with it. It shows about:home and the caret keeps blinking in the url bar forever: https://share.firefox.dev/3AgOoy5

Each time the caret visibility changes, there's activity in the main thread, the Renderer thread and the Compositor thread: https://share.firefox.dev/3fFblmG

Could this be changed to a compositor animation?

Also, it seems most platforms limit the blinking duration.

On Windows, there's a Computer\HKEY_CURRENT_USER\Control Panel\Desktop\CaretTimeout registry setting (defaulting to 5000ms) which makes the caret stop blinking after 5s.

On GTK there's a gtk-cursor-blink-timeout setting (https://docs.gtk.org/gtk3/property.Settings.gtk-cursor-blink-timeout.html) which seems to default to 10, for 10s after which the caret stops blinking.

Bug 1159263 already added support for a pref that makes the caret stop blinking after some time, but it's only enabled on Android.
Maybe we could enable this on desktop too?

Limiting the amount of blinks seems legit.

One way to fix this is changing ui.caretBlinkCount to be a LookAndFeel::IntID, and implementing it per platform (returning a 10 on Android). Or making it a timer or such.

gtk-cursor-blink seems only a boolean to see if the caret should blink at all, and we already honor it, afaict. Did you mean gtk-cursor-blink-timeout?

I can take this if you don't have the cycles and you think it's important, feel free to ni? me if so.

Implementing the caret blink time as an opacity animation on nsDisplayCaret::CreateWebRenderCommands might be worth trying. Not sure how easy that is though, might be worth spinning either the blink timeout or that as a separate bug.

Flags: needinfo?(florian)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #1)

gtk-cursor-blink seems only a boolean to see if the caret should blink at all, and we already honor it, afaict. Did you mean gtk-cursor-blink-timeout?

Yes, sorry. I fixed the previous comment.

I can take this if you don't have the cycles and you think it's important, feel free to ni? me if so.

I will be on PTO for the next 2 weeks, and this is a bit outside my comfort zone, so feel free to take it. About whether I think it's important... I think it's worth fixing, but I don't know if it needs to be a priority. It would be nice to no longer see it in profiles, as that causes lots of markers that can easily hide other things that would be worth investigating for idle power use.

Flags: needinfo?(florian) → needinfo?(emilio)

And make sure the caret ends up being visible, rather than not
visible.

This should be implementable on windows as well. It seems macOS doesn't
have a timeout thing.

Assignee: nobody → emilio
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/aa696af2feac
Make ui.caretBlinkCount a proper widget int, and make it respect GTK settings. r=stransky
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 93 Branch
Flags: needinfo?(emilio)
Depends on: 1725454
Duplicate of this bug: 978134
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: