333 points · by PikachuEXE · 5y ago · 198 comments
Given how simple most UI is, especially these days (circles filled with gradients, roundrects) and given how many different screen sizes and resolutions are used even within Apple’s first party displays, it’s almost insane macOS isn’t resolution independent.
With how advanced macOS graphics stack is, I don't understand why does Apple not do this, instead insisting on using integer multipliers. Some iPhone models, too, render the UI at 3x and then downscale it to fit the screen. Even more curious is the fact that they have returned it as a float for as long as retina displays were a thing: https://developer.apple.com/documentation/appkit/nsscreen/13...
edit: one important difference I forgot to mention. On Android, all draw calls on the Canvas, and all view dimensions and other things like text sizes, always take physical pixels. It's your job to multiply and round everything correctly. On macOS and iOS, all graphics APIs take "points", which are those logical pixels you get after the scaling is applied, "density-independent pixels" as Android calls them. I guess Apple thought it would make it easier to adapt existing apps to retina displays. Android has always supported UI scaling, so there was no problem designing the API the way it is.
There was also a lot of custom layout code in existing apps, both first and third party, which just didn't work at arbitrary scale factors because it was never tested.
Yet another complication is that apps are expected to handle scale changes, e.g. if the user drags a window from one display to another. Android doesn't have to deal with this.
After years of trying to make it work, Apple basically gave up and did the scaling in WindowServer.
The thing I love about HackerNews is how you can casually run into people who worked on things you've been using every day for the last 10 years.
> The short answer to your question is "rounding."
Yeah, on Android, you're supposed to round yourself. View dimensions are integers, so you have to, but graphics APIs take floats, you don't strictly have to, but you want to anyway. Even though there's no such thing as pixel-perfect on AMOLED displays thanks to their subpixel layout. When you use XML and specify `25dp`, the system does the rounding.
> Android doesn't have to deal with this.
Oh it does! Though it deals with this in a lame way: your activity with all its views gets destroyed and recreated for a "configuration change" unless you've explicitly specified that you can handle this specific kind of change. Density doesn't change often, but the possibility is certainly there.
I remember how around 2013 there was this bizarre device. It was a phone, but it came with a tablet you could dock it into. The tablet contained only a screen and a battery. The screens on the phone and on the tablet had different densities. There were bug reports about my app not handling these transitions correctly, presumably because I was dumb back then. I can imagine something similar happening with the new hotness, foldable devices, where the external and internal screens could have different densities.
And while I have you, one question. Why does macOS have the coordinate system origin in the bottom left? I've always found that bizarre, especially when iOS does use the usual top left.
Plus, the way it works means that (as I understand it), programs don't really need to do anything to support all these variations. Behind the scenes, the OS renders everything at a very high resolution, then uses the graphics hardware to smoothly scale everything down to your chosen size.
My eyes aren't good enough to use the native resolution, and using the 'retina' setting wastes too much screen real estate (I mean, that's why you buy a big monitor for, right?), so having somewhere between the two is essential. I was concerned that choosing a non-simple scaling (neither doubled or native) would make things blurry or slow, but it just works, and works well. Even dragging windows between a high-DPI and normal DPI display is seamless.
As an aside, after years of using a low-res monitor, with tiny fonts to squeeze as many terminals and emacs windows onto my screen, high-DPI is a godsend. For a long time after getting the 4k monitor, I'd just play around with the mac's screen zoom accessibility function (uses the mouse wheel to smoothly zoom into an area of the screen) - it was astounding to me just how much you can zoom before individual characters become blocky. They used to be drawn as 8x8 pixels and now, to my aging eyes, each letter looks as smooth and detailed as printed text!
Another tangentially related issue, how do you display a pixel perfect image on a non-integer DPR. For example lets say you want to show 8bit mario in HTML at exactly 16 or some multiple of 16 pixels so that there's not odd integer scaling. it's quite a pain, requires JS, and requires flexible page layout since you won't be able to use "CSS pixels" to decide the size to display it. Possibly that's an argument for never having non-integer DPRs.
Leave everything as fixed pixels for backwards compatibility and add scaled pixels in for new development. I can guarantee that if Apple ported the main apps like Finder, Mail, Safari, Calendar, Music to support resolution independence that other developers would jump on board quickly to keep up to date.
Windows 10 has solved all of these, you need to find and use some old 3rd party apps to have this issue
Win10 scaling is..... very hit or miss. Various programs are of course all over the place, but some system utilities don't even render correctly. Window size and control placement is mostly correct everywhere, but text? Images? Tooltips? Ooooh boy are those a mess. Maybe like 20% of apps I've ever touched don't render something correctly. That's A LOT of problems.
And that's before I start talking about running two screens at different densities. Then it's borderline hilarious how broken things are.
For a couple of examples: The nVidia Control Panel ignores the scaling on the 4k display and renders tiny text as if the display was set to 4k. GPU-Z looks like a blurry mess.
Solved would mean I'm not hacking a scaling factor into the perforce config file to get its window to match the rest of the UI. Solved would mean that Windows handled it for everything drawing windows.
Most apps are 3rd party apps!
I used to write a lot of WPF apps and the resolution independence was a real thing. I guess I just got lucky in that car never used any legacy apps.
This is a good thing, since as much as I like 4K resolution, my middle aged eyes prefer to have things scaled up a bit.
For example with the Windows solution, I have a laptop with a 1920x1080 screen which I set to 125% and then a 3440x1440 monitor which I set to 150%.
When I connect my MacBook to that monitor, I have to resort to hacks like the one linked here, or live with tiny text and heaps of wasted space.
(This is frustrating me to the point that I am on the verge of getting a macbook for the first time now even though my laptop is otherwise great and only a year old, so it's good (for my pocketbook anyway) to know the other side has its own issues).
Eh I have a Macbook and various apps will cause the laptop to not go to sleep. Web browsers are the largest offenders in my experience. I've often enough came into my office to a laptop that was running at 100% CPU all night.
That said, yeah I'll check if there are updates I'm missing.
Windows: give users choice, including the choice to end up with blurry apps with ill aligned UI.
Mac: we cannot let you stray outside these boundaries, otherwise your UI experience will deviate too much from the experience we determine to be the best.
For me, scaling on non-HiDPI screens is a feature. I like big text and big buttons and Windows gives me that. I’ll gladly except perfect big UI 99% of the time, if the cost is ugly UI 1% of the time.
I agree, and wish to add that the new graphics stack on Linux is also far superior to MacOS in the same way. By "new graphics stack" I mean Wayland without XWayland.
In fact, of the 3 desktop operating systems, I distinctly prefer the details of how my screen looks on Linux: on Windows, small (plus or minus 25%) changes in scaling factor tend to cause large changes in the details of the rendering of text (e.g., the average width of lines and curves can seem to halve or double or the text can seem to change font) which I find a little distracting.
MacOS is by far the worst of the three. Not only does it look horribly blurry to me (on a normal old monitor -- I do not own any HiDPI monitors) when a non-integer scaling factor is applied (via the Displays pane of System Preferences), but even at the native resolution of the display, it is blurrier than I like because of a decision by Apple long ago to optimize for how closely text on the screen matches how the same text looks like when printed out. (At least one of the terms hinting and anti-aliasing are relevant here, but I don't know the details.)
Windows is further along than Linux in the rollout of a truly resolution-independent graphics stack: on Linux, I have to pass certain flags to Chrome to get it to circumvent XWayland and not be blurry -- and then there are a few bugs -- but bugs I can definitely live with. Also, on Linux, I have to use a special branch of Emacs (named feature/pgtk) to get Emacs to be non-blurry when a non-integer scaling factor is set in Gnome Settings, feature/pgtk has a bad bug (freezing at random times) which I learned to work around (by starting a second "sacrificial" Emacs instance, which luckily would always be the first to freeze, and once frozen would somehow prevent the first instance from freezing).
I was a MacOS user for 10 years, and would still be a MacOS user today if I hadn't spent time on Windows 10 and had my eyes opened to the painfulness of the two aforementioned sources of blurriness (namely, Apple's decision to optimize for fidelity to hardcopy and MacOS's use of a scaling algorithm when the scaling factor is not an exact integer). I always knew during those 10 years that MacOS was too blurry for me at non-integer scaling factors, but I thought it was OK because the 2 individual apps I spent the most time in (Emacs and my browser) have app-specific scaling factors that don't introduce blurriness, and it wasn't until I spent time on a different OS that I understood how sub-optimal MacOS was for my pattern of use and my particular visual cortex.
If you are on a Mac, a good way to experience what I am talking about is to install Google Chrome, then operate the "Zoom" control in the menu of the 3 vertical dots. Note how every element in the viewport instantly changes size. PNG and JPG images (e.g., the white "Y" in the left top corner of this page, but not the white rectangle surrounding it) might become blurry (or stop being blurry) because unlike essentially everything else on a modern web page, PNGs and JPGs are not stored as resolution-independent mathematical descriptions of curves. Well, Windows has a control in its Settings app that has the same effect on every visual element on the OS (including the mouse cursor). And on my Linux box, Gnome Settings has a control that does the same thing. (Safari and Firefox might have the same "zoomability" as Chrome does; I haven't used Firefox on a Mac in years; back when I did, its zoom control zoomed only the text, but not the images; I no longer have access to a Mac, so cannot experiment with Safari.)
This is a major factor. macOS has aggressively optimized for these in recent years, often at the expense of classic 1x display experience. I use 5K 27" and 4K 24" monitors at 2x scaling (this is the default), and the result is excellent.
I worked for Apple more than two decades ago, but now I'm a happy Windows 11 user.
These days, fonts, SVG images, CSS, etc, are stored as mathematical descriptions of curves that can be rendered at any scaling factor. Any use of a scaling algorithm, like MacOS does when the scaling factor is not an integer multiple of the display's true resolution, is an unnecessary source of blurriness. A HiDPI display make the blurriness less noticeable, but do not solve the basic problem, which is that the scaling algorithm reduces the "effective resolution" of the display.
(I have never used a HiDPI display with a desktop OS, but another participant here on HN has and reported that he notices MacOS's blurriness relative to Windows even on a HiDPI display.)
(I have 4k screen and need to scale up the text size to 2560*1440. Then I found these app only take the 2560 screen to remote)
The best remote experience I have had with macOS is using the built in VNC, but not with a standard client. Using the Remotix client provides a great experience. It's $50.
I have also heard that NoMachine for macOS works really well, but I have not tried it.
Mac mini's without a monitor hooked up can only display at a certain aspect ratio while remote screen sharing. The typical solution is to use a dummy hdmi plug (~$10) plus an app like SwitchResX (~$20) to support custom screen resolutions.
If OP's app works as described, then this is a free software solution to a $30 problem.
Create a dummy display for the full-screen presentation, share that into the remote meeting/projector, and preserve the primary display for presenter notes, logtails, chat, etc.
Bonus to sharing only a window - you never accidentally show something you didn't want to, like that email or messages notification...
I've given up the idea of connecting to mini over screensharing and connected a couple of displays to it, happily.
If you connect a Mac (mini, MacBook pro, air) to an external monitor, AND this monitor is not recognized as "retina" (eg. Apple $4599 XDR) AND you are not running at the monitor's highest resolution, the screen will be blurry.
There are a lot of "ands" in the above sentence, but it's actually quite common situation. Retina monitors are expensive. For non-retina monitors, native highest resolution still renders objects too small for many people.
On MacBook Pro/Air the solution is to mirror the screens. The MacOS thinks that it renders to the retina screen and sends appropriate re-scaling to the external monitor. But mirroring has its problems. For example, expect ratio will be the same as MacBook's internal screen. This may result in black bars on the monitor, depending on its aspect ratio.
Also, in M1 MacBook Pro 2021, the aspect ratio is variable, due to the 72 pixels menu bar up top, going in and out. I am not sure what will happen when you mirror the screens there.
Hopefully the above software solves this problem.
On a related note, does anyone know of similar software to create dummy displays on Linux? All I could find so far is some trickery which only works with Intel hardware on X11 [3].
[1]: https://github.com/H-M-H/Weylus
[2]: https://github.com/pavlobu/deskreen
[3]: https://github.com/H-M-H/Weylus#intel-gpu-on-xorg-with-intel...
Xvfb (https://linux.die.net/man/1/xvfb)
wayvnc: https://github.com/any1/wayvnc
Weston has a headless backend also.
So, to people who build stuff like this and release it... Thank you for your service!
My creativity is normally put to use on something other, like MonitorControl, but working on BetterDummy is fun as well. :)
LG UltraFine 4K Display
I guess I'll have to try this with my display!
> To fix this problem, BetterDummy creates a virtual dummy display which you can then utilize as a mirror main.
What is a "mirror main"?
> M1 macs tend to have issues with custom resolutions. Notoriously they don't allow sub-4K resolution displays to have HiDPI ("Retina") resolutions even though (for example) a 24" QHD 1440p display would greatly benefit from having an 1920x1080 HiDPI "Retina" mode.
So, if you connect a non-4k display, the Mac will render in a way that won't look as sharp as the display could.
If you are in the marked for a new display, just but a 4K model (unless you have good reasons not to) and you won't need this hack.
That's not true. A display will happily utilise it's full hardware resolution. The problem, as I understand it, is you can't change the DPI of the monitor. You can configure a 2560x1440 display to use a lower resolution (e.g. 1920x1080 or 1600x900), but then the monitor itself will upscale this into a blurry full screen.
Tricking MacOS to change the DPI would let you configure the display to use all 2560x1440 pixels, but drawing everything bigger, at full resolution.
Especially with the wholly Apple-made M series of chips, they control the entire video stack down to the transistor level.
Dummy plugs should be syscalls, not physical things.
I agree with you, it is funny that we need dummies and workarounds (being hardware or software).
I'm using 1920x1200 monitors. If I upgrade to a M1 Pro/Max Mac Mini (if those will ever be available) will I have any trouble using them at their native resolution?
From what I understand, this trick is helpful for headless machines.
I tested this as part of testing the app on Intel and Big Sur (BetterDummy worked fine on this Intel config with an integrated Intel UHD630 so headless Mac Mini 2018 users should be fine).
I've found display compatibility has not been straightforward, having owned an M1 mini for the last year...which is unfortunate for a computer without a built-in screen.
Don't count on it supporting multiple external monitors. Expect compatibility issues, etc.
Last week it kind of burned a flickering rectangle onto my Dell ultrasharp 4k, which I thought was toast, but it gradually cleared up.
Like I said - weird.
Well, no way I'm buying a M1 due to the lack of RAM. Hopefully Apple will make a decent desktop for me next year and fix some silicon bugs while they're at it.
Incidentally, my current x86 mac mini is wonky with the hdmi output as well. The monitor randomly goes black for a few seconds once in a while.
It has been really helpful to finally have virtual displays that respond to CGDisplay methods when developing Lunar (https://lunar.fyi)
It also helped in unearthing some bugs apparently. [0]
[0] https://github.com/MonitorControl/MonitorControl/issues/752#...
My monitor have light leakages issues. In Windows, I scale it down and use black tap covered all 4 edges. It looks like a normal screen. :)
When I use it as macOS external, I have to guess the top menu position :p
https://telepromptermirror.com/mirror-flip-screen/
Personally I gave up on the window flippers and use LunaDisplay w/ iPad.
Why? The window flippers flip the window — but not the mouse or button click targets! So you need the whole screen to flip, not just the window.
The thing that annoys me, is that I have a second display that I use, from time to time (when giving video classes, for instance), but it remains assigned to a different device, most times.
However, I can't leave it plugged in. If I do, the OS insists that I have a second screen, even though it is not actually connected to the Mac. This means that I can lose my cursor and the graphics processors are rendering undisplayed pixels.
I can use an app like SwitchResX[0], but I feel that I should not need it. The OS should detect more than just if an HDMI cable is plugged in. It needs to know whether or not the screen is actually "live," and rendering graphics.
Hardware KVMs weren't much better, but if you're willing to spend the money, and have enough DP sources on both sides, they aren't too bad.
Funny how hard/expensive it is to replicate the convenience of a nice analogue KVM with a bunch of VGA/DVI/PS2 I/O, a knob, an not much else...
An iMac pro with an eGPU was able to accomplish this perfectly.
--edit
The Display Dummy app resolves this problem perfectly. In the Display Dummy menu, select 16:9 ratio, then go to displays in system preferences and choose 3840x2160. Curious if it will be able to work with dual Pro Display XDRs on M1.
There may well be a way to do it from the CLI as well but the app just sits as a tray icon in the menu bar which is great from a "I don't know what I just plugged in but I want to to just be <x>" perspective.
Unfortunately the original M1 limited SwitchResX from using HiDPI at higher resolutions. It is limited to 3008x1692 at HiDPI (half of 6k).
The higher resolutions are available but they aren't HiDPI and text looks noticeably worse.
It's a known issue with several display tools like: https://github.com/xzhih/one-key-hidpi/issues/164
I just tested the Dummy Display app and it resolved this perfectly. The app definitely works, even better than the m1 limitation of SwitchResX.
Confirmed working with dual Pro Display XDRs, M1 Max, Monterey (14" MBP in clamshell mode).
Bad news, you lose HDR color support (ouch).
Current workarounds involve toggling BetterDummy as needed, or higher resolution on one monitor and native HDR on the other.
BetterDummy simply navigates around the whole problem by creating Virtual Displays that are mirrored to the main display. This is in one regard inferior, since this is inherently a workaround but on the other hand can work on-the-fly and all possible resolutions are instantly available and accessible via System Preferences/Displays.
Can anyone shed a light on this feature? Doesn't HiDPI require graphics hardware ?
For ppl who until now had to resort to mirroring the internal displays (as M1 MacBooks - before the new MBPs - support only the internal display + a single external display) the benefit is more obvious, they now can use clamshell mode and don't have to drive the full MacBook display hardware (with brightness turned down to zero) all the time.
Basically would need some sort of VM or sandbox that could run the apps in 1920 width and scale down to fit 1440px.
You would create a dummy display at 1920x1080 (or higher), then have your real display become a mirror of the dummy display. macOS will scale down to display on 1440x900.
It allowed using HiDPI at a higher resolution (4k or 3840x2160) than the M1 chipset natively allows (3k or 3008x1692 HiDPI on the 6k XDRs).
- Works just fine on an Intel Mac (tested one with Intel UHD 630). - Works well with Big Sur (tested on an Intel Mac). - Does seem to provide headless macs with a HiDPI virtual display with customizable resolution (tested via Screen Sharing, resolution switch on the fly worked, all resolutions are available without any real display connected - should work with VNC as well, but I did not test that).
SwitchResX is cool but also a bit complex. 'Display Menu' is simpler but also somewhat limited.
If you have a 2+ display setup for example, you can create a Dummy, mirror it to one display but leave the other display unaffected. Or you can create 2 dummies, mirror each one to a separate display.
Every display can serve as a Main or Extended display, as well as a Mirror for some other display. Therefore a mirrored set can be Main or Extended as well. A typical use case is to use your MacBook display as an Extended display alongside your external display which is a Mirror of a Dummy that is set as Main display (providing all the fine grained HiDPI resolution options).
Hope this helps!
macOS is in these days at the moment. What does that say about its product arc?