pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[pulsar-next] `scrollbar-style` crashes the editor

Open savetheclocktower opened this issue 1 year ago • 1 comments

The scrollbar-style library manages to crash the editor window when it reloads. It was rewritten in N-API a while back, but it's still got some context safety issues that I can replicate quite easily via a worker_threads test.

But since Electron can replace at least some of its functionality, the right answer might be to abandon it entirely.

savetheclocktower avatar Sep 28 '24 21:09 savetheclocktower

In fact, that's what I did!

The purpose of scrollbar-style is to detect macOS's current scrollbar style — overlay or regular — and to find out when it changes.

Strangely, it's easy to find out when the value changes using just Electron's systemPreferences API; but it's not possible to get the value on demand. The good news is that we can expose the appropriate AppKit method with a small, targeted native module.

I wrote get-scrollbar-style for that very purpose! It's easy to write a context-safe native module when you don't have to deal with any async stuff. For extra safety, we can move it to the main process, since that's the only place we can use the systemPreferences API. This is fine because there's no compelling reason for it to be in the renderer in the first place.

This is fixed in the updated-latest-electron branch and is a good candidate for a backport to current Pulsar.

savetheclocktower avatar Sep 28 '24 21:09 savetheclocktower