Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari 14.1 does not follow setting #14

Closed
danilokleber opened this issue Apr 27, 2021 · 13 comments
Closed

Safari 14.1 does not follow setting #14

danilokleber opened this issue Apr 27, 2021 · 13 comments

Comments

@danilokleber
Copy link

Hey there. First of all, thanks for this utility!

I noticed that Safari 14.1 started to render fonts with smoothing on some websites. The rest of the system is fine as far as right now, including Safari's interface. Another place I noticed font smoothing was in email rendering on Spark. Do you know if this has to do with some new thing regarding to HTML rendering itself?

Feel free to close this issue if that's not applicable to the project. Thanks!

@abyrne10
Copy link
Contributor

Hi @danilokleber, thank you for your comment! I'm glad you found the app useful, and thank you for flagging up the issue with Safari 14.1.

I'll be upgrading to Big Sur 11.3 in the next few days, so I'll be able to test the issue you noticed with Safari 14.1 at that point. Do you have any websites in particular where you noticed the font smoothing preferences not being respected?

@danilokleber
Copy link
Author

Thanks for the reply @abyrne10!

I can say that GitHub and Google results are showing this behavior. Here's a comparison with Brave for Google results if that helps. Safari is in the back with a bolder font.

tg_image_1773996236

@abyrne10
Copy link
Contributor

Thanks @danilokleber, that's helpful, I'll let you know what I find 👍

@danilokleber
Copy link
Author

I did some more research and found one way around it if someone wants to minimize this issue.

https://forums.macrumors.com/threads/apple-releases-macos-big-sur-11-3-with-m1-optimizations-airtag-integration-updated-controller-support-apple-music-updates-and-more.2293343/post-29821274

It appears to fix it only in Safari itself but already helps a lot. HTML rendering still looks off in other apps. So I guess those new macOS/Safari versions changed something under the hood.

@leafac
Copy link

leafac commented Apr 29, 2021

I just upgraded to macOS 11.3 with Safari 14.1 and I can confirm the issue. As mentioned, it applies not only to the browser, but other contexts in which HTML is rendered, for example, rich-text emails in Mail.app.

@danilokleber
Copy link
Author

I was hoping macOS 11.3.1 would fix this, but no.

@danilokleber
Copy link
Author

Same thing on macOS 11.4 unfortunately.

@abyrne10
Copy link
Contributor

Hi @danilokleber and @leafac, sorry for taking so long to address this. We've now been able to spend some proper time on this, and we've tracked it down to a bug that was introduced into WebKit whereby it wasn't respecting the AppleFontSmoothing default setting, which is why the problem appears in Safari, Mail, Spark and other apps that use views backed by WebKit.

We can confirm that this issue has been fixed in recent builds of WebKit for Big Sur. However, at the the time of writing this, builds including the font smoothing fix had not yet made their way to the Safari Technology Preview, so it will probably be some time before Apple ships an update that fixes the font smoothing issue.

We created a small reference app comparing native text views with WebKit views to help with testing and debugging this issue, available here. The below screenshot shows what it looks like.
image

Here's how you can use it to test WebKit for yourself:

  1. Download a WebKit build, or get the code, checkout the commit you want to test, and build it from source. This took around an hour each time on a MacBook Pro (15-inch, 2017). To build older snapshots, we had to use a older versions of the Xcode command line tools to avoid compiler errors.
  2. Clone and open the Font Smoothing WebKit Bug project in Xcode, create a scheme if one doesn't exist, build and run the app, and confirm that font smoothing is respected in the text view but not the web view.
  3. Add an environment variable to the run configuration with the name DYLD_FRAMEWORK_PATH and the path to the folder containing your archived or built WebKit framework as the value. This will tell dyld, the dynamic linker, to link the app to that version of WebKit instead of the version shipped with macOS.
  4. Disable System Integrity Protection by restarting your Mac in recovery mode, launching a terminal, and running csrutil disable. N.B. make sure to re-enable SIP by running csrutil enable in recovery mode once you've finished testing. Disabling SIP is required because dyld will ignore the DYLD_FRAMEWORK_PATH environment variable if SIP is enabled.
  5. Build and run the project again in Xcode, and verify that font smoothing is now being respected by the web view (assuming you are using a build of WebKit where the bug either doesn't exist or has been patched out).

We think this was the patch that introduced the bug to WebKit (note also that it was reviewed after it was merged), and that this patch may have been the one that fixed the font smoothing issue, but we haven't confirmed it because the WebKit built archives don't go back very far, and building each snapshot from source takes a long time.

Unfortunately we weren't able to get Safari to work with the patched versions of WebKit using the scripts that WebKit includes, as the API seems to have changed.

I will update you again if we find a temporary workaround for this issue before Apple ships a fix. Cheers!

@danilokleber
Copy link
Author

danilokleber commented Jun 14, 2021

Wow, @abyrne10. That was a great roundup! Thank you very much for the time invested in this issue. Let's hope the fix lands on Apple's side soon.

@Eitot
Copy link

Eitot commented Jul 2, 2021

The Safari Technology Preview 127 contains the fix. Obviously is does not apply this to the system WebKit (for apps like Mail). Hopefully the release version of Safari 15 will have this.

@abyrne10
Copy link
Contributor

abyrne10 commented Jul 2, 2021

The Safari Technology Preview 127 contains the fix. Obviously is does not apply this to the system WebKit (for apps like Mail). Hopefully the release version of Safari 15 will have this.

Great news 👍

@153957
Copy link

153957 commented Jul 8, 2021

Here is my temporary fix, by using a custom CSS file through Safari's preferences (-> Advanced -> Style sheet):

html body * {
    -webkit-font-smoothing: antialiased !important;
}

@govertb
Copy link

govertb commented Jul 23, 2021

This seems to be fixed in Safari 14.1.2 (that came with macOS 11.5)!

@abyrne10 abyrne10 closed this as completed Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants