Live data from Hacker News

Recreating macOS’s Drift Screensaver with Rust and WASM

github.com

31–40 of 47 posts

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#33
post #18
post #17

Why did screensavers ever do anything besides just blanking the screen?

I think the intent was not only to not do harm, but to undo the burn-in caused when the screen is on by cycling each pixel on and off. (Early CRT monitors used to have a “memory” of what was on there before, similar to the artifacts left behind after e-ink screens are cleared)

Plus early on you couldn't turn off the screen from the PC, only the physical button worked. We had to wait for VESA blanking IIRC to have something working.

So either your screen was always on, or you printed moving pattern to avoid burning the phosphor.

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#34
post #17

Why did screensavers ever do anything besides just blanking the screen?

Prior to the mid-1990's, blanking the screen simply meant painting the screen black in software. Later video cards would allow you to turn off the video signal and monitors would blank if they lost the signal. However, this would only work if both ends supported power saving modes. Otherwise the electronics (including the picture tube) for the monitor would operate normally. The only other option was to turn off the monitor manually or, on machines with an integrated monitor, to turn the brightness down.

If the monitor is going to be on anyway, why wouldn't people want to display something interesting on it?

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#35
post #20

"it might stand to dethrone the venerable Flurry screensaver" - You are absolutely right. The first time I saw the screensaver, I was completely mesmerized and watched it for a few minutes before getting back to work. Out of curiosity, why Rust? Not saying anything against it, just looking to understand your take on it.

I had 2 requirements starting out:

1. It absolutely had to run in the browser. 2. I wanted the option of shipping native binaries later on, e.g. screensavers

This narrows the choice to something that can compile to WASM and has bindings for WebGL/OpenGL. Rust has substantial support for these technologies, there's an active graphics community, and, personally, it felt approachable for someone without experience with C/C++.

Also, I write Haskell/Elm for a living. I don't need much convincing to pick up another typed, memory-safe language.

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#36

It's taxing on CPU and GPU: normal | running screensaver in browser CPU: 5% | 15% GPU: 10% | 45%

What’s your GPU? My phone can handle the demo without freaking out so I find it hard to understand why a PC would take half its available GPU compute to do the same.

MBP with M1 Pro chip.

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#37

What's the missing secret sauce that the anonymous apple employee alludes to? Any guesses?

My guesses based on intuition:

1) Colors are set based on desktop wallpaper chosen by the user automatically

2) The little lines never cross at more than slightly more than parallel in the real one, but they sometimes do here

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#38
post #8

Are these screensavers designed to be impressive and fun while also requiring minimal processor (battery)? I always assumed the screensavers that ship with the Mac are carefully designed not to unnecessarily drain the battery, but I realised just now that’s just an assumption.

The older ones are pretty lightweight shaders, and don't seem to tax the machine that much. Drift would heat up my Intel Mac pretty quickly though (~70c, 80c if connected to an external monitor), but presumably only because the iGPU was struggling. I'd be curious to profile the official program and see what's hogging the GPU so much...

> I'd be curious to profile the official program and see what's hogging the GPU so much...

It's a fluid simulation. Compute shaders, compute shaders, compute shaders.

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#39
post #8

Earlier quoted context omitted.

The older ones are pretty lightweight shaders, and don't seem to tax the machine that much. Drift would heat up my Intel Mac pretty quickly though (~70c, 80c if connected to an external monitor), but presumably only because the iGPU was struggling. I'd be curious to profile the official program and see what's hogging the GPU so much...

> I'd be curious to profile the official program and see what's hogging the GPU so much... It's a fluid simulation. Compute shaders, compute shaders, compute shaders.

Right, but a lot of those shaders will run fine on the CPU as opposed to the GPU. Especially with the current lineup of supported Intel Macs, there's pretty much no supported machines that don't have comprehensive vector computation pipelines on the CPU-side of things.

IMO the best balance would be maxing out the AVX pipeline but keeping the CPU at base clock, and then leave the rendering/framebuffer manipulation to the GPU. I suspect that running both the simulation and 5k/2k displays simultaneously is too much for the GPU to handle.

Re: Recreating macOS’s Drift Screensaver with Rust and WASM

#40
post #4

Earlier quoted context omitted.

Hit "C" to bring up the control panel which, btw, is written in Elm!

Ah, the tell-tale signs of re-implementing inputs from scratch! It's not so much "hit C" as "Hit the key with code KeyC"... which means press "j" if you're using Dvorak, and something else if you're using Azerty, Colemak, or some other layout.

is there a library most people use?
Post reply on HN