TEST: Fixed the annoying 10-15 second highlight lag after orientation changes

I've been reading a lot more on KOReader lately, but one bug annoyed me to no end. When you change the screen orientation, the text rotates instantly, but the highlights just sit there.

For about 10 to 15 seconds, KOReader highlights completely the wrong words until it finally catches up, which is really annoying for me. It completely broke my reading flow.

Before (The Bug): Highlight lag bug (Highlighting completely wrong text while lagging behind the new layout)

When you rotate, the page layout updates immediately, but the highlight refresh gets delayed. So for that 10-15 second window, you're looking at the new page layout with misaligned highlights from the old one.

Fix: Force the highlights to refresh immediately instead of waiting for KOReader to do it later.

I came up with a small patch that checks if the layout changed, and if it did, it forces the highlights to redraw right then and there. I took some help from GitHub Copilot as I have no prior experience with Lua. It's a minimal patch based on a hand-written text solution that I passed to Copilot to ensure it did not overdo the solution.

After (The Fix): Highlights redraw immediately (Highlights redraw immediately to match the new layout)

(Also: While I was fixing this, I patched that bug in the Kobo-style screensaver plugin where your book cover gets cropped weirdly if you put the device to sleep in landscape mode).

I didn't want to dump a bunch of code into a Reddit post. If this lag has been annoying you too, I put the actual fix, the patch files, and the instructions on how to apply it over on my blog: Fixing KOReader's Highlight Lag After Orientation Changes | Anurag Rai

Posted Apr 4, 2026, 1:18 PM UTC

10
Loading comments…