Live data from Hacker News

"Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

gist.github.com

51–60 of 115 posts

Re: "Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

#52
post #10

What's with "guard !foo else return" instead of "if foo return", is that just how Swift is written?

guard is an inverted if statement, with the additional requirement that the branch must exit the parent scope. It's useful sometimes for readability, particularly for avoiding the "pyramid of doom" when you have a lot of preconditions that need to be checked: if fooOK if barOK { if bazOK { // do something } } } can be written as: guard fooOK else { return } guard barOK else { return } guard bazOK else { return } // d…

Perl has the negated if statement:

    return unless fooOK;
    return unless barOK;
    return unless bazOK;
    # do something

Re: "Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

#53
post #49

But at the moment when it lags the system switches from hardware cursor to software cursor (CGCursorIsDrawnInFramebuffer() goes from 0 to 1) so maybe that transition is stalled somehow on Macbook Neo. With the disclaimer that I have zero knowledge of the MacBook Neo hardware, but I do know a bit about GPUs in general (including having written some GPU-accelerated drivers for Windows and the associated cursor-handling…

> A hardware cursor is basically a small bitmap that can be positioned anywhere on the screen and moved around by simply updating position registers (which is normally done per mouse interrupt); the hardware draws it automatically Do modern machines still have custom hardware for cursors? That would surprise me, as a GPU can easily blit a small cursor on top of whatever gets drawn.

The cursor plane is the way to "easily blit a small cursor on top of whatever gets drawn". If the cursor was drawn on the primary plane, the primary plane would need to be redrawn (expensive!) or repaired (messy!) to change the cursor position.

Re: "Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

#54

But at the moment when it lags the system switches from hardware cursor to software cursor (CGCursorIsDrawnInFramebuffer() goes from 0 to 1) so maybe that transition is stalled somehow on Macbook Neo. With the disclaimer that I have zero knowledge of the MacBook Neo hardware, but I do know a bit about GPUs in general (including having written some GPU-accelerated drivers for Windows and the associated cursor-handling…

how do hardware cursors work in a composited desktop? the cursor could just be another small rectangle texture you position on top of the other surfaces. there is no need to read the framebuffer/write into it, its just a z-stack of 3d surfaces now

AFAIK, they work just like in a non-composited desktop.

The problem with rendering the cursor into the primary plane is that, often, only the cursor changes, and you'd have to re-render the whole plane that contains the cursor. That is easily doable for modern hardware, but bad for power consumption and may also be higher latency. (The latency aspect gets interesting when dragging something on the primary plane - I think most compositors temporarily disable the hardware cursor in order to keep cursor and dragged object in sync.)

Re: "Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

#56
post #34

Earlier quoted context omitted.

linux was plagued for a long time by lagging mouse cursor

I've been using Linux every day for the last 17 years, and that's the first time I'm hearing this. I'm genuinely surprised. The way you word it, it looks like a famous ubiquitous problem. Mind sharing any details?

not necessarily ubiquitous, but you can encounter some issues with "lagging cursor" even today, if you use standard raspbian for example

> usbhid.mousepoll=0 > to /boot/cmdline.txt > This option was implemented to enforce a mouse polling rate of 62.5Hz which dramatically reduced the XWindow event system update rate in certain circumstances (oddball or "performance" mice can have update rates of 1000Hz, which is silly).

Re: "Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

#58
post #10

What's with "guard !foo else return" instead of "if foo return", is that just how Swift is written?

guard is an inverted if statement, with the additional requirement that the branch must exit the parent scope. It's useful sometimes for readability, particularly for avoiding the "pyramid of doom" when you have a lot of preconditions that need to be checked: if fooOK if barOK { if bazOK { // do something } } } can be written as: guard fooOK else { return } guard barOK else { return } guard bazOK else { return } // d…

Already in 1963, the language CPL introduced "unless ... do ...", besides the "if ... do ..." inherited from ALGOL 60. Perl has just followed the example of CPL and BCPL, decades later.

Using "if" or "unless", whichever is more appropriate, is far more readable than "guard".

Moreover, there are many languages where an assignment or an initialization can appear in any place where an expression can appear. Such general rules are always better than special rules like allowing new bindings in a "guard", but not in an "if". Pattern matching does not need any special syntax, it should work in the standard alternative program structure of that programming language, regardless whether it is called "select", "case" or "switch".

It always annoys me when the creators of new programming languages demonstrate amateurism, by inventing new worse alternatives than those that existed in various older programming language, already many decades ago.

There are plenty of new programming languages that claim to be better than C, which may be true, but they fail to match programming languages much older than C.

Re: "Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

#59
post #8

I’m not sure what the bug is, but this is a terrible fix. What this is doing is forcing the WindowServer to composite the cursor rather than treat it as a hardware overlay. I suppose the issue must be pretty bad for OP if this helps, but … ugh.

Reminds me of a fix I wrote a decade ago. My Laptop would sometimes start emitting a high frequency whine when on battery. I figured out it only happened when the CPU went into performance states lower than P2 for power saving.

So I wrote a bash script that auto-started on battery mode and then calculated a hash every few seconds. Boom, whine solved. Terrible fix, but I never measured how much battery it cost me, so it was... fine.

Re: "Fix" MacBook Neo Cursor Lag: Record 1 Pixel of the Screen Every 10 Seconds

#60

Earlier quoted context omitted.

Yeah, the cursor is your most direct embodiment in the computer. Messing with it is like somebody pushing your arm when you're trying to cut tomatoes. It's a major determinant in how good it feels to use a computer (and whether you cut your fingers). But there were a lot of things we learned in the 80s and 90s that we have largely forgotten today, like "make clickable things look clickable" and "don't use Yes and No…

Alan Dye would disagree. https://daringfireball.net/2025/12/bad_dye_job

I think you forgot the /s

Anyway, interesting story. I didn't know what a key window is. I googled. It's the active window.

Post reply on HN