Changeset 291477 in webkit


Ignore:
Timestamp:
Mar 18, 2022, 5:18:00 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Recycling a webgl context when it has been lost and restored causes a crash
https://bugs.webkit.org/show_bug.cgi?id=238024

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2022-03-18
Reviewed by Geoffrey Garen.

Source/WebCore:

Simulated context lost makes WebGLRenderingContextBase::m_context = nullptr
Real context lost preserves WebGLRenderingContextBase::m_context.

WebGLRenderingContextBase::maybeRestoreContext() used m_context.

The intention was that simulated context lost never invokes maybeRestoreContext()
as the timer to run maybeRestoreContext() is started only on real context lost.

However, it is possible to invoke simulated context lost after a real context lost,
but before the timer triggers maybeRestoreContext().

The sequence would be:

  1. Lose the context somehow
  2. Wait for webglcontextlost, use event.preventDefault() to request a restore.
  3. Before restore happens, lose the context via simulated context lost. This can be done by creating many contexts or via the WEBGL_lose_context.loseContext().
  4. maybeRestoreContext() would query m_context->getGraphicsResetStatusARB() for console log reasons, trying to explain to the developer why the context was lost. In case simulated context lost set the m_context == nullptr, this would crash.

getGraphicsResetStatusARB() has likely not been accurate for any platform ever.
For ANGLE, it is unimplemented and cannot pinpoint which context caused the context lost.
Just remove getGraphicsResetStatusARB() use from maybeRestoreContext(), this prevents
the crash. Remove it also from WebKit use altogether, it is never used for anything.

Adds the case to webgl/max-active-contexts-webglcontextlost-prevent-default.html

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::loseContextImpl):
(WebCore::WebGLRenderingContextBase::maybeRestoreContext):

  • loader/FrameLoaderClient.h:
  • platform/graphics/GraphicsContextGL.h:
  • platform/graphics/angle/GraphicsContextGLANGLE.cpp:
  • platform/graphics/angle/GraphicsContextGLANGLE.h:
  • platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp:
  • platform/graphics/opengl/ExtensionsGLOpenGLCommon.h:
  • platform/graphics/opengl/ExtensionsGLOpenGLES.cpp:
  • platform/graphics/opengl/ExtensionsGLOpenGLES.h:
  • platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
  • platform/graphics/opengl/GraphicsContextGLOpenGL.h:

Source/WebKit:

Remove GraphicsContextGL::getGraphicsResetStatusARB(), it's unused now.

  • GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
  • GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:

(getActiveUniformBlockiv):

  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:

(WebKit::RemoteGraphicsContextGLProxy::paintRenderingResultsToCanvas):
(WebKit::RemoteGraphicsContextGLProxy::paintCompositedResultsToCanvas):
(WebKit::RemoteGraphicsContextGLProxy::markContextLost):

  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp:

LayoutTests:

Creating excessive amount of contexts will lose the oldest context via
"simulated context lost" logic, making the contexts non-restorable.

Previously the test tried to test that requesting a restore on a context that
had simulated context lost would not restore. However, the test was invalid,
as it asserted that the context is still lost immediately after preventDefault():

event.preventDefault();
if (!contexts[0].isContextLost())

document.getElementById("result").textContent = "FAIL";

This is not correct, as the preventDefault() only informs the browser
that the context should be restored. The restore happens asynchronously.

Fix the test logic and add extra cases. Make the logic as such:

  1. Lose the context in some way
  2. Wait for context lost event, request restore
  3. Optionally do something that would trigger another way of losing the context
  4. Run assertions about context being still expectedly lost

The failures in the test expectation:
FAIL getError expected: INVALID_OPERATION. Was NO_ERROR :
FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR :
bug 236965

FAIL Expected restore be ignored, but it was not.
bug 238034

  • webgl/max-active-contexts-webglcontextlost-prevent-default.html:
Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r291471 r291477  
     12022-03-18  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        Recycling a webgl context when it has been lost and restored causes a crash
     4        https://bugs.webkit.org/show_bug.cgi?id=238024
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Creating excessive amount of contexts will lose the oldest context via
     9        "simulated context lost" logic, making the contexts non-restorable.
     10
     11        Previously the test tried to test that requesting a restore on a context that
     12        had simulated context lost would not restore. However, the test was invalid,
     13        as it asserted that the context is still lost immediately after preventDefault():
     14
     15          event.preventDefault();
     16          if (!contexts[0].isContextLost())
     17             document.getElementById("result").textContent = "FAIL";
     18
     19        This is not correct, as the preventDefault() only informs the browser
     20        that the context should be restored. The restore happens asynchronously.
     21
     22        Fix the test logic and add extra cases. Make the logic as such:
     23        1. Lose the context in some way
     24        2. Wait for context lost event, request restore
     25        3. Optionally do something that would trigger another way of losing the context
     26        4. Run assertions about context being still expectedly lost
     27
     28        The failures in the test expectation:
     29        FAIL getError expected: INVALID_OPERATION. Was NO_ERROR :
     30        FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR :
     31        bug 236965
     32
     33        FAIL Expected restore be ignored, but it was not.
     34        bug 238034
     35
     36        * webgl/max-active-contexts-webglcontextlost-prevent-default.html:
     37
    1382022-03-18  Carlos Garcia Campos  <cgarcia@igalia.com>
    239
  • trunk/LayoutTests/platform/glib/TestExpectations

    r291399 r291477  
    13851385webkit.org/b/172812 webgl/lose-context-after-context-lost.html [ Failure ]
    13861386webkit.org/b/172812 webgl/multiple-context-losses.html [ Failure ]
     1387webkit.org/b/172812 webgl/max-active-contexts-webglcontextlost-prevent-default.html [ Failure ]
    13871388
    13881389webkit.org/b/223624 webgl/conformance/extensions/khr-parallel-shader-compile.html [ Skip ]
  • trunk/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt

    r259900 r291477  
    1 CONSOLE MESSAGE: There are too many active WebGL contexts on this page, the oldest context will be lost.
    2 PASS if the first context was lost due to creating too many WebGL contexts even though preventDefault() was called when a webglcontextlost event was dispatched.
     1Test that first losing context, trying to restore it, and then doing something to really lose it does not crash.
     2
     3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     4
     5TEST COMPLETE: 42 PASS, 10 FAIL
     6
     7Running test: loseMethod: loseContext, loseMethod2: loseContext
     8PASS Got webglcontextlost and restore was attempted.
     9PASS getError was expected value: CONTEXT_LOST_WEBGL :
     10PASS getError was expected value: INVALID_OPERATION :
     11PASS gl.isContextLost() is true
     12PASS getError was expected value: NO_ERROR :
     13Running test: loseMethod: loseContext, loseMethod2: manyContexts
     14PASS Got webglcontextlost and restore was attempted.
     15PASS getError was expected value: CONTEXT_LOST_WEBGL :
     16PASS gl.isContextLost() is true
     17PASS getError was expected value: NO_ERROR :
     18Running test: loseMethod: loseContext, loseMethod2: gpuStatusFailure
     19PASS Got webglcontextlost and restore was attempted.
     20PASS getError was expected value: CONTEXT_LOST_WEBGL :
     21PASS gl.isContextLost() is true
     22PASS getError was expected value: NO_ERROR :
     23Running test: loseMethod: loseContext, loseMethod2: nothing
     24PASS Got webglcontextlost and restore was attempted.
     25PASS getError was expected value: CONTEXT_LOST_WEBGL :
     26PASS gl.isContextLost() is true
     27PASS getError was expected value: NO_ERROR :
     28Running test: loseMethod: manyContexts, loseMethod2: loseContext
     29PASS Got webglcontextlost and restore was attempted.
     30FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR :
     31FAIL getError expected: INVALID_OPERATION. Was NO_ERROR :
     32PASS gl.isContextLost() is true
     33PASS getError was expected value: NO_ERROR :
     34Running test: loseMethod: manyContexts, loseMethod2: manyContexts
     35PASS Got webglcontextlost and restore was attempted.
     36FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR :
     37PASS gl.isContextLost() is true
     38PASS getError was expected value: NO_ERROR :
     39Running test: loseMethod: manyContexts, loseMethod2: gpuStatusFailure
     40PASS Got webglcontextlost and restore was attempted.
     41FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR :
     42PASS gl.isContextLost() is true
     43PASS getError was expected value: NO_ERROR :
     44Running test: loseMethod: manyContexts, loseMethod2: nothing
     45PASS Got webglcontextlost and restore was attempted.
     46FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR :
     47PASS gl.isContextLost() is true
     48PASS getError was expected value: NO_ERROR :
     49Running test: loseMethod: gpuStatusFailure, loseMethod2: loseContext
     50PASS Got webglcontextlost and restore was attempted.
     51PASS getError was expected value: CONTEXT_LOST_WEBGL :
     52FAIL getError expected: INVALID_OPERATION. Was NO_ERROR :
     53FAIL Expected restore be ignored, but it was not.
     54PASS getError was expected value: NO_ERROR :
     55Running test: loseMethod: gpuStatusFailure, loseMethod2: manyContexts
     56PASS Got webglcontextlost and restore was attempted.
     57PASS getError was expected value: CONTEXT_LOST_WEBGL :
     58FAIL Expected restore be ignored, but it was not.
     59PASS getError was expected value: NO_ERROR :
     60Running test: loseMethod: gpuStatusFailure, loseMethod2: gpuStatusFailure
     61PASS Got webglcontextlost and restore was attempted.
     62PASS getError was expected value: CONTEXT_LOST_WEBGL :
     63FAIL Expected restore be ignored, but it was not.
     64PASS getError was expected value: NO_ERROR :
     65Running test: loseMethod: gpuStatusFailure, loseMethod2: nothing
     66PASS Got webglcontextlost and restore was attempted.
     67PASS getError was expected value: CONTEXT_LOST_WEBGL :
     68FAIL Expected restore be ignored, but it was not.
     69PASS getError was expected value: NO_ERROR :
     70PASS successfullyParsed is true
     71
     72TEST COMPLETE
     73
  • trunk/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default.html

    r199819 r291477  
    1 <div id="result">PASS if the first context was lost due to creating too many WebGL contexts even though <code>preventDefault()</code> was called when a <code>webglcontextlost</code> event was dispatched.</div>
     1<!DOCTYPE html>
     2<html>
     3<head>
     4<meta charset="utf-8">
     5<link rel="stylesheet" href="resources/webgl_test_files/resources/js-test-style.css"/>
     6<script src="resources/webgl_test_files/js/js-test-pre.js"></script>
     7<script src="resources/webgl_test_files/js/webgl-test-utils.js"></script>
     8</head>
     9<body onload="test()">
     10<div id="description"></div>
     11<div id="console"></div>
    212<script>
    3 if (window.testRunner) {
    4     testRunner.waitUntilDone();
    5     testRunner.dumpAsText();
     13"use strict";
     14description("Test that first losing context, trying to restore it, and then doing something to really lose it does not crash.");
     15
     16// The test would crash with following sequence:
     17// 1. Cause a real context lost. In this test, "gpuStatusFailure".
     18// 2. Page would try to restore the context. This would start the restore timer.
     19// 3. Before the restore timer fires, really lose the context. In this test, "manyContext".
     20// 4. The restore timer would fire, and restore function would use nullptr context.
     21
     22var wtu = WebGLTestUtils;
     23var gl;
     24
     25async function waitForEvent(element, eventName, timeoutMS)
     26{
     27    timeoutMS = timeoutMS || 2000;
     28    return new Promise((resolve, reject) => {
     29        function timeoutHandler() {
     30            element.removeEventListener(eventName, handler, { once: true });
     31            reject();
     32        }
     33        const rejectID = setTimeout(timeoutHandler, timeoutMS);
     34        function handler(event) {
     35            clearTimeout(rejectID);
     36            resolve(event);
     37        }
     38        element.addEventListener(eventName, handler, { once: true });
     39    });
    640}
    741
    8 var maxNumberOfActiveContexts = 16;
    9 var contexts = [];
    10 for (var i = 0; i <= maxNumberOfActiveContexts; i++) {
    11     var canvas = document.createElement("canvas");
    12     canvas.addEventListener("webglcontextlost", function(event) {
    13         event.preventDefault();
    14         if (!contexts[0].isContextLost())
    15             document.getElementById("result").textContent = "FAIL";
    16         if (window.testRunner)
    17             testRunner.notifyDone();
    18     });
    19     contexts[i] = canvas.getContext("webgl");
     42async function waitForWebGLContextRestored(canvas, timeoutMS)
     43{
     44    await waitForEvent(canvas, "webglcontextrestored", timeoutMS);
     45}
     46
     47async function waitForWebGLContextLostAndRestore(canvas, timeoutMS)
     48{
     49    let event = await waitForEvent(canvas, "webglcontextlost", timeoutMS);
     50    event.preventDefault();
     51}
     52
     53function testDescription(subcase) {
     54    return Object.keys(subcase).map((k) => `${k}: ${typeof subcase[k] === "function" ? subcase[k].name : subcase[k]}`).join(", ");
     55}
     56
     57async function runTest(subcase)
     58{
     59    debug(`Running test: ${testDescription(subcase)}`);
     60
     61    const canvas = document.createElement("canvas");
     62    canvas.width = 1;
     63    canvas.height = 1;
     64    gl = wtu.create3DContext(canvas);
     65    const WEBGL_lose_context = wtu.getExtensionWithKnownPrefixes(gl, "WEBGL_lose_context");
     66
     67    const webglcontextlostandrestore = waitForWebGLContextLostAndRestore(canvas);
     68    const webglcontextrestored = waitForWebGLContextRestored(canvas);
     69    let expectRestoreIgnored = subcase.loseMethod(gl, WEBGL_lose_context);
     70
     71    try {
     72        await webglcontextlostandrestore;
     73        testPassed("Got webglcontextlost and restore was attempted.");
     74        wtu.glErrorShouldBe(gl, gl.CONTEXT_LOST_WEBGL);
     75    } catch (e) {
     76        if (e)
     77            throw e;
     78        testFailed("Timed out waiting webglcontextlost that would attempt to be restored.");
     79    }
     80    expectRestoreIgnored = subcase.loseMethod2(gl, WEBGL_lose_context) || expectRestoreIgnored;
     81
     82    try {
     83        await webglcontextrestored;
     84        if (expectRestoreIgnored)
     85            testFailed("Expected restore be ignored, but it was not.");
     86        else
     87            shouldBeFalse("gl.isContextLost()");
     88    } catch (e) {
     89        if (e)
     90            throw e;
     91        if (!expectRestoreIgnored)
     92            testFailed("Did not expect restore be ignored, but it was.");
     93        else
     94            shouldBeTrue("gl.isContextLost()");
     95    }
     96
     97    wtu.glErrorShouldBe(gl, gl.NO_ERROR);
     98}
     99
     100function loseContext(gl, WEBGL_lose_context)
     101{
     102    if (!WEBGL_lose_context) {
     103        testFailed("Could not find WEBGL_lose_context extension");
     104        return;
     105    }
     106    let wasLost = gl.isContextLost();
     107    WEBGL_lose_context.loseContext();
     108    if (wasLost)
     109        wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
     110    return true; // Request for restore is ignored.
     111}
     112
     113function manyContexts()
     114{
     115    // This causes the older contexts to be lost, including the first one we created
     116    // for testing.
     117    const contexts = []
     118    for (let i = 0; i < 50; ++i)
     119        contexts.push(document.createElement("canvas").getContext("webgl"));
     120    return true; // Request for restore is ignored.
     121}
     122
     123function gpuStatusFailure(gl)
     124{
     125    internals.simulateEventForWebGLContext("GPUStatusFailure", gl);
     126    gl.clear(gl.COLOR_BUFFER_BIT);
     127    return true; // Request for restore is honored.
     128}
     129
     130function nothing()
     131{
     132    return false;
     133}
     134
     135const loseMethods = [loseContext, manyContexts];
     136if (window.internals)
     137    loseMethods.push(gpuStatusFailure);
     138
     139const subcases = [];
     140for (const loseMethod of loseMethods)
     141    for (const loseMethod2 of loseMethods.concat(nothing))
     142        subcases.push({loseMethod, loseMethod2});
     143
     144async function test()
     145{
     146    for (let subcase of subcases)
     147        await runTest(subcase);
     148    finishTest();
    20149}
    21150</script>
     151</body>
     152</html>
  • trunk/Source/WebCore/ChangeLog

    r291476 r291477  
     12022-03-18  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        Recycling a webgl context when it has been lost and restored causes a crash
     4        https://bugs.webkit.org/show_bug.cgi?id=238024
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Simulated context lost makes WebGLRenderingContextBase::m_context = nullptr
     9        Real context lost preserves WebGLRenderingContextBase::m_context.
     10
     11        WebGLRenderingContextBase::maybeRestoreContext() used m_context.
     12
     13        The intention was that simulated context lost never invokes maybeRestoreContext()
     14        as the timer to run maybeRestoreContext() is started only on real context lost.
     15
     16        However, it is possible to invoke simulated context lost after a real context lost,
     17        but before the timer triggers maybeRestoreContext().
     18
     19        The sequence would be:
     20        1. Lose the context somehow
     21        2. Wait for webglcontextlost, use event.preventDefault() to request a restore.
     22        3. Before restore happens, lose the context via simulated context lost.
     23           This can be done by creating many contexts or via the WEBGL_lose_context.loseContext().
     24        4. maybeRestoreContext() would query m_context->getGraphicsResetStatusARB() for
     25           console log reasons, trying to explain to the developer why the context was lost.
     26           In case simulated context lost set the m_context == nullptr, this would crash.
     27
     28        getGraphicsResetStatusARB() has likely not been accurate for any platform ever.
     29        For ANGLE, it is unimplemented and cannot pinpoint which context caused the context lost.
     30        Just remove getGraphicsResetStatusARB() use from maybeRestoreContext(), this prevents
     31        the crash. Remove it also from WebKit use altogether, it is never used for anything.
     32
     33        Adds the case to webgl/max-active-contexts-webglcontextlost-prevent-default.html
     34
     35        * html/canvas/WebGLRenderingContextBase.cpp:
     36        (WebCore::WebGLRenderingContextBase::loseContextImpl):
     37        (WebCore::WebGLRenderingContextBase::maybeRestoreContext):
     38        * loader/FrameLoaderClient.h:
     39        * platform/graphics/GraphicsContextGL.h:
     40        * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
     41        * platform/graphics/angle/GraphicsContextGLANGLE.h:
     42        * platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp:
     43        * platform/graphics/opengl/ExtensionsGLOpenGLCommon.h:
     44        * platform/graphics/opengl/ExtensionsGLOpenGLES.cpp:
     45        * platform/graphics/opengl/ExtensionsGLOpenGLES.h:
     46        * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
     47        * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
     48
    1492022-03-18  Cameron McCormack  <heycam@apple.com>
    250
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r291468 r291477  
    64536453    m_contextLostMode = mode;
    64546454
    6455     if (mode == RealLostContext) {
    6456         // Inform the embedder that a lost context was received. In response, the embedder might
    6457         // decide to take action such as asking the user for permission to use WebGL again.
    6458         auto* canvas = htmlCanvas();
    6459         if (canvas) {
    6460             if (RefPtr<Frame> frame = canvas->document().frame())
    6461                 frame->loader().client().didLoseWebGLContext(m_context->getGraphicsResetStatusARB());
    6462         }
    6463     }
    6464 
    64656455    detachAndRemoveAllObjects();
    64666456    loseExtensions(mode);
     
    77727762        return;
    77737763
    7774     int contextLostReason = m_context->getGraphicsResetStatusARB();
    7775 
    7776     switch (contextLostReason) {
    7777     case GraphicsContextGL::NO_ERROR:
    7778         // The GraphicsContextGLOpenGL implementation might not fully
    7779         // support GL_ARB_robustness semantics yet. Alternatively, the
    7780         // WEBGL_lose_context extension might have been used to force
    7781         // a lost context.
    7782         break;
    7783     case GraphicsContextGL::GUILTY_CONTEXT_RESET_ARB:
    7784         // The rendering context is not restored if this context was
    7785         // guilty of causing the graphics reset.
    7786         printToConsole(MessageLevel::Warning, "WARNING: WebGL content on the page caused the graphics card to reset; not restoring the context");
    7787         return;
    7788     case GraphicsContextGL::INNOCENT_CONTEXT_RESET_ARB:
    7789         // Always allow the context to be restored.
    7790         break;
    7791     case GraphicsContextGL::UNKNOWN_CONTEXT_RESET_ARB:
    7792         // Warn. Ideally, prompt the user telling them that WebGL
    7793         // content on the page might have caused the graphics card to
    7794         // reset and ask them whether they want to continue running
    7795         // the content. Only if they say "yes" should we start
    7796         // attempting to restore the context.
    7797         printToConsole(MessageLevel::Warning, "WARNING: WebGL content on the page might have caused the graphics card to reset");
    7798         break;
    7799     }
    7800 
    78017764    auto* canvas = htmlCanvas();
    78027765    if (!canvas)
  • trunk/Source/WebCore/loader/FrameLoaderClient.h

    r289790 r291477  
    341341#if ENABLE(WEBGL)
    342342    virtual bool allowWebGL(bool enabledPerSettings) { return enabledPerSettings; }
    343     // Informs the embedder that a WebGL canvas inside this frame received a lost context
    344     // notification with the given GL_ARB_robustness guilt/innocence code (see GraphicsContextGL.h).
    345     virtual void didLoseWebGLContext(int) { }
    346343    virtual WebGLLoadPolicy webGLPolicyForURL(const URL&) const { return WebGLLoadPolicy::WebGLAllowCreation; }
    347344    virtual WebGLLoadPolicy resolveWebGLPolicyForURL(const URL&) const { return WebGLLoadPolicy::WebGLAllowCreation; }
  • trunk/Source/WebCore/platform/graphics/GraphicsContextGL.h

    r291468 r291477  
    13761376    virtual bool isExtensionEnabled(const String&) = 0;
    13771377
    1378     // GL_ARB_robustness
    1379     // Note: This method's behavior differs from the GL_ARB_robustness
    1380     // specification in the following way:
    1381     // The implementation must not reset the error state during this call.
    1382     // If getGraphicsResetStatusARB returns an error, it should continue
    1383     // returning the same error. Restoring the GraphicsContextGLOpenGL is handled
    1384     // externally.
    1385     virtual GCGLint getGraphicsResetStatusARB() = 0;
    1386 
    13871378    // GL_ANGLE_translated_shader_source
    13881379    virtual String getTranslatedShaderSourceANGLE(PlatformGLObject) = 0;
  • trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp

    r291399 r291477  
    29242924}
    29252925
    2926 GLint GraphicsContextGLANGLE::getGraphicsResetStatusARB()
    2927 {
    2928     return GraphicsContextGL::NO_ERROR;
    2929 }
    2930 
    29312926String GraphicsContextGLANGLE::getTranslatedShaderSourceANGLE(PlatformGLObject shader)
    29322927{
  • trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h

    r291399 r291477  
    330330    void ensureExtensionEnabled(const String&) override;
    331331    bool isExtensionEnabled(const String&) override;
    332     GCGLint getGraphicsResetStatusARB() override;
    333332    void drawBuffersEXT(GCGLSpan<const GCGLenum>) override;
    334333    String getTranslatedShaderSourceANGLE(PlatformGLObject) override;
  • trunk/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp

    r289790 r291477  
    160160}
    161161
    162 int ExtensionsGLOpenGLCommon::getGraphicsResetStatusARB()
    163 {
    164     return GraphicsContextGL::NO_ERROR;
    165 }
    166 
    167162String ExtensionsGLOpenGLCommon::getTranslatedShaderSourceANGLE(PlatformGLObject shader)
    168163{
  • trunk/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.h

    r289790 r291477  
    4444    virtual void ensureEnabled(const String&);
    4545    virtual bool isEnabled(const String&);
    46     virtual int getGraphicsResetStatusARB();
    4746    virtual String getTranslatedShaderSourceANGLE(PlatformGLObject);
    4847    virtual void drawBuffersEXT(GCGLSpan<const GCGLenum> bufs) = 0;
     
    5857    virtual void vertexAttribDivisorANGLE(GCGLuint index, GCGLuint divisor) = 0;
    5958
    60     // EXT Robustness - uses getGraphicsResetStatusARB()
     59    // EXT Robustness
    6160    virtual void readnPixelsEXT(int x, int y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, void *data);
    6261    virtual void getnUniformfvEXT(GCGLuint program, int location, GCGLsizei bufSize, float *params);
  • trunk/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.cpp

    r289790 r291477  
    167167}
    168168
    169 int ExtensionsGLOpenGLES::getGraphicsResetStatusARB()
    170 {
    171     // FIXME: This does not call getGraphicsResetStatusARB, but instead getGraphicsResetStatusEXT.
    172     // The return codes from the two extensions are identical and their purpose is the same, so it
    173     // may be best to rename getGraphicsResetStatusARB() to getGraphicsResetStatus().
    174     if (m_contextResetStatus != GL_NO_ERROR)
    175         return m_contextResetStatus;
    176     if (m_glGetGraphicsResetStatusEXT) {
    177         int reasonForReset = GraphicsContextGL::UNKNOWN_CONTEXT_RESET_ARB;
    178         if (m_context->makeContextCurrent())
    179             reasonForReset = m_glGetGraphicsResetStatusEXT();
    180         if (reasonForReset != GL_NO_ERROR)
    181             m_contextResetStatus = reasonForReset;
    182         return reasonForReset;
    183     }
    184 
    185     m_context->synthesizeGLError(GL_INVALID_OPERATION);
    186     return false;
    187 }
    188 
    189169void ExtensionsGLOpenGLES::readnPixelsEXT(int x, int y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, void *data)
    190170{
  • trunk/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.h

    r289790 r291477  
    9999    void vertexAttribDivisorANGLE(GCGLuint index, GCGLuint divisor) override;
    100100
    101     // EXT Robustness - reset
    102     int getGraphicsResetStatusARB() override;
    103 
    104101    // EXT Robustness - etc
    105102    void readnPixelsEXT(int x, int y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, void *data) override;
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp

    r291399 r291477  
    30713071}
    30723072
    3073 GLint GraphicsContextGLOpenGL::getGraphicsResetStatusARB()
    3074 {
    3075     return getExtensions().getGraphicsResetStatusARB();
    3076 }
    3077 
    30783073void GraphicsContextGLOpenGL::drawBuffersEXT(GCGLSpan<const GCGLenum> buffers)
    30793074{
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h

    r291399 r291477  
    373373    void ensureExtensionEnabled(const String&) final;
    374374    bool isExtensionEnabled(const String&) final;
    375     GLint getGraphicsResetStatusARB() final;
    376375    void drawBuffersEXT(GCGLSpan<const GCGLenum>) override;
    377376    String getTranslatedShaderSourceANGLE(PlatformGLObject) final;
  • trunk/Source/WebKit/ChangeLog

    r291475 r291477  
     12022-03-18  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        Recycling a webgl context when it has been lost and restored causes a crash
     4        https://bugs.webkit.org/show_bug.cgi?id=238024
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Remove GraphicsContextGL::getGraphicsResetStatusARB(), it's unused now.
     9
     10        * GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
     11        * GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:
     12        (getActiveUniformBlockiv):
     13        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
     14        (WebKit::RemoteGraphicsContextGLProxy::paintRenderingResultsToCanvas):
     15        (WebKit::RemoteGraphicsContextGLProxy::paintCompositedResultsToCanvas):
     16        (WebKit::RemoteGraphicsContextGLProxy::markContextLost):
     17        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
     18        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp:
     19
    1202022-03-18  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in

    r291468 r291477  
    285285    void UniformBlockBinding(uint32_t program, uint32_t uniformBlockIndex, uint32_t uniformBlockBinding)
    286286    void GetActiveUniformBlockiv(uint32_t program, uint32_t uniformBlockIndex, uint32_t pname, uint64_t paramsSize) -> (IPC::ArrayReference<int32_t> params) Synchronous
    287     void GetGraphicsResetStatusARB() -> (int32_t returnValue) Synchronous
    288287    void GetTranslatedShaderSourceANGLE(uint32_t arg0) -> (String returnValue) Synchronous
    289288    void DrawBuffersEXT(IPC::ArrayReference<uint32_t> bufs)
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h

    r291032 r291477  
    13221322        completionHandler(IPC::ArrayReference<int32_t>(reinterpret_cast<int32_t*>(params.data()), params.size()));
    13231323    }
    1324     void getGraphicsResetStatusARB(CompletionHandler<void(int32_t)>&& completionHandler)
    1325     {
    1326         GCGLint returnValue = { };
    1327         assertIsCurrent(workQueue());
    1328         returnValue = m_context->getGraphicsResetStatusARB();
    1329         completionHandler(returnValue);
    1330     }
    13311324    void getTranslatedShaderSourceANGLE(uint32_t arg0, CompletionHandler<void(String&&)>&& completionHandler)
    13321325    {
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h

    r291468 r291477  
    315315    void uniformBlockBinding(PlatformGLObject program, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding) final;
    316316    void getActiveUniformBlockiv(GCGLuint program, GCGLuint uniformBlockIndex, GCGLenum pname, GCGLSpan<GCGLint> params) final;
    317     GCGLint getGraphicsResetStatusARB() final;
    318317    String getTranslatedShaderSourceANGLE(PlatformGLObject arg0) final;
    319318    void drawBuffersEXT(GCGLSpan<const GCGLenum> bufs) final;
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp

    r291032 r291477  
    22682268}
    22692269
    2270 GCGLint RemoteGraphicsContextGLProxy::getGraphicsResetStatusARB()
    2271 {
    2272     int32_t returnValue = { };
    2273     if (!isContextLost()) {
    2274         auto sendResult = sendSync(Messages::RemoteGraphicsContextGL::GetGraphicsResetStatusARB(), Messages::RemoteGraphicsContextGL::GetGraphicsResetStatusARB::Reply(returnValue));
    2275         if (!sendResult)
    2276             markContextLost();
    2277     }
    2278     return returnValue;
    2279 }
    2280 
    22812270String RemoteGraphicsContextGLProxy::getTranslatedShaderSourceANGLE(PlatformGLObject arg0)
    22822271{
Note: See TracChangeset for help on using the changeset viewer.