Title: [270590] trunk
- Revision
- 270590
- Author
- an...@apple.com
- Date
- 2020-12-09 11:30:10 -0800 (Wed, 09 Dec 2020)
Log Message
Font loads are triggered too late
https://bugs.webkit.org/show_bug.cgi?id=219678
Reviewed by Geoffrey Garen.
Source/WebCore:
CSSFontSelector triggers font loads on zero duration timer after style resolution.
This can get delayed substantially and all sorts of less important loads (for example
CSS images triggered during render tree building) may go out first.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::beginLoadingFontSoon):
(WebCore::CSSFontSelector::loadPendingFonts):
Factor the actual load triggering into a function.
(WebCore::CSSFontSelector::fontLoadingTimerFired):
Timer still takes care of the checkLoadComplete.
(WebCore::CSSFontSelector::suspend):
(WebCore::CSSFontSelector::resume):
* css/CSSFontSelector.h:
* dom/Document.cpp:
(WebCore::Document::resolveStyle):
Trigger font loads right after style resolution, before render tree building.
LayoutTests:
* fast/text/web-font-load-fallback-during-loading-no-multiple-expected.txt:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (270589 => 270590)
--- trunk/LayoutTests/ChangeLog 2020-12-09 18:50:20 UTC (rev 270589)
+++ trunk/LayoutTests/ChangeLog 2020-12-09 19:30:10 UTC (rev 270590)
@@ -1,3 +1,12 @@
+2020-12-09 Antti Koivisto <an...@apple.com>
+
+ Font loads are triggered too late
+ https://bugs.webkit.org/show_bug.cgi?id=219678
+
+ Reviewed by Geoffrey Garen.
+
+ * fast/text/web-font-load-fallback-during-loading-no-multiple-expected.txt:
+
2020-12-09 Kimmo Kinnunen <kkinnu...@apple.com>
Implement RemoteGraphicsContextGL
Modified: trunk/LayoutTests/fast/text/web-font-load-fallback-during-loading-no-multiple-expected.txt (270589 => 270590)
--- trunk/LayoutTests/fast/text/web-font-load-fallback-during-loading-no-multiple-expected.txt 2020-12-09 18:50:20 UTC (rev 270589)
+++ trunk/LayoutTests/fast/text/web-font-load-fallback-during-loading-no-multiple-expected.txt 2020-12-09 19:30:10 UTC (rev 270590)
@@ -1,5 +1,5 @@
+Ahem.ttf - willSendRequest <NSURLRequest URL Ahem.ttf, main document URL web-font-load-fallback-during-loading-no-multiple.html, http method GET> redirectResponse (null)
web-font-load-fallback-during-loading-no-multiple.html - didFinishLoading
-Ahem.ttf - willSendRequest <NSURLRequest URL Ahem.ttf, main document URL web-font-load-fallback-during-loading-no-multiple.html, http method GET> redirectResponse (null)
Ahem.ttf - didReceiveResponse <NSURLResponse Ahem.ttf, http status code 0>
Ahem.ttf - didFinishLoading
This test makes sure that multiple remote fonts aren't requested concurrently due to timeouts. The test passes if only one remote font is requested.
Modified: trunk/Source/WebCore/ChangeLog (270589 => 270590)
--- trunk/Source/WebCore/ChangeLog 2020-12-09 18:50:20 UTC (rev 270589)
+++ trunk/Source/WebCore/ChangeLog 2020-12-09 19:30:10 UTC (rev 270590)
@@ -1,3 +1,32 @@
+2020-12-09 Antti Koivisto <an...@apple.com>
+
+ Font loads are triggered too late
+ https://bugs.webkit.org/show_bug.cgi?id=219678
+
+ Reviewed by Geoffrey Garen.
+
+ CSSFontSelector triggers font loads on zero duration timer after style resolution.
+ This can get delayed substantially and all sorts of less important loads (for example
+ CSS images triggered during render tree building) may go out first.
+
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::beginLoadingFontSoon):
+ (WebCore::CSSFontSelector::loadPendingFonts):
+
+ Factor the actual load triggering into a function.
+
+ (WebCore::CSSFontSelector::fontLoadingTimerFired):
+
+ Timer still takes care of the checkLoadComplete.
+
+ (WebCore::CSSFontSelector::suspend):
+ (WebCore::CSSFontSelector::resume):
+ * css/CSSFontSelector.h:
+ * dom/Document.cpp:
+ (WebCore::Document::resolveStyle):
+
+ Trigger font loads right after style resolution, before render tree building.
+
2020-12-09 Antoine Quint <grao...@webkit.org>
REGRESSION (r269812): Amazon Prime: thumbnail fails to expand properly
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (270589 => 270590)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2020-12-09 18:50:20 UTC (rev 270589)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2020-12-09 19:30:10 UTC (rev 270590)
@@ -365,7 +365,7 @@
// decrementRequestCount() in fontLoadingTimerFired() and in clearDocument().
m_document->cachedResourceLoader().incrementRequestCount(font);
- if (!m_fontLoadingTimerIsSuspended)
+ if (!m_isFontLoadingSuspended && !m_fontLoadingTimer.isActive())
m_fontLoadingTimer.startOneShot(0_s);
}
@@ -374,8 +374,11 @@
suspend(ReasonForSuspension::PageWillBeSuspended);
}
-void CSSFontSelector::fontLoadingTimerFired()
+void CSSFontSelector::loadPendingFonts()
{
+ if (m_isFontLoadingSuspended)
+ return;
+
Vector<CachedResourceHandle<CachedFont>> fontsToBeginLoading;
fontsToBeginLoading.swap(m_fontsToBeginLoading);
@@ -388,9 +391,17 @@
// Balances incrementRequestCount() in beginLoadingFontSoon().
cachedResourceLoader.decrementRequestCount(*fontHandle);
}
+}
+
+void CSSFontSelector::fontLoadingTimerFired()
+{
+ Ref<CSSFontSelector> protectedThis(*this);
+
+ loadPendingFonts();
+
// FIXME: Use SubresourceLoader instead.
// Call FrameLoader::loadDone before FrameLoader::subresourceLoadDone to match the order in SubresourceLoader::notifyDone.
- cachedResourceLoader.loadDone(LoadCompletionType::Finish);
+ m_document->cachedResourceLoader().loadDone(LoadCompletionType::Finish);
// Ensure that if the request count reaches zero, the frame loader will know about it.
// New font loads may be triggered by layout after the document load is complete but before we have dispatched
// didFinishLoading for the frame. Make sure the delegate is always dispatched by checking explicitly.
@@ -398,7 +409,6 @@
m_document->frame()->loader().checkLoadComplete();
}
-
size_t CSSFontSelector::fallbackFontCount()
{
if (!m_document)
@@ -431,24 +441,22 @@
void CSSFontSelector::suspend(ReasonForSuspension)
{
- if (m_fontLoadingTimerIsSuspended) {
- ASSERT(!m_fontLoadingTimer.isActive());
+ if (m_isFontLoadingSuspended)
return;
- }
- m_fontLoadingTimerIsSuspended = m_fontLoadingTimer.isActive();
+ m_isFontLoadingSuspended = true;
m_fontLoadingTimer.stop();
}
void CSSFontSelector::resume()
{
- if (!m_fontLoadingTimerIsSuspended)
+ if (!m_isFontLoadingSuspended)
return;
if (!m_fontsToBeginLoading.isEmpty())
m_fontLoadingTimer.startOneShot(0_s);
- m_fontLoadingTimerIsSuspended = false;
+ m_isFontLoadingSuspended = false;
}
}
Modified: trunk/Source/WebCore/css/CSSFontSelector.h (270589 => 270590)
--- trunk/Source/WebCore/css/CSSFontSelector.h 2020-12-09 18:50:20 UTC (rev 270589)
+++ trunk/Source/WebCore/css/CSSFontSelector.h 2020-12-09 19:30:10 UTC (rev 270590)
@@ -89,6 +89,8 @@
void incrementIsComputingRootStyleFont() { ++m_computingRootStyleFontCount; }
void decrementIsComputingRootStyleFont() { --m_computingRootStyleFontCount; }
+ void loadPendingFonts();
+
private:
explicit CSSFontSelector(Document&);
@@ -122,7 +124,7 @@
HashSet<RefPtr<StyleRuleFontFace>> m_cssConnectionsEncounteredDuringBuild;
Timer m_fontLoadingTimer;
- bool m_fontLoadingTimerIsSuspended { false };
+ bool m_isFontLoadingSuspended { false };
unsigned m_uniqueId;
unsigned m_version;
Modified: trunk/Source/WebCore/dom/Document.cpp (270589 => 270590)
--- trunk/Source/WebCore/dom/Document.cpp 2020-12-09 18:50:20 UTC (rev 270589)
+++ trunk/Source/WebCore/dom/Document.cpp 2020-12-09 19:30:10 UTC (rev 270590)
@@ -2035,6 +2035,8 @@
m_inStyleRecalc = false;
+ fontSelector().loadPendingFonts();
+
if (styleUpdate) {
updateRenderTree(WTFMove(styleUpdate));
frameView.styleAndRenderTreeDidChange();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes