Bug 167068 - [Cocoa] Eliminate one of the two CTFonts inside FontPlatformData
Summary: [Cocoa] Eliminate one of the two CTFonts inside FontPlatformData
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords:
: 144141 186002 (view as bug list)
Depends on: 167300 167056 167061
Blocks:
  Show dependency treegraph
 
Reported: 2017-01-15 10:56 PST by Myles C. Maxfield
Modified: 2019-11-15 15:15 PST (History)
3 users (show)

See Also:


Attachments
WIP (38.47 KB, patch)
2017-01-15 11:15 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
WIP (37.42 KB, patch)
2017-01-15 11:20 PST, Myles C. Maxfield
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews103 for mac-elcapitan (546.28 KB, application/zip)
2017-01-15 12:10 PST, Build Bot
no flags Details
Archive of layout-test-results from ews122 for ios-simulator-wk2 (615.70 KB, application/zip)
2017-01-15 12:23 PST, Build Bot
no flags Details
Archive of layout-test-results from ews117 for mac-elcapitan (1.17 MB, application/zip)
2017-01-15 12:24 PST, Build Bot
no flags Details
WIP (38.60 KB, patch)
2017-01-18 13:34 PST, Myles C. Maxfield
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-elcapitan (829.28 KB, application/zip)
2017-01-18 14:56 PST, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (966.48 KB, application/zip)
2017-01-18 15:00 PST, Build Bot
no flags Details
Archive of layout-test-results from ews124 for ios-simulator-wk2 (956.56 KB, application/zip)
2017-01-18 15:09 PST, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2017-01-15 10:56:11 PST
[Cocoa] Eliminate one of the two CTFonts inside FontPlatformData
Comment 1 Myles C. Maxfield 2017-01-15 11:15:38 PST
Created attachment 298907 [details]
WIP
Comment 2 Myles C. Maxfield 2017-01-15 11:20:56 PST
Created attachment 298908 [details]
WIP
Comment 3 Build Bot 2017-01-15 12:10:48 PST
Comment on attachment 298908 [details]
WIP

Attachment 298908 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/2895319

Number of test failures exceeded the failure limit.
Comment 4 Build Bot 2017-01-15 12:10:51 PST
Created attachment 298916 [details]
Archive of layout-test-results from ews103 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 5 Build Bot 2017-01-15 12:23:28 PST
Comment on attachment 298908 [details]
WIP

Attachment 298908 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2895309

Number of test failures exceeded the failure limit.
Comment 6 Build Bot 2017-01-15 12:23:31 PST
Created attachment 298924 [details]
Archive of layout-test-results from ews122 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 7 Build Bot 2017-01-15 12:24:39 PST
Comment on attachment 298908 [details]
WIP

Attachment 298908 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/2895384

Number of test failures exceeded the failure limit.
Comment 8 Build Bot 2017-01-15 12:24:42 PST
Created attachment 298925 [details]
Archive of layout-test-results from ews117 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 9 Myles C. Maxfield 2017-01-18 13:17:39 PST
CTFontCreateForCharactersWithLanguage() always returns LastResort D:
Comment 10 Myles C. Maxfield 2017-01-18 13:34:00 PST
Created attachment 299175 [details]
WIP
Comment 11 Myles C. Maxfield 2017-01-18 13:34:50 PST
Comment on attachment 299175 [details]
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=299175&action=review

> Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:893
> +    auto emptyCascadeList = adoptCF(CFArrayCreate(kCFAllocatorDefault, nullptr, 0, &kCFTypeArrayCallBacks));
> +    CFTypeRef keys[] = { kCTFontCascadeListAttribute };
> +    CFTypeRef values[] = { emptyCascadeList.get() };
> +    auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
> +    auto modification = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
> +    auto modifiedFont = adoptCF(CTFontCreateCopyWithAttributes(font, CTFontGetSize(font), nullptr, modification.get()));

This is probably a performance hit.
Comment 12 Build Bot 2017-01-18 14:56:32 PST
Comment on attachment 299175 [details]
WIP

Attachment 299175 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/2911401

New failing tests:
imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken.html
Comment 13 Build Bot 2017-01-18 14:56:36 PST
Created attachment 299188 [details]
Archive of layout-test-results from ews101 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 14 Build Bot 2017-01-18 15:00:49 PST
Comment on attachment 299175 [details]
WIP

Attachment 299175 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2911411

New failing tests:
fast/events/force-click-on-link-navigation.html
fast/events/cancelled-force-click-link-navigation.html
fast/events/force-click-link-selection-behavior.html
Comment 15 Build Bot 2017-01-18 15:00:53 PST
Created attachment 299190 [details]
Archive of layout-test-results from ews106 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 16 Build Bot 2017-01-18 15:09:34 PST
Comment on attachment 299175 [details]
WIP

Attachment 299175 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2911415

New failing tests:
fast/inline/padding-ellipsis-right.html
fast/text/fallback-language-han-2.html
Comment 17 Build Bot 2017-01-18 15:09:38 PST
Created attachment 299192 [details]
Archive of layout-test-results from ews124 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews124  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 18 Myles C. Maxfield 2017-01-22 22:49:33 PST
Assuming https://bugs.webkit.org/show_bug.cgi?id=167300 is completed, there are two different approaches for how to do this:

Approach 1: Use m_font everywhere and eliminate m_ctFont
Almost all the places which use ctFont() are using it to access some font-specific information, which means the cascade list won't be accessed, which means that these uses can be converted directly. However, ComplexTextController::collectComplexTextRuns() and ComplexTextController::collectComplexTextRunsForCharacters() actually use the new LastResort cascade list. If we can educate those places to treat a fallback font the same as LastResort, then we can eliminate m_ctFont().

Approach 2: Use m_ctFont everywhere and eliminate m_font
We can immediately add the cascade list to the font upon ingestion into the system. The one trick with this is that CTFontCreateForCharactersWithLanguage() (inside FontCache::systemFallbackForCharacters()) actually uses the cascade list to select a fallback font. We don't want to create a transient font every time this function is run. Instead, this could possibly be worked around by identifying the key pieces of information within a font which CTFontCreateForCharactersWithLanguage() is sensitive to, and just cache results using that information as a key. This information will probably have to contain weight, italics, and the information inside the font's class contained within its symbolic traits (https://developer.apple.com/reference/coretext/ctfontsymbolictraits/1509032-classmasktrait). Or we could work with the CoreText team to come up with a different solution.
Comment 19 Myles C. Maxfield 2019-11-15 15:14:14 PST
*** Bug 144141 has been marked as a duplicate of this bug. ***
Comment 20 Myles C. Maxfield 2019-11-15 15:14:47 PST
*** Bug 186002 has been marked as a duplicate of this bug. ***
Comment 21 Myles C. Maxfield 2019-11-15 15:15:04 PST
See duplicates