Skip to content

Commit

Permalink
[watchOS] Turning on lockdown mode should not cause certain web fonts…
Browse files Browse the repository at this point in the history
… to be enabled

https://bugs.webkit.org/show_bug.cgi?id=259791
rdar://112281112

Reviewed by Aditya Keerthi.

To optimize performance and data use, web fonts are currently always disabled on watchOS. However,
enabling lockdown mode on watchOS actually causes us to *enable* support for a small subset for web
fonts, since we change `DownloadableBinaryFontAllowedTypes` state from `None` (i.e. no web fonts
allowed at all) to `Restricted`. This subsequently causes cached fonts in the GPU process to end up
in an unexpected state on watchOS, triggering a `MESSAGE_CHECK` and causing the web process to
terminate.

It doesn't make sense for Lockdown mode to make web fonts *less* restrictive, so we can simply fix
this by maintaining `DownloadableBinaryFontAllowedTypes::None` in the case where web fonts are
already unconditionally disabled.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::adjustSettingsForLockdownMode):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/LockdownModeFonts.mm:

Rebaseline an API test for compatibility with watchOS as well, where web fonts are always disabled.

Canonical link: https://commits.webkit.org/266563@main
  • Loading branch information
whsieh committed Aug 4, 2023
1 parent 29231ce commit eb66cb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/WebKit/WebProcess/WebPage/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4461,7 +4461,14 @@ static void adjustSettingsForLockdownMode(Settings& settings, const WebPreferenc
#if ENABLE(WEB_AUDIO)
settings.setWebAudioEnabled(false);
#endif
settings.setDownloadableBinaryFontAllowedTypes(DownloadableBinaryFontAllowedTypes::Restricted);
switch (settings.downloadableBinaryFontAllowedTypes()) {
case DownloadableBinaryFontAllowedTypes::Any:
settings.setDownloadableBinaryFontAllowedTypes(DownloadableBinaryFontAllowedTypes::Restricted);
break;
case DownloadableBinaryFontAllowedTypes::Restricted:
case DownloadableBinaryFontAllowedTypes::None:
break;
}
#if ENABLE(WEB_CODECS)
settings.setWebCodecsEnabled(false);
settings.setWebCodecsAV1Enabled(false);
Expand Down
4 changes: 4 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/LockdownModeFonts.mm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@
auto targetResult = static_cast<NSNumber *>([webView objectByEvaluatingJavaScript:@"target.offsetWidth"]).intValue;
auto referenceResult = static_cast<NSNumber *>([webView objectByEvaluatingJavaScript:@"reference.offsetWidth"]).intValue;

#if PLATFORM(WATCHOS)
EXPECT_NE(targetResult, referenceResult);
#else
EXPECT_EQ(targetResult, referenceResult);
#endif
}
}
}

0 comments on commit eb66cb9

Please sign in to comment.