Title: [211151] trunk/Source/WebCore
Revision
211151
Author
[email protected]
Date
2017-01-25 09:51:13 -0800 (Wed, 25 Jan 2017)

Log Message

Measure how common it is for content to deal with WebGL context loss
https://bugs.webkit.org/show_bug.cgi?id=166866
<rdar://problem/30171195>

Reviewed by Alex Christensen.

Add diagnostic logging to measure how common it is for sites to handle
WebGL context loss via the webglcontextlost & webglcontextrestored
events.

* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
(WebCore::WebGLRenderingContextBase::checkForContextLossHandling):
* html/canvas/WebGLRenderingContextBase.h:
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::noKey):
(WebCore::DiagnosticLoggingKeys::yesKey):
(WebCore::DiagnosticLoggingKeys::handlesContextLossKey):
* page/DiagnosticLoggingKeys.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211150 => 211151)


--- trunk/Source/WebCore/ChangeLog	2017-01-25 17:48:54 UTC (rev 211150)
+++ trunk/Source/WebCore/ChangeLog	2017-01-25 17:51:13 UTC (rev 211151)
@@ -1,3 +1,25 @@
+2017-01-25  Chris Dumez  <[email protected]>
+
+        Measure how common it is for content to deal with WebGL context loss
+        https://bugs.webkit.org/show_bug.cgi?id=166866
+        <rdar://problem/30171195>
+
+        Reviewed by Alex Christensen.
+
+        Add diagnostic logging to measure how common it is for sites to handle
+        WebGL context loss via the webglcontextlost & webglcontextrestored
+        events.
+
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
+        (WebCore::WebGLRenderingContextBase::checkForContextLossHandling):
+        * html/canvas/WebGLRenderingContextBase.h:
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::noKey):
+        (WebCore::DiagnosticLoggingKeys::yesKey):
+        (WebCore::DiagnosticLoggingKeys::handlesContextLossKey):
+        * page/DiagnosticLoggingKeys.h:
+
 2017-01-25  Simon Fraser  <[email protected]>
 
         Revert r210882, removing support for background-repeat-x/y

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (211150 => 211151)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-01-25 17:48:54 UTC (rev 211150)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2017-01-25 17:51:13 UTC (rev 211151)
@@ -31,6 +31,8 @@
 #include "ANGLEInstancedArrays.h"
 #include "CachedImage.h"
 #include "DOMWindow.h"
+#include "DiagnosticLoggingClient.h"
+#include "DiagnosticLoggingKeys.h"
 #include "Document.h"
 #include "EXTBlendMinMax.h"
 #include "EXTFragDepth.h"
@@ -100,6 +102,7 @@
 
 const double secondsBetweenRestoreAttempts = 1.0;
 const int maxGLErrorsAllowedToConsole = 256;
+static const std::chrono::seconds checkContextLossHandlingDelay { 3 };
 
 namespace {
     
@@ -456,8 +459,10 @@
     , m_attributes(attributes)
     , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
     , m_isPendingPolicyResolution(true)
+    , m_checkForContextLossHandlingTimer(*this, &WebGLRenderingContextBase::checkForContextLossHandling)
 {
     registerWithWebGLStateTracker();
+    m_checkForContextLossHandlingTimer.startOneShot(checkContextLossHandlingDelay);
 }
 
 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement& passedCanvas, Ref<GraphicsContext3D>&& context, WebGLContextAttributes attributes)
@@ -469,6 +474,7 @@
     , m_generatedImageCache(4)
     , m_attributes(attributes)
     , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
+    , m_checkForContextLossHandlingTimer(*this, &WebGLRenderingContextBase::checkForContextLossHandling)
 {
     m_contextGroup = WebGLContextGroup::create();
     m_contextGroup->addContext(*this);
@@ -480,8 +486,24 @@
     setupFlags();
     initializeNewContext();
     registerWithWebGLStateTracker();
+    m_checkForContextLossHandlingTimer.startOneShot(checkContextLossHandlingDelay);
 }
 
+// We check for context loss handling after a few seconds to give the JS a chance to register the event listeners
+// and to discard temporary GL contexts (e.g. feature detection).
+void WebGLRenderingContextBase::checkForContextLossHandling()
+{
+    if (!canvas().renderer())
+        return;
+
+    auto* page = canvas().document().page();
+    if (!page)
+        return;
+
+    bool handlesContextLoss = canvas().hasEventListeners(eventNames().webglcontextlostEvent) && canvas().hasEventListeners(eventNames().webglcontextrestoredEvent);
+    page->diagnosticLoggingClient().logDiagnosticMessageWithValue(DiagnosticLoggingKeys::webGLKey(), DiagnosticLoggingKeys::handlesContextLossKey(), handlesContextLoss ? DiagnosticLoggingKeys::yesKey() : DiagnosticLoggingKeys::noKey(), ShouldSample::No);
+}
+
 void WebGLRenderingContextBase::registerWithWebGLStateTracker()
 {
     auto* page = canvas().document().page();

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (211150 => 211151)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2017-01-25 17:48:54 UTC (rev 211150)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h	2017-01-25 17:51:13 UTC (rev 211151)
@@ -827,8 +827,10 @@
 private:
     bool validateArrayBufferType(const char* functionName, GC3Denum type, std::optional<JSC::TypedArrayType>);
     void registerWithWebGLStateTracker();
+    void checkForContextLossHandling();
 
     WebGLStateTracker::Token m_trackerToken;
+    Timer m_checkForContextLossHandlingTimer;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (211150 => 211151)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2017-01-25 17:48:54 UTC (rev 211150)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2017-01-25 17:51:13 UTC (rev 211151)
@@ -153,6 +153,11 @@
     return ASCIILiteral("neverSeenBefore");
 }
 
+String DiagnosticLoggingKeys::noKey()
+{
+    return ASCIILiteral("no");
+}
+
 String DiagnosticLoggingKeys::noCacheKey()
 {
     return ASCIILiteral("noCache");
@@ -633,6 +638,11 @@
     return ASCIILiteral("webView");
 }
 
+String DiagnosticLoggingKeys::yesKey()
+{
+    return ASCIILiteral("yes");
+}
+
 String DiagnosticLoggingKeys::zoomedKey()
 {
     return ASCIILiteral("zoomed");
@@ -648,6 +658,11 @@
     return ASCIILiteral("font");
 }
 
+String DiagnosticLoggingKeys::handlesContextLossKey()
+{
+    return ASCIILiteral("handlesContextLoss");
+}
+
 String DiagnosticLoggingKeys::prunedDueToMemoryPressureKey()
 {
     return ASCIILiteral("pruned.memoryPressure");

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (211150 => 211151)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2017-01-25 17:48:54 UTC (rev 211150)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2017-01-25 17:51:13 UTC (rev 211151)
@@ -56,6 +56,7 @@
     WEBCORE_EXPORT static String entryWronglyNotWarmedUpKey();
     static String expiredKey();
     static String fontKey();
+    static String handlesContextLossKey();
     static String hasPluginsKey();
     static String httpsNoStoreKey();
     static String imageKey();
@@ -84,6 +85,7 @@
     static String networkKey();
     WEBCORE_EXPORT static String networkProcessCrashedKey();
     WEBCORE_EXPORT static String neverSeenBeforeKey();
+    static String noKey();
     static String noCacheKey();
     static String noCurrentHistoryItemKey();
     static String noDocumentLoaderKey();
@@ -158,6 +160,7 @@
     WEBCORE_EXPORT static String wastedSpeculativeWarmupWithoutRevalidationKey();
     WEBCORE_EXPORT static String webGLKey();
     WEBCORE_EXPORT static String webViewKey();
+    static String yesKey();
     WEBCORE_EXPORT static String zoomedKey();
 
     WEBCORE_EXPORT static String memoryUsageToDiagnosticLoggingKey(uint64_t memoryUsage);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to