The once-a-second fallback update keeps re-rendering when nothing has changed
Describe the bug
LintFramework runs update() every second as a fallback for editors that do not emit events. It does so unconditionally, so every second Harper lints all on-screen targets and renders again, even when the text, the layout and the scroll position are the same as a second ago. Rendering reads element and range geometry and updates the highlights, which forces layout and repaint. In a long document this keeps the main thread busy while the user is not typing at all.
To Reproduce
- Open a long document in an editor Harper checks. In my case it was a Thunderbird compose window with a long forwarded thread (see #1425 for how the extension runs there).
- Leave it idle and watch the CPU time of the process.
- The main thread stays busy. In my measurement it was about 48 % of one core with Harper enabled and about 3 % once the periodic update was skipped when nothing changed (Harper already ignored the quoted text there, so there were no lints to draw).
Expected behavior An idle page costs next to nothing. The fallback update runs only when something it could miss has actually changed.
Platform
Measured in the Thunderbird compose window with the Firefox build repackaged as a MailExtension. The timer is part of lint-framework, so it runs the same way in every browser, but I have not measured it elsewhere.
Additional context I will open a pull request with a fix. I worked on this with an AI agent. I have reviewed the AI parts and edited them when appropriate.
Source: Automattic/harper