Archive for February 6, 2023

Monday, February 6, 2023

Tracking Hover Location in SwiftUI

Natalia Panferova (tweet):

For a while we only had onHover(perform:) modifier in SwiftUI that is called when the user moves the pointer over or away from the view’s frame. There used to be no official way to continuously track the pointer location. This changed with the introduction of onContinuousHover(coordinateSpace:perform:) in macOS 13 and iPadOS 16.

The new modifier lets us read the current HoverPhase and reports the exact location of the pointer when it’s within the view’s bounds. Let’s see it in action.

Update (2023-02-13): John Siracusa (Mastodon):

SwiftUI’s .onHover View method fails sporadically when applied to a view that does not cover the entire containing window and that window has a “clear” background color. This sample project demonstrates the bug, which has been filed with Apple as FB11988707.

The workaround is to make the background color anything that is not “clear.”

Update (2023-03-08): Donny Wals:

Long shot: in a macOS app that leverages this gist for a more reliable hover effect in SwiftUI[…]

On some macs with macOS 12.x this is completely fine. On others with 12.x the app is fine until the very first time the app is clicked. After that happens there’s a huge slowdown that seems related to the code in that gist (based on Instruments trace) but without a reliable reproduction on virtually identical machines I have no idea where to start debugging.

Facebook Negative Testing

Kathianne Boniello (via Jamie Zawinski):

Facebook can secretly drain its users’ cellphone batteries, a former employee contends in a lawsuit.

The practice, known as “negative testing,” allows tech companies to “surreptitiously” run down someone’s mobile juice in the name of testing features or issues such as how fast their app runs or how an image might load, according to data scientist George Hayward.

He refused to do that and was fired.

Cory Doctorow:

Hayward balked because he knew that among the 1.3 billion people who use Messenger, some would be placed in harm’s way if Facebook deliberately drained their batteries – physically stranded, unable to communicate with loved ones experiencing emergencies, or locked out of their identification, payment method, and all the other functions filled by mobile phones.


We don’t know much else, because Hayward’s employment contract included a non-negotiable binding arbitration waiver, which means that he surrendered his right to seek legal redress from his former employer.

Update (2023-02-14): Tracy Lopez:

Testing within an app is aimed at improving it, but this was not the case with Facebook apps, both on iOS and Android: the company it slowed down the loading of the images, the connections to the pages of the links and even made the application consume more battery.


Meta carried out negative tests for draw a relationship between app performance and app experience.

This seems to be clearly in violation of App Store guideline 2.4.2. Though, according to the NTIA, Apple claims it “reviews each line of an app’s code,” we know they don’t do that in any real sense and likely didn’t realize Facebook was doing this.

Example Custom FormatStyles

Jonathan Wight:

I’ve been making a package of custom Swift (Parseable)FormatStyles for types that don’t currently get any love by the standard library.

My main need for this is GUI apps showing complex 3D types (think a SwiftUI field editor for a quaternion, etc) -- but am building it by composing basic types and FormatStyles.


PodSearch Reborn

David Smith:

Back in 2017 I had created a site which took the the audio of some of my favorite podcasts and tried to make them searchable by passing them through an automated speech-to-text engine.


Thankfully since then OpenAI has released Whisper a powerful speech-to-text engine that I can run right on my Mac and results in transcripts that are shockingly good. They aren’t quite at the level of a human transcriber but they get darn close in many instances. Getting close to the level where you could use them to grab a pull quote with only a little bit of tidying up to do.


Update (2023-02-14): Jason Snell:

While not perfect, Whisper was staggeringly better than the 2017 transcript and really, much better than any other AI-driven transcription I’d tried recently. It got the punctuation. It got proper names. And it didn’t turn “Thanks for listening to The Incomparable, I’ve been your host Jason Snell” into “Goodnight everybody for listening to be uncomfortable, I’ve been your Hostess and smell.”

Fortunately, a fellow named Georgi Gerganov made a C++-native port of Whisper that is easy to install and run on macOS and is optimized for Apple silicon. I downloaded and installed Gerganov’s version, downloaded the medium English model, and discovered that it could transcribe a podcast at rates up to 2x!

This was great, but the last thing I needed was to have to remember all the arcane command-line commands required to get the files in the right place. So instead, I wrote The Transcriptor, a Shortcut that lets me control-click on audio files and turn them into transcripts in a format of my choice.