Title: [210753] trunk/Source
Revision
210753
Author
cdu...@apple.com
Date
2017-01-13 17:05:32 -0800 (Fri, 13 Jan 2017)

Log Message

[WK2] Add diagnostic logging to measure WebGL usage
https://bugs.webkit.org/show_bug.cgi?id=166730
<rdar://problem/29883469>

Reviewed by Alex Christensen.

Add diagnostic logging to measure high performance WebGL usage. We report
at regular intervals in which WebGL state Safari is:
- Inactive
- ActiveInForegroundTab
- ActiveInBackgroundTabOnly

This should give us an estimate of:
- What % of the time is Safari using high performance graphics
- What % of this time is only due to background tabs

Source/WebCore:

No new tests, no Web-facing behavior change.

* WebCore.xcodeproj/project.pbxproj:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::create):
(WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
(WebCore::WebGLRenderingContextBase::registerWithWebGLStateTracker):
* html/canvas/WebGLRenderingContextBase.h:
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::inactiveKey):
(WebCore::DiagnosticLoggingKeys::activeInForegroundTabKey):
(WebCore::DiagnosticLoggingKeys::activeInBackgroundTabOnlyKey):
(WebCore::DiagnosticLoggingKeys::stateKey):
(WebCore::WebCore::DiagnosticLoggingKeys::webGLKey):
* page/DiagnosticLoggingKeys.h:
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore::Page::webGLStateTracker):
* page/PageConfiguration.cpp:
* page/PageConfiguration.h:
* platform/WebGLStateTracker.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h.
(WebCore::WebGLStateTracker::WebGLStateTracker):
(WebCore::m_stateChangeHandler):
(WebCore::WebGLStateTracker::updateWebGLState):
* platform/WebGLStateTracker.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h.
* platform/graphics/GraphicsContext3DAttributes.h:

Source/WebKit2:

* UIProcess/HighPerformanceGraphicsUsageSampler.cpp: Added.
(WebKit::HighPerformanceGraphicsUsageSampler::HighPerformanceGraphicsUsageSampler):
(WebKit::HighPerformanceGraphicsUsageSampler::timerFired):
* UIProcess/HighPerformanceGraphicsUsageSampler.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::setIsUsingHighPerformanceWebGL):
(WebKit::WebPageProxy::isUsingHighPerformanceWebGL):
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebProcessPool.cpp:
(WebKit::m_highPerformanceGraphicsUsageSampler):
* UIProcess/WebProcessPool.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_userInterfaceLayoutDirection):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (210752 => 210753)


--- trunk/Source/WebCore/CMakeLists.txt	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-01-14 01:05:32 UTC (rev 210753)
@@ -2107,6 +2107,7 @@
     platform/UUID.cpp
     platform/UserActivity.cpp
     platform/WebCoreCrossThreadCopier.cpp
+    platform/WebGLStateTracker.cpp
     platform/Widget.cpp
 
     platform/animation/Animation.cpp

Modified: trunk/Source/WebCore/ChangeLog (210752 => 210753)


--- trunk/Source/WebCore/ChangeLog	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/ChangeLog	2017-01-14 01:05:32 UTC (rev 210753)
@@ -1,3 +1,49 @@
+2017-01-13  Chris Dumez  <cdu...@apple.com>
+
+        [WK2] Add diagnostic logging to measure WebGL usage
+        https://bugs.webkit.org/show_bug.cgi?id=166730
+        <rdar://problem/29883469>
+
+        Reviewed by Alex Christensen.
+
+        Add diagnostic logging to measure high performance WebGL usage. We report
+        at regular intervals in which WebGL state Safari is:
+        - Inactive
+        - ActiveInForegroundTab
+        - ActiveInBackgroundTabOnly
+
+        This should give us an estimate of:
+        - What % of the time is Safari using high performance graphics
+        - What % of this time is only due to background tabs
+
+        No new tests, no Web-facing behavior change.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::create):
+        (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
+        (WebCore::WebGLRenderingContextBase::registerWithWebGLStateTracker):
+        * html/canvas/WebGLRenderingContextBase.h:
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::inactiveKey):
+        (WebCore::DiagnosticLoggingKeys::activeInForegroundTabKey):
+        (WebCore::DiagnosticLoggingKeys::activeInBackgroundTabOnlyKey):
+        (WebCore::DiagnosticLoggingKeys::stateKey):
+        (WebCore::WebCore::DiagnosticLoggingKeys::webGLKey):
+        * page/DiagnosticLoggingKeys.h:
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        * page/Page.h:
+        (WebCore::Page::webGLStateTracker):
+        * page/PageConfiguration.cpp:
+        * page/PageConfiguration.h:
+        * platform/WebGLStateTracker.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h.
+        (WebCore::WebGLStateTracker::WebGLStateTracker):
+        (WebCore::m_stateChangeHandler):
+        (WebCore::WebGLStateTracker::updateWebGLState):
+        * platform/WebGLStateTracker.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h.
+        * platform/graphics/GraphicsContext3DAttributes.h:
+
 2017-01-13  Brent Fulgham  <bfulg...@apple.com>
 
         Avoid nullptr frame dereference when scrollTo is called on a disconnected DOMWindow

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (210752 => 210753)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-01-14 01:05:32 UTC (rev 210753)
@@ -3024,6 +3024,8 @@
 		838EF5381DC149E2008F0C39 /* IDBTransactionMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 838EF5361DC149DA008F0C39 /* IDBTransactionMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		838EF53B1DC14A7C008F0C39 /* JSIDBTransactionMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 838EF5391DC14A75008F0C39 /* JSIDBTransactionMode.cpp */; };
 		838EF53C1DC14A7C008F0C39 /* JSIDBTransactionMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 838EF53A1DC14A75008F0C39 /* JSIDBTransactionMode.h */; };
+		839A2F2D1E204A710039057E /* WebGLStateTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839A2F2B1E204A6D0039057E /* WebGLStateTracker.cpp */; };
+		839A2F2E1E204A710039057E /* WebGLStateTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 839A2F2C1E204A6D0039057E /* WebGLStateTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		839AAFEC1A0C0C8D00605F99 /* HTMLWBRElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */; };
 		839AAFED1A0C0C8D00605F99 /* HTMLWBRElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */; };
 		83A4A9F91CE7FD8100709B00 /* JSXMLDocumentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */; };
@@ -10540,6 +10542,8 @@
 		838EF5371DC149DA008F0C39 /* IDBTransactionMode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDBTransactionMode.idl; sourceTree = "<group>"; };
 		838EF5391DC14A75008F0C39 /* JSIDBTransactionMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBTransactionMode.cpp; sourceTree = "<group>"; };
 		838EF53A1DC14A75008F0C39 /* JSIDBTransactionMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIDBTransactionMode.h; sourceTree = "<group>"; };
+		839A2F2B1E204A6D0039057E /* WebGLStateTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLStateTracker.cpp; sourceTree = "<group>"; };
+		839A2F2C1E204A6D0039057E /* WebGLStateTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLStateTracker.h; sourceTree = "<group>"; };
 		839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLWBRElement.cpp; sourceTree = "<group>"; };
 		839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLWBRElement.h; sourceTree = "<group>"; };
 		83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocumentCustom.cpp; sourceTree = "<group>"; };
@@ -22669,6 +22673,8 @@
 				9A1142031832D134000BB8AD /* ValueToString.h */,
 				515F79511CFCA3C700CCED93 /* WebCoreCrossThreadCopier.cpp */,
 				515F79521CFCA3C700CCED93 /* WebCoreCrossThreadCopier.h */,
+				839A2F2B1E204A6D0039057E /* WebGLStateTracker.cpp */,
+				839A2F2C1E204A6D0039057E /* WebGLStateTracker.h */,
 				9380F47109A11AB4001FDB34 /* Widget.cpp */,
 				9380F47209A11AB4001FDB34 /* Widget.h */,
 				E1E1BEFF115FF6FB006F52CA /* WindowsKeyboardCodes.h */,
@@ -25489,6 +25495,7 @@
 				0F4710AF1DB56AFC002DCEC3 /* DOMRect.h in Headers */,
 				0F4710B11DB56AFC002DCEC3 /* DOMRectInit.h in Headers */,
 				0F4710B31DB56AFC002DCEC3 /* DOMRectReadOnly.h in Headers */,
+				839A2F2E1E204A710039057E /* WebGLStateTracker.h in Headers */,
 				BC5A86850C33676000EEA649 /* DOMSelection.h in Headers */,
 				C544274B11A57E7A0063A749 /* DOMStringList.h in Headers */,
 				BC64640A11D7F304006455B0 /* DOMStringMap.h in Headers */,
@@ -29458,6 +29465,7 @@
 				65BF022E0974816300C43196 /* Frame.cpp in Sources */,
 				974A862214B7ADBB003FDC76 /* FrameDestructionObserver.cpp in Sources */,
 				FED13D3D0CEA936A00D89466 /* FrameIOS.mm in Sources */,
+				839A2F2D1E204A710039057E /* WebGLStateTracker.cpp in Sources */,
 				932E16090AF578340025F408 /* FrameLoader.cpp in Sources */,
 				D000EBA211BDAFD400C47726 /* FrameLoaderStateMachine.cpp in Sources */,
 				86BA766E166427A8005BE5D1 /* FrameLoadRequest.cpp in Sources */,

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (210752 => 210753)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -399,7 +399,8 @@
     if (frame->settings().forceSoftwareWebGLRendering())
         attributes.forceSoftwareRenderer = true;
 
-    if (!attributes.preferLowPowerToHighPerformance && frame->settings().preferLowPowerWebGLRendering())
+    attributes.initialPreferLowPowerToHighPerformance = attributes.preferLowPowerToHighPerformance;
+    if (frame->settings().preferLowPowerWebGLRendering())
         attributes.preferLowPowerToHighPerformance = true;
 
     if (page)
@@ -461,6 +462,7 @@
     , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
     , m_isPendingPolicyResolution(true)
 {
+    registerWithWebGLStateTracker();
 }
 
 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement& passedCanvas, Ref<GraphicsContext3D>&& context, WebGLContextAttributes attributes)
@@ -482,8 +484,22 @@
 
     setupFlags();
     initializeNewContext();
+    registerWithWebGLStateTracker();
 }
 
+void WebGLRenderingContextBase::registerWithWebGLStateTracker()
+{
+    auto* page = canvas().document().page();
+    if (!page)
+        return;
+
+    auto* tracker = page->webGLStateTracker();
+    if (!tracker)
+        return;
+
+    m_trackerToken = tracker->token(m_attributes.initialPreferLowPowerToHighPerformance);
+}
+
 void WebGLRenderingContextBase::initializeNewContext()
 {
     ASSERT(!m_contextLost);

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (210752 => 210753)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -36,6 +36,7 @@
 #include "WebGLFramebuffer.h"
 #include "WebGLProgram.h"
 #include "WebGLRenderbuffer.h"
+#include "WebGLStateTracker.h"
 #include "WebGLTexture.h"
 #include "WebGLVertexArrayObjectOES.h"
 #include <memory>
@@ -825,6 +826,9 @@
 
 private:
     bool validateArrayBufferType(const char* functionName, GC3Denum type, std::optional<JSC::TypedArrayType>);
+    void registerWithWebGLStateTracker();
+
+    WebGLStateTracker::Token m_trackerToken;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (210752 => 210753)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -243,6 +243,11 @@
     return ASCIILiteral("inMemoryCache");
 }
 
+String DiagnosticLoggingKeys::inactiveKey()
+{
+    return ASCIILiteral("inactive");
+}
+
 String DiagnosticLoggingKeys::internalErrorKey()
 {
     return ASCIILiteral("internalError");
@@ -323,6 +328,16 @@
     return ASCIILiteral("delta");
 }
 
+String DiagnosticLoggingKeys::activeInForegroundTabKey()
+{
+    return ASCIILiteral("activeInForegroundTab");
+}
+
+String DiagnosticLoggingKeys::activeInBackgroundTabOnlyKey()
+{
+    return ASCIILiteral("activeInBackgroundTabOnly");
+}
+
 String DiagnosticLoggingKeys::applicationCacheKey()
 {
     return ASCIILiteral("applicationCache");
@@ -448,6 +463,11 @@
     return ASCIILiteral("source");
 }
 
+String DiagnosticLoggingKeys::stateKey()
+{
+    return ASCIILiteral("state");
+}
+
 String DiagnosticLoggingKeys::streamingMedia()
 {
     return ASCIILiteral("streamingMedia");
@@ -628,5 +648,10 @@
     return ASCIILiteral("notInCache");
 }
 
+String WebCore::DiagnosticLoggingKeys::webGLKey()
+{
+    return ASCIILiteral("webGL");
+}
+
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (210752 => 210753)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -31,6 +31,8 @@
 
 class DiagnosticLoggingKeys {
 public:
+    WEBCORE_EXPORT static String activeInForegroundTabKey();
+    WEBCORE_EXPORT static String activeInBackgroundTabOnlyKey();
     static String applicationCacheKey();
     static String audioKey();
     WEBCORE_EXPORT static String backNavigationKey();
@@ -57,6 +59,7 @@
     static String httpsNoStoreKey();
     static String imageKey();
     static String inMemoryCacheKey();
+    WEBCORE_EXPORT static String inactiveKey();
     WEBCORE_EXPORT static String internalErrorKey();
     WEBCORE_EXPORT static String invalidSessionIDKey();
     WEBCORE_EXPORT static String isAttachmentKey();
@@ -120,6 +123,7 @@
     static String sameLoadKey();
     static String scriptKey();
     static String sourceKey();
+    WEBCORE_EXPORT static String stateKey();
     WEBCORE_EXPORT static String streamingMedia();
     static String styleSheetKey();
     WEBCORE_EXPORT static String successfulSpeculativeWarmupWithRevalidationKey();
@@ -147,6 +151,7 @@
     static String videoKey();
     WEBCORE_EXPORT static String wastedSpeculativeWarmupWithRevalidationKey();
     WEBCORE_EXPORT static String wastedSpeculativeWarmupWithoutRevalidationKey();
+    WEBCORE_EXPORT static String webGLKey();
     WEBCORE_EXPORT static String webViewKey();
     WEBCORE_EXPORT static String zoomedKey();
 

Modified: trunk/Source/WebCore/page/Page.cpp (210752 => 210753)


--- trunk/Source/WebCore/page/Page.cpp	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/page/Page.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -98,6 +98,7 @@
 #include "VisitedLinkState.h"
 #include "VisitedLinkStore.h"
 #include "VoidCallback.h"
+#include "WebGLStateTracker.h"
 #include "Widget.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/RefCountedLeakCounter.h>
@@ -197,6 +198,7 @@
     , m_plugInClient(pageConfiguration.plugInClient)
     , m_validationMessageClient(WTFMove(pageConfiguration.validationMessageClient))
     , m_diagnosticLoggingClient(WTFMove(pageConfiguration.diagnosticLoggingClient))
+    , m_webGLStateTracker(WTFMove(pageConfiguration.webGLStateTracker))
     , m_subframeCount(0)
     , m_openedByDOM(false)
     , m_tabKeyCyclesThroughElements(true)

Modified: trunk/Source/WebCore/page/Page.h (210752 => 210753)


--- trunk/Source/WebCore/page/Page.h	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/page/Page.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -130,6 +130,7 @@
 class ValidationMessageClient;
 class ActivityStateChangeObserver;
 class VisitedLinkStore;
+class WebGLStateTracker;
 
 typedef uint64_t LinkHash;
 
@@ -552,6 +553,7 @@
     std::optional<EventThrottlingBehavior> eventThrottlingBehaviorOverride() const { return m_eventThrottlingBehaviorOverride; }
     void setEventThrottlingBehaviorOverride(std::optional<EventThrottlingBehavior> throttling) { m_eventThrottlingBehaviorOverride = throttling; }
 
+    WebGLStateTracker* webGLStateTracker() const { return m_webGLStateTracker.get(); }
 private:
     WEBCORE_EXPORT void initGroup();
 
@@ -617,6 +619,7 @@
     PlugInClient* m_plugInClient;
     std::unique_ptr<ValidationMessageClient> m_validationMessageClient;
     std::unique_ptr<DiagnosticLoggingClient> m_diagnosticLoggingClient;
+    std::unique_ptr<WebGLStateTracker> m_webGLStateTracker;
 
     int m_subframeCount;
     String m_groupName;

Modified: trunk/Source/WebCore/page/PageConfiguration.cpp (210752 => 210753)


--- trunk/Source/WebCore/page/PageConfiguration.cpp	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/page/PageConfiguration.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -37,6 +37,7 @@
 #include "UserContentController.h"
 #include "ValidationMessageClient.h"
 #include "VisitedLinkStore.h"
+#include "WebGLStateTracker.h"
 
 namespace WebCore {
 

Modified: trunk/Source/WebCore/page/PageConfiguration.h (210752 => 210753)


--- trunk/Source/WebCore/page/PageConfiguration.h	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/page/PageConfiguration.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -50,6 +50,7 @@
 class UserContentProvider;
 class ValidationMessageClient;
 class VisitedLinkStore;
+class WebGLStateTracker;
 
 #if ENABLE(CONTEXT_MENUS)
 class ContextMenuClient;
@@ -80,6 +81,7 @@
     std::unique_ptr<ValidationMessageClient> validationMessageClient;
     FrameLoaderClient* loaderClientForMainFrame { nullptr };
     std::unique_ptr<DiagnosticLoggingClient> diagnosticLoggingClient;
+    std::unique_ptr<WebGLStateTracker> webGLStateTracker;
 
     RefPtr<ApplicationCacheStorage> applicationCacheStorage;
     RefPtr<DatabaseProvider> databaseProvider;

Copied: trunk/Source/WebCore/platform/WebGLStateTracker.cpp (from rev 210752, trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h) (0 => 210753)


--- trunk/Source/WebCore/platform/WebGLStateTracker.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/WebGLStateTracker.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGLStateTracker.h"
+
+namespace WebCore {
+
+WebGLStateTracker::WebGLStateTracker(StateChangeHandler&& handler)
+    : m_webGLContextCounter([this](RefCounterEvent) { updateWebGLState(); })
+    , m_stateChangeHandler(WTFMove(handler))
+{
+}
+
+auto WebGLStateTracker::token(bool preferLowPower) -> Token
+{
+    // We only track high performance WebGL contexts at the moment.
+    if (preferLowPower)
+        return { };
+    return m_webGLContextCounter.count();
+}
+
+void WebGLStateTracker::updateWebGLState()
+{
+    if (!m_webGLContextCounter.value())
+        m_stateChangeHandler(false);
+    else if (m_webGLContextCounter.value() == 1)
+        m_stateChangeHandler(true);
+}
+
+} // namespace WebCore

Copied: trunk/Source/WebCore/platform/WebGLStateTracker.h (from rev 210752, trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h) (0 => 210753)


--- trunk/Source/WebCore/platform/WebGLStateTracker.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/WebGLStateTracker.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Function.h>
+#include <wtf/RefCounter.h>
+
+namespace WebCore {
+
+class WebGLStateTracker {
+public:
+    using StateChangeHandler = Function<void(bool isUsingWebGL)>;
+    WEBCORE_EXPORT explicit WebGLStateTracker(StateChangeHandler&&);
+
+    enum WebGLContextCounterType { };
+    using WebGLContextCounter = RefCounter<WebGLContextCounterType>;
+    using Token = WebGLContextCounter::Token;
+
+    Token token(bool preferLowPower);
+
+private:
+    void updateWebGLState();
+
+    WebGLContextCounter m_webGLContextCounter;
+    StateChangeHandler m_stateChangeHandler;
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h (210752 => 210753)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -44,6 +44,7 @@
     bool useGLES3 { false };
     bool noExtensions { false };
     float devicePixelRatio { 1 };
+    bool initialPreferLowPowerToHighPerformance { false };
 };
 
 }

Modified: trunk/Source/WebKit2/ChangeLog (210752 => 210753)


--- trunk/Source/WebKit2/ChangeLog	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-14 01:05:32 UTC (rev 210753)
@@ -1,3 +1,36 @@
+2017-01-13  Chris Dumez  <cdu...@apple.com>
+
+        [WK2] Add diagnostic logging to measure WebGL usage
+        https://bugs.webkit.org/show_bug.cgi?id=166730
+        <rdar://problem/29883469>
+
+        Reviewed by Alex Christensen.
+
+        Add diagnostic logging to measure high performance WebGL usage. We report
+        at regular intervals in which WebGL state Safari is:
+        - Inactive
+        - ActiveInForegroundTab
+        - ActiveInBackgroundTabOnly
+
+        This should give us an estimate of:
+        - What % of the time is Safari using high performance graphics
+        - What % of this time is only due to background tabs
+
+        * UIProcess/HighPerformanceGraphicsUsageSampler.cpp: Added.
+        (WebKit::HighPerformanceGraphicsUsageSampler::HighPerformanceGraphicsUsageSampler):
+        (WebKit::HighPerformanceGraphicsUsageSampler::timerFired):
+        * UIProcess/HighPerformanceGraphicsUsageSampler.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h.
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::setIsUsingHighPerformanceWebGL):
+        (WebKit::WebPageProxy::isUsingHighPerformanceWebGL):
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::m_highPerformanceGraphicsUsageSampler):
+        * UIProcess/WebProcessPool.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_userInterfaceLayoutDirection):
+
 2017-01-13  Matt Rajca  <mra...@apple.com>
 
         Defer use of autoplay heuristics to clients

Added: trunk/Source/WebKit2/UIProcess/HighPerformanceGraphicsUsageSampler.cpp (0 => 210753)


--- trunk/Source/WebKit2/UIProcess/HighPerformanceGraphicsUsageSampler.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/HighPerformanceGraphicsUsageSampler.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HighPerformanceGraphicsUsageSampler.h"
+
+#include "WebProcessPool.h"
+#include <WebCore/DiagnosticLoggingKeys.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+static const std::chrono::minutes samplingInterval { 10 };
+
+HighPerformanceGraphicsUsageSampler::HighPerformanceGraphicsUsageSampler(WebProcessPool& webProcessPool)
+    : m_webProcessPool(webProcessPool)
+    , m_timer(RunLoop::main(), this, &HighPerformanceGraphicsUsageSampler::timerFired)
+{
+    m_timer.startRepeating(samplingInterval);
+}
+
+void HighPerformanceGraphicsUsageSampler::timerFired()
+{
+    bool isUsingHighPerformanceWebGL = false;
+    bool isUsingHighPerformanceWebGLInVisibleView = false;
+
+    WebPageProxy* firstPage = nullptr;
+    for (auto& webProcess : m_webProcessPool.processes()) {
+        for (auto& page : webProcess->pages()) {
+            if (!firstPage)
+                firstPage = page;
+
+            if (page->isUsingHighPerformanceWebGL()) {
+                isUsingHighPerformanceWebGL = true;
+                if (page->isViewVisible()) {
+                    isUsingHighPerformanceWebGLInVisibleView = true;
+                    break;
+                }
+            }
+        }
+    }
+
+    if (!firstPage)
+        return;
+
+    String state = DiagnosticLoggingKeys::inactiveKey();
+    if (isUsingHighPerformanceWebGLInVisibleView)
+        state = DiagnosticLoggingKeys::activeInForegroundTabKey();
+    else if (isUsingHighPerformanceWebGL)
+        state = DiagnosticLoggingKeys::activeInBackgroundTabOnlyKey();
+
+    firstPage->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::webGLKey(), DiagnosticLoggingKeys::stateKey(), state, false);
+}
+
+} // namespace WebKit

Copied: trunk/Source/WebKit2/UIProcess/HighPerformanceGraphicsUsageSampler.h (from rev 210752, trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h) (0 => 210753)


--- trunk/Source/WebKit2/UIProcess/HighPerformanceGraphicsUsageSampler.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/HighPerformanceGraphicsUsageSampler.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/RunLoop.h>
+
+namespace WebKit {
+
+class WebProcessPool;
+
+class HighPerformanceGraphicsUsageSampler {
+public:
+    explicit HighPerformanceGraphicsUsageSampler(WebProcessPool&);
+
+private:
+    void timerFired();
+
+    WebProcessPool& m_webProcessPool;
+    RunLoop::Timer<HighPerformanceGraphicsUsageSampler> m_timer;
+};
+
+} // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (210752 => 210753)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -378,6 +378,9 @@
     bool tryClose();
     bool isClosed() const { return m_isClosed; }
 
+    void setIsUsingHighPerformanceWebGL(bool value) { m_isUsingHighPerformanceWebGL = value; }
+    bool isUsingHighPerformanceWebGL() const { return m_isUsingHighPerformanceWebGL; }
+
     void closePage(bool stopResponsivenessTimer);
 
     void addPlatformLoadParameters(LoadParameters&);
@@ -1973,6 +1976,8 @@
 #if ENABLE(DOWNLOAD_ATTRIBUTE)
     bool m_syncNavigationActionHasDownloadAttribute { false };
 #endif
+
+    bool m_isUsingHighPerformanceWebGL { false };
         
     WeakPtrFactory<WebPageProxy> m_weakPtrFactory;
 };

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (210752 => 210753)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-14 01:05:32 UTC (rev 210753)
@@ -485,4 +485,6 @@
     DidHandleAcceptedCandidate()
     HandleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, String title, double duration, double elapsedTime)
 #endif
+
+    SetIsUsingHighPerformanceWebGL(bool isUsingHighPerformanceWebGL)
 }

Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (210752 => 210753)


--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -37,6 +37,7 @@
 #include "DownloadProxy.h"
 #include "DownloadProxyMessages.h"
 #include "GamepadData.h"
+#include "HighPerformanceGraphicsUsageSampler.h"
 #include "LogInitialization.h"
 #include "NetworkProcessCreationParameters.h"
 #include "NetworkProcessMessages.h"
@@ -165,6 +166,9 @@
     , m_memorySamplerEnabled(false)
     , m_memorySamplerInterval(1400.0)
     , m_websiteDataStore(m_configuration->shouldHaveLegacyDataStore() ? API::WebsiteDataStore::create(legacyWebsiteDataStoreConfiguration(m_configuration)).ptr() : nullptr)
+#if PLATFORM(MAC)
+    , m_highPerformanceGraphicsUsageSampler(std::make_unique<HighPerformanceGraphicsUsageSampler>(*this))
+#endif
     , m_shouldUseTestingNetworkSession(false)
     , m_processTerminationEnabled(true)
     , m_canHandleHTTPSServerTrustEvaluation(true)

Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (210752 => 210753)


--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h	2017-01-14 01:05:32 UTC (rev 210753)
@@ -79,6 +79,7 @@
 namespace WebKit {
 
 class DownloadProxy;
+class HighPerformanceGraphicsUsageSampler;
 class UIGamepad;
 class WebAutomationSession;
 class WebContextSupplement;
@@ -523,6 +524,8 @@
     RetainPtr<NSObject> m_automaticSpellingCorrectionNotificationObserver;
     RetainPtr<NSObject> m_automaticQuoteSubstitutionNotificationObserver;
     RetainPtr<NSObject> m_automaticDashSubstitutionNotificationObserver;
+
+    std::unique_ptr<HighPerformanceGraphicsUsageSampler> m_highPerformanceGraphicsUsageSampler;
 #endif
 
     String m_overrideIconDatabasePath;

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (210752 => 210753)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2017-01-14 01:05:32 UTC (rev 210753)
@@ -1253,6 +1253,8 @@
 		839149651BEA838500D2D953 /* NetworkLoadParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 839149631BEA838500D2D953 /* NetworkLoadParameters.h */; };
 		839902021BE9A02B000F3653 /* NetworkLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839901FF1BE9A01B000F3653 /* NetworkLoad.cpp */; };
 		839902031BE9A02B000F3653 /* NetworkLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 839901FE1BE9A01B000F3653 /* NetworkLoad.h */; };
+		839A2F311E2067450039057E /* HighPerformanceGraphicsUsageSampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 839A2F2F1E2067390039057E /* HighPerformanceGraphicsUsageSampler.cpp */; };
+		839A2F321E2067450039057E /* HighPerformanceGraphicsUsageSampler.h in Headers */ = {isa = PBXBuildFile; fileRef = 839A2F301E2067390039057E /* HighPerformanceGraphicsUsageSampler.h */; };
 		83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */; };
 		83BFAC421D96137C00433490 /* BlobDownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BFAC401D96136000433490 /* BlobDownloadClient.h */; };
 		83BFAC431D96137C00433490 /* BlobDownloadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BFAC411D96136000433490 /* BlobDownloadClient.cpp */; };
@@ -3401,6 +3403,8 @@
 		839149631BEA838500D2D953 /* NetworkLoadParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkLoadParameters.h; path = NetworkProcess/NetworkLoadParameters.h; sourceTree = "<group>"; };
 		839901FE1BE9A01B000F3653 /* NetworkLoad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkLoad.h; path = NetworkProcess/NetworkLoad.h; sourceTree = "<group>"; };
 		839901FF1BE9A01B000F3653 /* NetworkLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkLoad.cpp; path = NetworkProcess/NetworkLoad.cpp; sourceTree = "<group>"; };
+		839A2F2F1E2067390039057E /* HighPerformanceGraphicsUsageSampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HighPerformanceGraphicsUsageSampler.cpp; sourceTree = "<group>"; };
+		839A2F301E2067390039057E /* HighPerformanceGraphicsUsageSampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HighPerformanceGraphicsUsageSampler.h; sourceTree = "<group>"; };
 		83BDCCB81AC5FDB6003F6441 /* NetworkCacheStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheStatistics.cpp; sourceTree = "<group>"; };
 		83BFAC401D96136000433490 /* BlobDownloadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobDownloadClient.h; path = NetworkProcess/Downloads/BlobDownloadClient.h; sourceTree = "<group>"; };
 		83BFAC411D96136000433490 /* BlobDownloadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BlobDownloadClient.cpp; path = NetworkProcess/Downloads/BlobDownloadClient.cpp; sourceTree = "<group>"; };
@@ -6257,6 +6261,8 @@
 				BC06F44812DBD1F5002D78DE /* GeolocationPermissionRequestManagerProxy.h */,
 				BC06F43912DBCCFB002D78DE /* GeolocationPermissionRequestProxy.cpp */,
 				BC06F43812DBCCFB002D78DE /* GeolocationPermissionRequestProxy.h */,
+				839A2F2F1E2067390039057E /* HighPerformanceGraphicsUsageSampler.cpp */,
+				839A2F301E2067390039057E /* HighPerformanceGraphicsUsageSampler.h */,
 				31607F3819627002009B87DA /* LegacySessionStateCoding.h */,
 				BC6EDAA5111271C600E7678B /* PageClient.h */,
 				1AC75379183A9FDA0072CB15 /* PageLoadState.cpp */,
@@ -7885,6 +7891,7 @@
 				1A6FBD2811E69BC200DB1371 /* NetscapePlugin.h in Headers */,
 				1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */,
 				1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */,
+				839A2F321E2067450039057E /* HighPerformanceGraphicsUsageSampler.h in Headers */,
 				E1798C7A16E6818800240139 /* NetworkBlobRegistry.h in Headers */,
 				E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */,
 				E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */,
@@ -9380,6 +9387,7 @@
 				1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */,
 				1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */,
 				1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
+				839A2F311E2067450039057E /* HighPerformanceGraphicsUsageSampler.cpp in Sources */,
 				1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
 				1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */,
 				E1798C7916E6818800240139 /* NetworkBlobRegistry.cpp in Sources */,

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (210752 => 210753)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-01-14 01:03:17 UTC (rev 210752)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-01-14 01:05:32 UTC (rev 210753)
@@ -177,6 +177,7 @@
 #include <WebCore/UserStyleSheet.h>
 #include <WebCore/VisiblePosition.h>
 #include <WebCore/VisibleUnits.h>
+#include <WebCore/WebGLStateTracker.h>
 #include <WebCore/htmlediting.h>
 #include <WebCore/markup.h>
 #include <bindings/ScriptValue.h>
@@ -358,6 +359,9 @@
     pageConfiguration.loaderClientForMainFrame = new WebFrameLoaderClient;
     pageConfiguration.progressTrackerClient = new WebProgressTrackerClient(*this);
     pageConfiguration.diagnosticLoggingClient = std::make_unique<WebDiagnosticLoggingClient>(*this);
+    pageConfiguration.webGLStateTracker = std::make_unique<WebGLStateTracker>([this](bool isUsingHighPerformanceWebGL) {
+        send(Messages::WebPageProxy::SetIsUsingHighPerformanceWebGL(isUsingHighPerformanceWebGL));
+    });
 
 #if PLATFORM(COCOA)
     pageConfiguration.validationMessageClient = std::make_unique<WebValidationMessageClient>(*this);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to