Title: [270851] trunk/Source/WebKit
- Revision
- 270851
- Author
- [email protected]
- Date
- 2020-12-15 10:16:50 -0800 (Tue, 15 Dec 2020)
Log Message
Add batching to WebPreferences updates
https://bugs.webkit.org/show_bug.cgi?id=219878
Reviewed by Sam Weinig.
WebPreferences::resetAllInternalDebugFeatures() and WebPreferences::enableAllExperimentalFeatures()
would trigger tens of calls to WebPageProxy::preferencesDidChange(). Fix by adding batching, and only
firing update() at the end of any prefs changed.
* Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb:
* Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb:
* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::update):
(WebKit::WebPreferences::startBatchingUpdates):
(WebKit::WebPreferences::endBatchingUpdates):
* UIProcess/WebPreferences.h:
(WebKit::WebPreferences::UpdateBatch::UpdateBatch):
(WebKit::WebPreferences::UpdateBatch::~UpdateBatch):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (270850 => 270851)
--- trunk/Source/WebKit/ChangeLog 2020-12-15 18:16:25 UTC (rev 270850)
+++ trunk/Source/WebKit/ChangeLog 2020-12-15 18:16:50 UTC (rev 270851)
@@ -1,3 +1,24 @@
+2020-12-15 Simon Fraser <[email protected]>
+
+ Add batching to WebPreferences updates
+ https://bugs.webkit.org/show_bug.cgi?id=219878
+
+ Reviewed by Sam Weinig.
+
+ WebPreferences::resetAllInternalDebugFeatures() and WebPreferences::enableAllExperimentalFeatures()
+ would trigger tens of calls to WebPageProxy::preferencesDidChange(). Fix by adding batching, and only
+ firing update() at the end of any prefs changed.
+
+ * Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb:
+ * Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb:
+ * UIProcess/WebPreferences.cpp:
+ (WebKit::WebPreferences::update):
+ (WebKit::WebPreferences::startBatchingUpdates):
+ (WebKit::WebPreferences::endBatchingUpdates):
+ * UIProcess/WebPreferences.h:
+ (WebKit::WebPreferences::UpdateBatch::UpdateBatch):
+ (WebKit::WebPreferences::UpdateBatch::~UpdateBatch):
+
2020-12-15 Youenn Fablet <[email protected]>
Fix alertMessageText regression from https://trac.webkit.org/changeset/269918
Modified: trunk/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb (270850 => 270851)
--- trunk/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb 2020-12-15 18:16:25 UTC (rev 270850)
+++ trunk/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb 2020-12-15 18:16:50 UTC (rev 270851)
@@ -113,6 +113,7 @@
void WebPreferences::enableAllExperimentalFeatures()
{
+ UpdateBatch batch(*this);
<%- for @pref in @exposedExperimentalFeatures do -%>
<%- if @pref.condition -%>
#if <%= @pref.condition %>
Modified: trunk/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb (270850 => 270851)
--- trunk/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb 2020-12-15 18:16:25 UTC (rev 270850)
+++ trunk/Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb 2020-12-15 18:16:50 UTC (rev 270851)
@@ -113,6 +113,7 @@
void WebPreferences::resetAllInternalDebugFeatures()
{
+ UpdateBatch batch(*this);
<%- for @pref in @exposedInternalFeatures do -%>
<%- if @pref.condition -%>
#if <%= @pref.condition %>
Modified: trunk/Source/WebKit/UIProcess/WebPreferences.cpp (270850 => 270851)
--- trunk/Source/WebKit/UIProcess/WebPreferences.cpp 2020-12-15 18:16:25 UTC (rev 270850)
+++ trunk/Source/WebKit/UIProcess/WebPreferences.cpp 2020-12-15 18:16:50 UTC (rev 270851)
@@ -98,10 +98,31 @@
void WebPreferences::update()
{
+ if (m_updateBatchCount) {
+ m_needUpdateAfterBatch = true;
+ return;
+ }
+
for (auto& webPageProxy : m_pages)
webPageProxy->preferencesDidChange();
}
+void WebPreferences::startBatchingUpdates()
+{
+ if (!m_updateBatchCount)
+ m_needUpdateAfterBatch = false;
+
+ ++m_updateBatchCount;
+}
+
+void WebPreferences::endBatchingUpdates()
+{
+ ASSERT(m_updateBatchCount > 0);
+ --m_updateBatchCount;
+ if (!m_updateBatchCount && m_needUpdateAfterBatch)
+ update();
+}
+
void WebPreferences::setBoolValueForKey(const String& key, bool value)
{
if (!m_store.setBoolValueForKey(key, value))
Modified: trunk/Source/WebKit/UIProcess/WebPreferences.h (270850 => 270851)
--- trunk/Source/WebKit/UIProcess/WebPreferences.h 2020-12-15 18:16:25 UTC (rev 270850)
+++ trunk/Source/WebKit/UIProcess/WebPreferences.h 2020-12-15 18:16:50 UTC (rev 270851)
@@ -89,6 +89,26 @@
void update();
+ class UpdateBatch {
+ public:
+ explicit UpdateBatch(WebPreferences& preferences)
+ : m_preferences(preferences)
+ {
+ m_preferences.startBatchingUpdates();
+ }
+
+ ~UpdateBatch()
+ {
+ m_preferences.endBatchingUpdates();
+ }
+
+ private:
+ WebPreferences& m_preferences;
+ };
+
+ void startBatchingUpdates();
+ void endBatchingUpdates();
+
void updateStringValueForKey(const String& key, const String& value);
void updateBoolValueForKey(const String& key, bool value);
void updateBoolValueForInternalDebugFeatureKey(const String& key, bool value);
@@ -119,6 +139,8 @@
WebPreferencesStore m_store;
HashSet<WebPageProxy*> m_pages;
+ unsigned m_updateBatchCount { 0 };
+ bool m_needUpdateAfterBatch { false };
};
} // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes