Title: [108861] trunk/Source/WebCore
Revision
108861
Author
[email protected]
Date
2012-02-24 16:03:17 -0800 (Fri, 24 Feb 2012)

Log Message

Limit WebGL Errors in Console to 10 per context
https://bugs.webkit.org/show_bug.cgi?id=79387

Patch by Gregg Tavares <[email protected]> on 2012-02-24
Reviewed by Kenneth Russell.

Some apps generated enough errors to overload
the Dev Tools so limit the number of errors.
For a correct app there should never be any
errors so seeing the first few should be enough
to debug.

No new tests as no new functionality

* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContextErrorMessageCallback::onErrorMessage):
(WebCore::WebGLRenderingContext::WebGLRenderingContext):
(WebCore::WebGLRenderingContext::initializeNewContext):
(WebCore::WebGLRenderingContext::printGLErrorToConsole):
(WebCore::WebGLRenderingContext::synthesizeGLError):
* html/canvas/WebGLRenderingContext.h:
(WebGLRenderingContext):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108860 => 108861)


--- trunk/Source/WebCore/ChangeLog	2012-02-24 23:57:36 UTC (rev 108860)
+++ trunk/Source/WebCore/ChangeLog	2012-02-25 00:03:17 UTC (rev 108861)
@@ -1,3 +1,28 @@
+2012-02-24  Gregg Tavares  <[email protected]>
+
+        Limit WebGL Errors in Console to 10 per context
+        https://bugs.webkit.org/show_bug.cgi?id=79387
+
+        Reviewed by Kenneth Russell.
+        
+        Some apps generated enough errors to overload
+        the Dev Tools so limit the number of errors.
+        For a correct app there should never be any
+        errors so seeing the first few should be enough
+        to debug.
+
+        No new tests as no new functionality
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore):
+        (WebCore::WebGLRenderingContextErrorMessageCallback::onErrorMessage):
+        (WebCore::WebGLRenderingContext::WebGLRenderingContext):
+        (WebCore::WebGLRenderingContext::initializeNewContext):
+        (WebCore::WebGLRenderingContext::printGLErrorToConsole):
+        (WebCore::WebGLRenderingContext::synthesizeGLError):
+        * html/canvas/WebGLRenderingContext.h:
+        (WebGLRenderingContext):
+
 2012-02-24  Michael Saboff  <[email protected]>
 
         ASSERT(position < 0) in JSC::Yarr::Interpreter::InputStream::readChecked

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (108860 => 108861)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-02-24 23:57:36 UTC (rev 108860)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-02-25 00:03:17 UTC (rev 108861)
@@ -82,6 +82,7 @@
 namespace WebCore {
 
 const double secondsBetweenRestoreAttempts = 1.0;
+const int maxGLErrorsAllowedToConsole = 10;
 
 namespace {
 
@@ -378,7 +379,7 @@
 class WebGLRenderingContextErrorMessageCallback : public GraphicsContext3D::ErrorMessageCallback {
 public:
     explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContext* cb) : m_context(cb) { }
-    virtual void onErrorMessage(const String& message, GC3Dint) { m_context->printWarningToConsole(message); }
+    virtual void onErrorMessage(const String& message, GC3Dint) { m_context->printGLErrorToConsole(message); }
     virtual ~WebGLRenderingContextErrorMessageCallback() { }
 private:
     WebGLRenderingContext* m_context;
@@ -426,6 +427,7 @@
     , m_contextLostMode(SyntheticLostContext)
     , m_attributes(attributes)
     , m_synthesizedErrorsToConsole(false)
+    , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole)
 {
     ASSERT(m_context);
     m_contextGroup = WebGLContextGroup::create();
@@ -466,6 +468,7 @@
     m_stencilFuncMask = 0xFFFFFFFF;
     m_stencilFuncMaskBack = 0xFFFFFFFF;
     m_layerCleared = false;
+    m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole;
     
     m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0;
     m_scissorEnabled = false;
@@ -4883,6 +4886,18 @@
     }
 }
 
+void WebGLRenderingContext::printGLErrorToConsole(const String& message)
+{
+    if (!m_numGLErrorsToConsoleAllowed)
+        return;
+
+    --m_numGLErrorsToConsoleAllowed;
+    printWarningToConsole(message);
+
+    if (!m_numGLErrorsToConsoleAllowed)
+        printWarningToConsole("WebGL: too many errors, no more errors will be reported to the console for this context.");
+}
+
 void WebGLRenderingContext::printWarningToConsole(const String& message)
 {
     if (!canvas())
@@ -5366,7 +5381,7 @@
 {
     if (m_synthesizedErrorsToConsole) {
       String str = String("WebGL: ") + GetErrorString(error) +  ": " + String(functionName) + ": " + String(description);
-      printWarningToConsole(str);
+      printGLErrorToConsole(str);
     }
     m_context->synthesizeGLError(error);
 }

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (108860 => 108861)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2012-02-24 23:57:36 UTC (rev 108860)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h	2012-02-25 00:03:17 UTC (rev 108861)
@@ -496,6 +496,7 @@
     bool m_isDepthStencilSupported;
 
     bool m_synthesizedErrorsToConsole;
+    int m_numGLErrorsToConsoleAllowed;
 
     // Enabled extension objects.
     OwnPtr<OESTextureFloat> m_oesTextureFloat;
@@ -622,6 +623,9 @@
     // Helper function for texParameterf and texParameteri.
     void texParameter(GC3Denum target, GC3Denum pname, GC3Dfloat parami, GC3Dint paramf, bool isFloat);
 
+    // Helper function to print GL errors to console.
+    void printGLErrorToConsole(const String&);
+
     // Helper function to print warnings to console. Currently
     // used only to warn about use of obsolete functions.
     void printWarningToConsole(const String&);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to