Modified: trunk/Tools/ChangeLog (241919 => 241920)
--- trunk/Tools/ChangeLog 2019-02-21 23:59:29 UTC (rev 241919)
+++ trunk/Tools/ChangeLog 2019-02-22 00:03:25 UTC (rev 241920)
@@ -1,3 +1,24 @@
+2019-02-21 David Kilzer <[email protected]>
+
+ Leak of CFErrorRef objects (1.92 Kbytes) in com.apple.WebKit.WebContent.Development running WebKit layout tests on iOS Simulator
+ <https://webkit.org/b/194761>
+
+ Reviewed by Myles Maxfield.
+
+ * WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
+ (WTR::activateSystemCoreWebFonts): Log `error` to console if
+ CTFontManagerRegisterFontsForURL() fails (macOS only). Update
+ to use ARC-compliant cast.
+ (WTR::activateFonts): Change `0` to `nullptr`. Update to use
+ ARC-compliant cast.
+ (WTR::installFakeHelvetica): Log `error` to console if
+ CTFontManagerRegisterFontsForURL() fails, but only on supported
+ platforms (macOS Mojave/iOS 12 and newer, not iOS Simulator).
+ Call CFRelease() on `error` to fix the leak. Update to use
+ ARC-compliant cast.
+ (WTR::uninstallFakeHelvetica): Update to use ARC-compliant
+ cast.
+
2019-02-21 Chris Dumez <[email protected]>
Flaky API Test: TestWebKitAPI.ProcessSwap.SuspendedPageLimit
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm (241919 => 241920)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm 2019-02-21 23:59:29 UTC (rev 241919)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm 2019-02-22 00:03:25 UTC (rev 241920)
@@ -88,7 +88,11 @@
// also activates e.g. Arial Unicode, which is not a variation of Arial.
for (NSString *coreWebFontName in coreWebFontNames) {
if ([fileName hasPrefix:coreWebFontName]) {
- CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeProcess, 0);
+ CFErrorRef error = nullptr;
+ if (!CTFontManagerRegisterFontsForURL((__bridge CFURLRef)fontURL, kCTFontManagerScopeProcess, &error)) {
+ NSLog(@"Failed to activate %@: %@", coreWebFontName, error);
+ CFRelease(error);
+ }
break;
}
}
@@ -121,8 +125,8 @@
[fontURLs addObject:[fontURL absoluteURL]];
}
- CFArrayRef errors = 0;
- if (!CTFontManagerRegisterFontsForURLs((CFArrayRef)fontURLs, kCTFontManagerScopeProcess, &errors)) {
+ CFArrayRef errors = nullptr;
+ if (!CTFontManagerRegisterFontsForURLs((__bridge CFArrayRef)fontURLs, kCTFontManagerScopeProcess, &errors)) {
NSLog(@"Failed to activate fonts: %@", errors);
CFRelease(errors);
exit(1);
@@ -138,7 +142,13 @@
RetainPtr<CFStringRef> configurationString = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, configuration));
NSURL *resourceURL = [resourcesDirectoryURL() URLByAppendingPathComponent:[NSString stringWithFormat:@"FakeHelvetica-%@.ttf", configurationString.get()] isDirectory:NO];
CFErrorRef error = nullptr;
- CTFontManagerRegisterFontsForURL(static_cast<CFURLRef>(resourceURL), kCTFontManagerScopeProcess, &error);
+ if (!CTFontManagerRegisterFontsForURL((__bridge CFURLRef)resourceURL, kCTFontManagerScopeProcess, &error)) {
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS_FAMILY) && !PLATFORM(IOS_FAMILY_SIMULATOR) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
+ // Registering shadow fonts is only supported on macOS Mojave and iOS 12 or newer, but not iOS Simulator. See Bugs 180062 & 194761.
+ NSLog(@"Failed to activate fake Helvetica: %@", error);
+#endif
+ CFRelease(error);
+ }
}
void uninstallFakeHelvetica()
@@ -154,7 +164,7 @@
if ([[url lastPathComponent] hasPrefix:@"FakeHelvetica"])
[fontsToRemove addObject:url];
}
- CTFontManagerUnregisterFontsForURLs(static_cast<CFArrayRef>(fontsToRemove), kCTFontManagerScopeProcess, nullptr);
+ CTFontManagerUnregisterFontsForURLs((__bridge CFArrayRef)fontsToRemove, kCTFontManagerScopeProcess, nullptr);
}
}