Diff
Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (211210 => 211211)
--- branches/safari-603-branch/Source/WebCore/ChangeLog 2017-01-26 15:51:34 UTC (rev 211210)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog 2017-01-26 15:52:52 UTC (rev 211211)
@@ -1,5 +1,31 @@
2017-01-25 Matthew Hanson <matthew_han...@apple.com>
+ Merge r211151. rdar://problem/30171195
+
+ 2017-01-25 Chris Dumez <cdu...@apple.com>
+
+ 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 Matthew Hanson <matthew_han...@apple.com>
+
Merge 210777. rdar://problem/30186526
2017-01-15 Andreas Kling <akl...@apple.com>
Modified: branches/safari-603-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (211210 => 211211)
--- branches/safari-603-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2017-01-26 15:51:34 UTC (rev 211210)
+++ branches/safari-603-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2017-01-26 15:52:52 UTC (rev 211211)
@@ -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 {
@@ -470,8 +473,10 @@
, m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
, m_isPendingPolicyResolution(true)
, m_hasRequestedPolicyResolution(false)
+ , m_checkForContextLossHandlingTimer(*this, &WebGLRenderingContextBase::checkForContextLossHandling)
{
registerWithWebGLStateTracker();
+ m_checkForContextLossHandlingTimer.startOneShot(checkContextLossHandlingDelay);
}
WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement& passedCanvas, RefPtr<GraphicsContext3D>&& context, WebGLContextAttributes attributes)
@@ -489,6 +494,7 @@
, m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
, m_isPendingPolicyResolution(false)
, m_hasRequestedPolicyResolution(false)
+ , m_checkForContextLossHandlingTimer(*this, &WebGLRenderingContextBase::checkForContextLossHandling)
{
ASSERT(m_context);
m_contextGroup = WebGLContextGroup::create();
@@ -502,8 +508,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: branches/safari-603-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (211210 => 211211)
--- branches/safari-603-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2017-01-26 15:51:34 UTC (rev 211210)
+++ branches/safari-603-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2017-01-26 15:52:52 UTC (rev 211211)
@@ -803,8 +803,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: branches/safari-603-branch/Source/WebCore/page/DiagnosticLoggingKeys.cpp (211210 => 211211)
--- branches/safari-603-branch/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2017-01-26 15:51:34 UTC (rev 211210)
+++ branches/safari-603-branch/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2017-01-26 15:52:52 UTC (rev 211211)
@@ -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: branches/safari-603-branch/Source/WebCore/page/DiagnosticLoggingKeys.h (211210 => 211211)
--- branches/safari-603-branch/Source/WebCore/page/DiagnosticLoggingKeys.h 2017-01-26 15:51:34 UTC (rev 211210)
+++ branches/safari-603-branch/Source/WebCore/page/DiagnosticLoggingKeys.h 2017-01-26 15:52:52 UTC (rev 211211)
@@ -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);