Changeset 91112 in webkit


Ignore:
Timestamp:
Jul 15, 2011 2:22:45 PM (13 years ago)
Author:
kbr@google.com
Message:

Don't restore WebGL context if it was guilty of a graphics reset
https://bugs.webkit.org/show_bug.cgi?id=64497

Reviewed by Stephen White.

Source/WebCore:

Use getGraphicsResetStatusARB already defined in Extensions3D to
determine why the context was lost, and respond to guilty context
notifications by forbidding restoration of the context.

It isn't currently possible to write an automated test for this.
We might consider extending the WEBKIT_lose_context extension to
allow a reason to be provided why the context was lost. It was
tested manually in Chromium on Windows and Linux with some test
cases that provoke actual graphics card resets.

  • html/canvas/WebGLRenderingContext.cpp:

(WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired):
(WebCore::WebGLRenderingContext::forceLostContext):
(WebCore::WebGLRenderingContext::maybeRestoreContext):

  • html/canvas/WebGLRenderingContext.h:

Source/WebKit/chromium:

Actually implement getGraphicsResetStatusARB rather than inferring
the status based on whether the context has been lost.

  • public/WebGraphicsContext3D.h:

(WebKit::WebGraphicsContext3D::getGraphicsResetStatusARB):

  • src/Extensions3DChromium.cpp:

(WebCore::Extensions3DChromium::getGraphicsResetStatusARB):

  • src/GraphicsContext3DChromium.cpp:
  • src/GraphicsContext3DInternal.h:

LayoutTests:

Updated expectations for context-lost test and added comment about
the order of event delivery. Per the specification of the
WEBKIT_lose_context extension, the previous expectations were wrong.

  • fast/canvas/webgl/context-lost-expected.txt:
  • fast/canvas/webgl/context-lost.html:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r91105 r91112  
     12011-07-15  Kenneth Russell  <kbr@google.com>
     2
     3        Don't restore WebGL context if it was guilty of a graphics reset
     4        https://bugs.webkit.org/show_bug.cgi?id=64497
     5
     6        Reviewed by Stephen White.
     7
     8        Updated expectations for context-lost test and added comment about
     9        the order of event delivery. Per the specification of the
     10        WEBKIT_lose_context extension, the previous expectations were wrong.
     11
     12        * fast/canvas/webgl/context-lost-expected.txt:
     13        * fast/canvas/webgl/context-lost.html:
     14
    1152011-07-15  Adrienne Walker  <enne@google.com>
    216
  • trunk/LayoutTests/fast/canvas/webgl/context-lost-expected.txt

    r91053 r91112  
    1616
    1717Lose context
    18 PASS extension.loseContext() was expected value: NO_ERROR.
    19 
    2018Test lost context
    2119PASS gl.isContextLost() is true
     
    180178PASS gl.isTexture(texture) is false
    181179PASS gl.getError() is gl.NO_ERROR
     180
     181PASS extension.loseContext() was expected value: NO_ERROR.
     182
    182183PASS successfullyParsed is true
    183184
  • trunk/LayoutTests/fast/canvas/webgl/context-lost.html

    r91053 r91112  
    6060    debug("");
    6161    debug("Lose context");
     62
     63    // Note: this will cause the context to be lost, and the
     64    // webglcontextlost event listener to be called, immediately.
    6265    shouldGenerateGLError(gl, gl.NO_ERROR, "extension.loseContext()");
    6366    debug("");
     
    293296    shouldBe("gl.getError()", "gl.NO_ERROR");
    294297
     298    debug("");
     299
    295300    finish();
    296301}
  • trunk/Source/WebCore/ChangeLog

    r91110 r91112  
     12011-07-15  Kenneth Russell  <kbr@google.com>
     2
     3        Don't restore WebGL context if it was guilty of a graphics reset
     4        https://bugs.webkit.org/show_bug.cgi?id=64497
     5
     6        Reviewed by Stephen White.
     7
     8        Use getGraphicsResetStatusARB already defined in Extensions3D to
     9        determine why the context was lost, and respond to guilty context
     10        notifications by forbidding restoration of the context.
     11
     12        It isn't currently possible to write an automated test for this.
     13        We might consider extending the WEBKIT_lose_context extension to
     14        allow a reason to be provided why the context was lost. It was
     15        tested manually in Chromium on Windows and Linux with some test
     16        cases that provoke actual graphics card resets.
     17
     18        * html/canvas/WebGLRenderingContext.cpp:
     19        (WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired):
     20        (WebCore::WebGLRenderingContext::forceLostContext):
     21        (WebCore::WebGLRenderingContext::maybeRestoreContext):
     22        * html/canvas/WebGLRenderingContext.h:
     23
    1242011-07-15  Chris Marrin  <cmarrin@apple.com>
    225
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r90180 r91112  
    340340void WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired()
    341341{
    342     // Timer is started when m_contextLost is false.  It will first call
    343     // onLostContext, which will set m_contextLost to true.  Then it will keep
    344     // calling restoreContext and reschedule itself until m_contextLost is back
    345     // to false.
    346     if (!m_context->m_contextLost) {
    347         m_context->onLostContext();
    348         startOneShot(secondsBetweenRestoreAttempts);
    349     } else {
    350         // The rendering context is not restored if there is no handler for
    351         // the context restored event.
    352         if (!m_context->canvas()->hasEventListeners(eventNames().webglcontextrestoredEvent))
    353             return;
    354 
    355         m_context->restoreContext();
    356         if (m_context->m_contextLost)
    357             startOneShot(secondsBetweenRestoreAttempts);
    358     }
     342    m_context->maybeRestoreContext();
    359343}
    360344
     
    39413925    }
    39423926
    3943     m_restoreTimer.startOneShot(0);
     3927    maybeRestoreContext();
    39443928}
    39453929
     
    47954779}
    47964780
     4781void WebGLRenderingContext::maybeRestoreContext()
     4782{
     4783    // Timer is started when m_contextLost is false. It will first call
     4784    // onLostContext, which will set m_contextLost to true. Then it will keep
     4785    // calling restoreContext and reschedule itself until m_contextLost is back
     4786    // to false.
     4787    bool shouldStartTimer = false;
     4788    bool shouldAttemptRestoreNow = true;
     4789
     4790    if (!m_contextLost) {
     4791        onLostContext();
     4792        shouldStartTimer = true;
     4793        shouldAttemptRestoreNow = false;
     4794    }
     4795
     4796    // The rendering context is not restored if there is no handler for
     4797    // the context restored event.
     4798    if (!canvas()->hasEventListeners(eventNames().webglcontextrestoredEvent))
     4799        return;
     4800
     4801    int contextLostReason = m_context->getExtensions()->getGraphicsResetStatusARB();
     4802
     4803    switch (contextLostReason) {
     4804    case GraphicsContext3D::NO_ERROR:
     4805        // The GraphicsContext3D implementation might not fully
     4806        // support GL_ARB_robustness semantics yet. Alternatively, the
     4807        // WebGL WEBKIT_lose_context extension might have been used to
     4808        // force a lost context.
     4809        break;
     4810    case Extensions3D::GUILTY_CONTEXT_RESET_ARB:
     4811        // The rendering context is not restored if this context was
     4812        // guilty of causing the graphics reset.
     4813        printWarningToConsole("WARNING: WebGL content on the page caused the graphics card to reset; not restoring the context");
     4814        return;
     4815    case Extensions3D::INNOCENT_CONTEXT_RESET_ARB:
     4816        // Always allow the context to be restored.
     4817        break;
     4818    case Extensions3D::UNKNOWN_CONTEXT_RESET_ARB:
     4819        // Warn. Ideally, prompt the user telling them that WebGL
     4820        // content on the page might have caused the graphics card to
     4821        // reset and ask them whether they want to continue running
     4822        // the content. Only if they say "yes" should we start
     4823        // attempting to restore the context.
     4824        printWarningToConsole("WARNING: WebGL content on the page might have caused the graphics card to reset");
     4825        break;
     4826    }
     4827
     4828    if (shouldAttemptRestoreNow) {
     4829        restoreContext();
     4830        if (m_contextLost)
     4831            shouldStartTimer = true;
     4832    }
     4833
     4834    if (shouldStartTimer)
     4835        m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts);
     4836}
     4837
    47974838WebGLRenderingContext::LRUImageBufferCache::LRUImageBufferCache(int capacity)
    47984839    : m_buffers(adoptArrayPtr(new OwnPtr<ImageBuffer>[capacity]))
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r90180 r91112  
    611611    void restoreStatesAfterVertexAttrib0Simulation();
    612612
     613    // Helper for restoration after context lost.
     614    void maybeRestoreContext();
     615
    613616    friend class WebGLStateRestorer;
    614617};
  • trunk/Source/WebKit/chromium/ChangeLog

    r91107 r91112  
     12011-07-15  Kenneth Russell  <kbr@google.com>
     2
     3        Don't restore WebGL context if it was guilty of a graphics reset
     4        https://bugs.webkit.org/show_bug.cgi?id=64497
     5
     6        Reviewed by Stephen White.
     7
     8        Actually implement getGraphicsResetStatusARB rather than inferring
     9        the status based on whether the context has been lost.
     10
     11        * public/WebGraphicsContext3D.h:
     12        (WebKit::WebGraphicsContext3D::getGraphicsResetStatusARB):
     13        * src/Extensions3DChromium.cpp:
     14        (WebCore::Extensions3DChromium::getGraphicsResetStatusARB):
     15        * src/GraphicsContext3DChromium.cpp:
     16        * src/GraphicsContext3DInternal.h:
     17
    1182011-07-15  Dan Bernstein  <mitz@apple.com>
    219
  • trunk/Source/WebKit/chromium/public/WebGraphicsContext3D.h

    r90878 r91112  
    357357
    358358    virtual void setContextLostCallback(WebGraphicsContextLostCallback* callback) {}
     359    // GL_ARB_robustness
     360    //
     361    // This entry point must provide slightly different semantics than
     362    // the GL_ARB_robustness extension; specifically, the lost context
     363    // state is sticky, rather than reported only once.
     364    virtual WGC3Denum getGraphicsResetStatusARB() { return 0; /* GL_NO_ERROR */ }
    359365};
    360366
  • trunk/Source/WebKit/chromium/src/Extensions3DChromium.cpp

    r86278 r91112  
    6565int Extensions3DChromium::getGraphicsResetStatusARB()
    6666{
    67     return m_internal->isContextLost() ? static_cast<int>(Extensions3D::UNKNOWN_CONTEXT_RESET_ARB) : static_cast<int>(GraphicsContext3D::NO_ERROR);
     67    return static_cast<int>(m_internal->getGraphicsResetStatusARB());
    6868}
    6969
  • trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp

    r90878 r91112  
    841841
    842842DELEGATE_TO_IMPL(rateLimitOffscreenContextCHROMIUM)
     843DELEGATE_TO_IMPL_R(getGraphicsResetStatusARB, GC3Denum)
    843844
    844845//----------------------------------------------------------------------
  • trunk/Source/WebKit/chromium/src/GraphicsContext3DInternal.h

    r90872 r91112  
    293293    void rateLimitOffscreenContextCHROMIUM();
    294294
     295    // GL_ARB_robustness
     296    GC3Denum getGraphicsResetStatusARB();
     297
    295298private:
    296299    OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
Note: See TracChangeset for help on using the changeset viewer.