Changeset 211151 in webkit


Ignore:
Timestamp:
Jan 25, 2017 9:51:13 AM (7 years ago)
Author:
Chris Dumez
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:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r211149 r211151  
     12017-01-25  Chris Dumez  <cdumez@apple.com>
     2
     3        Measure how common it is for content to deal with WebGL context loss
     4        https://bugs.webkit.org/show_bug.cgi?id=166866
     5        <rdar://problem/30171195>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Add diagnostic logging to measure how common it is for sites to handle
     10        WebGL context loss via the webglcontextlost & webglcontextrestored
     11        events.
     12
     13        * html/canvas/WebGLRenderingContextBase.cpp:
     14        (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
     15        (WebCore::WebGLRenderingContextBase::checkForContextLossHandling):
     16        * html/canvas/WebGLRenderingContextBase.h:
     17        * page/DiagnosticLoggingKeys.cpp:
     18        (WebCore::DiagnosticLoggingKeys::noKey):
     19        (WebCore::DiagnosticLoggingKeys::yesKey):
     20        (WebCore::DiagnosticLoggingKeys::handlesContextLossKey):
     21        * page/DiagnosticLoggingKeys.h:
     22
    1232017-01-25  Simon Fraser  <simon.fraser@apple.com>
    224
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r211085 r211151  
    3232#include "CachedImage.h"
    3333#include "DOMWindow.h"
     34#include "DiagnosticLoggingClient.h"
     35#include "DiagnosticLoggingKeys.h"
    3436#include "Document.h"
    3537#include "EXTBlendMinMax.h"
     
    101103const double secondsBetweenRestoreAttempts = 1.0;
    102104const int maxGLErrorsAllowedToConsole = 256;
     105static const std::chrono::seconds checkContextLossHandlingDelay { 3 };
    103106
    104107namespace {
     
    457460    , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
    458461    , m_isPendingPolicyResolution(true)
     462    , m_checkForContextLossHandlingTimer(*this, &WebGLRenderingContextBase::checkForContextLossHandling)
    459463{
    460464    registerWithWebGLStateTracker();
     465    m_checkForContextLossHandlingTimer.startOneShot(checkContextLossHandlingDelay);
    461466}
    462467
     
    470475    , m_attributes(attributes)
    471476    , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
     477    , m_checkForContextLossHandlingTimer(*this, &WebGLRenderingContextBase::checkForContextLossHandling)
    472478{
    473479    m_contextGroup = WebGLContextGroup::create();
     
    481487    initializeNewContext();
    482488    registerWithWebGLStateTracker();
     489    m_checkForContextLossHandlingTimer.startOneShot(checkContextLossHandlingDelay);
     490}
     491
     492// We check for context loss handling after a few seconds to give the JS a chance to register the event listeners
     493// and to discard temporary GL contexts (e.g. feature detection).
     494void WebGLRenderingContextBase::checkForContextLossHandling()
     495{
     496    if (!canvas().renderer())
     497        return;
     498
     499    auto* page = canvas().document().page();
     500    if (!page)
     501        return;
     502
     503    bool handlesContextLoss = canvas().hasEventListeners(eventNames().webglcontextlostEvent) && canvas().hasEventListeners(eventNames().webglcontextrestoredEvent);
     504    page->diagnosticLoggingClient().logDiagnosticMessageWithValue(DiagnosticLoggingKeys::webGLKey(), DiagnosticLoggingKeys::handlesContextLossKey(), handlesContextLoss ? DiagnosticLoggingKeys::yesKey() : DiagnosticLoggingKeys::noKey(), ShouldSample::No);
    483505}
    484506
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h

    r210753 r211151  
    828828    bool validateArrayBufferType(const char* functionName, GC3Denum type, std::optional<JSC::TypedArrayType>);
    829829    void registerWithWebGLStateTracker();
     830    void checkForContextLossHandling();
    830831
    831832    WebGLStateTracker::Token m_trackerToken;
     833    Timer m_checkForContextLossHandlingTimer;
    832834};
    833835
  • trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp

    r211120 r211151  
    154154}
    155155
     156String DiagnosticLoggingKeys::noKey()
     157{
     158    return ASCIILiteral("no");
     159}
     160
    156161String DiagnosticLoggingKeys::noCacheKey()
    157162{
     
    634639}
    635640
     641String DiagnosticLoggingKeys::yesKey()
     642{
     643    return ASCIILiteral("yes");
     644}
     645
    636646String DiagnosticLoggingKeys::zoomedKey()
    637647{
     
    647657{
    648658    return ASCIILiteral("font");
     659}
     660
     661String DiagnosticLoggingKeys::handlesContextLossKey()
     662{
     663    return ASCIILiteral("handlesContextLoss");
    649664}
    650665
  • trunk/Source/WebCore/page/DiagnosticLoggingKeys.h

    r211120 r211151  
    5757    static String expiredKey();
    5858    static String fontKey();
     59    static String handlesContextLossKey();
    5960    static String hasPluginsKey();
    6061    static String httpsNoStoreKey();
     
    8586    WEBCORE_EXPORT static String networkProcessCrashedKey();
    8687    WEBCORE_EXPORT static String neverSeenBeforeKey();
     88    static String noKey();
    8789    static String noCacheKey();
    8890    static String noCurrentHistoryItemKey();
     
    159161    WEBCORE_EXPORT static String webGLKey();
    160162    WEBCORE_EXPORT static String webViewKey();
     163    static String yesKey();
    161164    WEBCORE_EXPORT static String zoomedKey();
    162165
Note: See TracChangeset for help on using the changeset viewer.