Changeset 291749 in webkit
- Timestamp:
- Mar 23, 2022, 10:12:07 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/canvas/webgl/lose-context-on-status-failure-expected.txt (modified) (1 diff)
-
LayoutTests/webgl/lose-context-after-context-lost-expected.txt (modified) (3 diffs)
-
LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt (modified) (3 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (modified) (14 diffs)
-
Source/WebCore/html/canvas/WebGLRenderingContextBase.h (modified) (4 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r291748 r291749 1 2022-03-23 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 After losing context due to too many contexts, getError() does not return CONTEXT_LOST_WEBGL 4 https://bugs.webkit.org/show_bug.cgi?id=236965 5 6 Reviewed by Kenneth Russell. 7 8 * fast/canvas/webgl/lose-context-on-status-failure-expected.txt: 9 * webgl/lose-context-after-context-lost-expected.txt: 10 * webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt: 11 1 12 2022-03-23 Kimmo Kinnunen <kkinnunen@apple.com> 2 13 -
trunk/LayoutTests/fast/canvas/webgl/lose-context-on-status-failure-expected.txt
r259900 r291749 1 CONSOLE MESSAGE: WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost2 CONSOLE MESSAGE: WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost3 CONSOLE MESSAGE: WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost4 CONSOLE MESSAGE: WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost1 CONSOLE MESSAGE: WebGL: context lost. 2 CONSOLE MESSAGE: WebGL: context lost. 3 CONSOLE MESSAGE: WebGL: context lost. 4 CONSOLE MESSAGE: WebGL: context lost. 5 5 Checks that a GPU status check failure will lose the context. 6 6 NOTE: This only passes in the test harness because it requires Internals. -
trunk/LayoutTests/webgl/lose-context-after-context-lost-expected.txt
r291399 r291749 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 4 5 TEST COMPLETE: 29 PASS, 2FAIL5 TEST COMPLETE: 31 PASS, 0 FAIL 6 6 7 7 Running test: loseMethod: loseContext, testedMethod: loseContext … … 20 20 PASS Got webglcontextlost. 21 21 PASS gl.isContextLost() is true 22 FAIL gl.getError() should be 37442. Was 0. 22 PASS gl.getError() is gl.CONTEXT_LOST_WEBGL 23 23 PASS gl.getError() is gl.NO_ERROR 24 24 PASS Did not crash on tested method loseContext. … … 26 26 PASS Got webglcontextlost. 27 27 PASS gl.isContextLost() is true 28 FAIL gl.getError() should be 37442. Was 0. 28 PASS gl.getError() is gl.CONTEXT_LOST_WEBGL 29 29 PASS gl.getError() is gl.NO_ERROR 30 30 PASS Did not crash on tested method restoreContext. -
trunk/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt
r291477 r291749 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 4 5 TEST COMPLETE: 4 2 PASS, 10FAIL5 TEST COMPLETE: 46 PASS, 6 FAIL 6 6 7 7 Running test: loseMethod: loseContext, loseMethod2: loseContext … … 15 15 PASS getError was expected value: CONTEXT_LOST_WEBGL : 16 16 PASS gl.isContextLost() is true 17 PASS getError was expected value: NO_ERROR:17 FAIL getError expected: NO_ERROR. Was INVALID_OPERATION : 18 18 Running test: loseMethod: loseContext, loseMethod2: gpuStatusFailure 19 19 PASS Got webglcontextlost and restore was attempted. … … 28 28 Running test: loseMethod: manyContexts, loseMethod2: loseContext 29 29 PASS Got webglcontextlost and restore was attempted. 30 FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR:31 FAIL getError expected: INVALID_OPERATION. Was NO_ERROR:30 PASS getError was expected value: CONTEXT_LOST_WEBGL : 31 PASS getError was expected value: INVALID_OPERATION : 32 32 PASS gl.isContextLost() is true 33 33 PASS getError was expected value: NO_ERROR : 34 34 Running test: loseMethod: manyContexts, loseMethod2: manyContexts 35 35 PASS Got webglcontextlost and restore was attempted. 36 FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR:36 PASS getError was expected value: CONTEXT_LOST_WEBGL : 37 37 PASS gl.isContextLost() is true 38 38 PASS getError was expected value: NO_ERROR : 39 39 Running test: loseMethod: manyContexts, loseMethod2: gpuStatusFailure 40 40 PASS Got webglcontextlost and restore was attempted. 41 FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR:41 PASS getError was expected value: CONTEXT_LOST_WEBGL : 42 42 PASS gl.isContextLost() is true 43 43 PASS getError was expected value: NO_ERROR : 44 44 Running test: loseMethod: manyContexts, loseMethod2: nothing 45 45 PASS Got webglcontextlost and restore was attempted. 46 FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR:46 PASS getError was expected value: CONTEXT_LOST_WEBGL : 47 47 PASS gl.isContextLost() is true 48 48 PASS getError was expected value: NO_ERROR : -
trunk/Source/WebCore/ChangeLog
r291748 r291749 1 2022-03-23 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 After losing context due to too many contexts, getError() does not return CONTEXT_LOST_WEBGL 4 https://bugs.webkit.org/show_bug.cgi?id=236965 5 6 Reviewed by Kenneth Russell. 7 8 After generating context lost, getError() is specified to return: 9 - CONTEXT_LOST_WEBGL for first call 10 - NO_ERROR for all the next calls. 11 12 WEBGL_lose_context is specified to add INVALID_OPERATION errors 13 even after context lost. 14 15 Change the code so that CONTEXT_LOST_WEBGL and WEBGL_lose_context induced 16 INVALID_OPERATION errors go to error vector in context lost -specific state. 17 18 Previously, these errors went into the m_context error vector. This is problematic 19 especially in the case where context loss happens where the m_context gets destroyed -- 20 the error vector would be gone. This kind of loss happens for example when contexts 21 get lost due to the process having too many active contexts (least active context is "recycled"). 22 23 Previously, any synthetized error was potentially obtainable after context lost. This is problematic 24 as it is not as specified. As mentioned above, only errors allowed after context lost is 25 - CONTEXT_LOST_WEBGL first after context lost 26 - WEBGL_lose_context.loseContext() and WEBGL_lose_context.restoreContext() induced INVALID_OPERATIONs 27 28 Changes the behavior to not report INVALID_OPERATION error in the theoretical case where we fail to 29 instantiate a new context. This is not allowed by the spec. Instead, just print an error to the console. 30 31 No new tests, updates the expectations of old ones with less failures. 32 33 * html/canvas/WebGLRenderingContextBase.cpp: 34 (WebCore::WebGLRenderingContextBase::initializeNewContext): 35 (WebCore::WebGLRenderingContextBase::getError): 36 (WebCore::WebGLRenderingContextBase::isContextLost const): 37 (WebCore::WebGLRenderingContextBase::isContextLostOrPending): 38 (WebCore::WebGLRenderingContextBase::forceLostContext): 39 (WebCore::WebGLRenderingContextBase::loseContextImpl): 40 (WebCore::WebGLRenderingContextBase::forceRestoreContext): 41 (WebCore::WebGLRenderingContextBase::isContextUnrecoverablyLost const): 42 (WebCore::WebGLRenderingContextBase::scheduleTaskToDispatchContextLostEvent): 43 (WebCore::WebGLRenderingContextBase::maybeRestoreContext): 44 (WebCore::WebGLRenderingContextBase::synthesizeGLError): 45 (WebCore::WebGLRenderingContextBase::synthesizeLostContextGLError): 46 * html/canvas/WebGLRenderingContextBase.h: 47 (WebCore::WebGLRenderingContextBase::ContextLostState::ContextLostState): 48 1 49 2022-03-23 Kimmo Kinnunen <kkinnunen@apple.com> 2 50 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r291611 r291749 1047 1047 void WebGLRenderingContextBase::initializeNewContext() 1048 1048 { 1049 ASSERT(! m_contextLost);1049 ASSERT(!isContextLost()); 1050 1050 m_needsUpdate = true; 1051 1051 m_markedCanvasDirty = false; … … 3167 3167 GCGLenum WebGLRenderingContextBase::getError() 3168 3168 { 3169 if (!m_context || m_isPendingPolicyResolution) 3169 if (isContextLost()) { 3170 auto& errors = m_contextLostState->errors; 3171 if (!errors.isEmpty()) 3172 return errors.takeFirst(); 3173 return GraphicsContextGL::NO_ERROR; 3174 } 3175 if (m_isPendingPolicyResolution) 3170 3176 return GraphicsContextGL::NO_ERROR; 3171 3177 return m_context->getError(); … … 4056 4062 bool WebGLRenderingContextBase::isContextLost() const 4057 4063 { 4058 return m_contextLost ;4064 return m_contextLostState.has_value(); 4059 4065 } 4060 4066 … … 4077 4083 } 4078 4084 4079 return m_contextLost|| m_isPendingPolicyResolution;4085 return isContextLost() || m_isPendingPolicyResolution; 4080 4086 } 4081 4087 … … 6434 6440 { 6435 6441 if (isContextLostOrPending()) { 6436 synthesize GLError(GraphicsContextGL::INVALID_OPERATION, "loseContext", "context already lost");6442 synthesizeLostContextGLError(GraphicsContextGL::INVALID_OPERATION, "loseContext", "context already lost"); 6437 6443 return; 6438 6444 } … … 6445 6451 if (isContextLost()) 6446 6452 return; 6447 6448 m_contextLost = true; 6449 m_contextLostMode = mode; 6453 if (mode == RealLostContext) 6454 printToConsole(MessageLevel::Error, "WebGL: context lost."); 6455 6456 m_contextLostState = ContextLostState { mode }; 6457 m_contextLostState->errors.add(GraphicsContextGL::CONTEXT_LOST_WEBGL); 6450 6458 6451 6459 detachAndRemoveAllObjects(); … … 6460 6468 break; 6461 6469 } 6462 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInConsole: DontDisplayInConsole;6463 synthesizeGLError(GraphicsContextGL::CONTEXT_LOST_WEBGL, "loseContext", "context lost", display);6464 6465 // Don't allow restoration unless the context lost event has both been6466 // dispatched and its default behavior prevented.6467 m_restoreAllowed = false;6468 6470 6469 6471 // Always defer the dispatch of the context lost event, to implement … … 6478 6480 return; 6479 6481 } 6480 6481 if (!m_restoreAllowed) { 6482 if (m_contextLostMode == SyntheticLostContext) 6483 synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "restoreContext", "context restoration not allowed"); 6482 if (!m_contextLostState->restoreRequested) { 6483 if (m_contextLostState->mode == SyntheticLostContext) 6484 synthesizeLostContextGLError(GraphicsContextGL::INVALID_OPERATION, "restoreContext", "context restoration not allowed"); 6484 6485 return; 6485 6486 } … … 6491 6492 bool WebGLRenderingContextBase::isContextUnrecoverablyLost() const 6492 6493 { 6493 return m_contextLost && !m_restoreAllowed;6494 return isContextLost() && !m_contextLostState->restoreRequested; 6494 6495 } 6495 6496 … … 7733 7734 if (isContextStopped()) 7734 7735 return; 7735 7736 if (!isContextLost()) 7737 return; 7736 7738 auto event = WebGLContextEvent::create(eventNames().webglcontextlostEvent, Event::CanBubble::No, Event::IsCancelable::Yes, emptyString()); 7737 7739 canvas->dispatchEvent(event); 7738 m_ restoreAllowed = event->defaultPrevented();7739 if (m_contextLost Mode == RealLostContext && m_restoreAllowed)7740 m_contextLostState->restoreRequested = event->defaultPrevented(); 7741 if (m_contextLostState->mode == RealLostContext && m_contextLostState->restoreRequested) 7740 7742 m_restoreTimer.startOneShot(0_s); 7741 7743 }); … … 7745 7747 { 7746 7748 RELEASE_ASSERT(!m_isSuspended); 7747 ASSERT(m_contextLost); 7748 if (!m_contextLost) 7749 return; 7750 7751 // The rendering context is not restored unless the default behavior of the 7752 // webglcontextlost event was prevented earlier. 7753 // 7754 // Because of the way m_restoreTimer is set up for real vs. synthetic lost 7755 // context events, we don't have to worry about this test short-circuiting 7756 // the retry loop for real context lost events. 7757 if (!m_restoreAllowed) 7758 return; 7749 if (!isContextLost() || !m_contextLostState->restoreRequested) { 7750 ASSERT_NOT_REACHED(); 7751 return; 7752 } 7759 7753 7760 7754 auto* canvas = htmlCanvas(); … … 7781 7775 RefPtr<GraphicsContextGL> context = hostWindow->createGraphicsContextGL(m_attributes); 7782 7776 if (!context) { 7783 if (m_contextLost Mode == RealLostContext)7777 if (m_contextLostState->mode == RealLostContext) 7784 7778 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); 7785 7779 else 7786 // This likely shouldn't happen but is the best way to report it to the WebGL app. 7787 synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "", "error restoring context"); 7780 printToConsole(MessageLevel::Error, "WebGL: error restoring lost context."); 7788 7781 return; 7789 7782 } … … 7791 7784 setGraphicsContextGL(context.releaseNonNull()); 7792 7785 addActivityStateChangeObserverIfNecessary(); 7793 m_contextLost = false;7786 m_contextLostState = std::nullopt; 7794 7787 setupFlags(); 7795 7788 initializeNewContext(); … … 7873 7866 } // namespace anonymous 7874 7867 7875 void WebGLRenderingContextBase::synthesizeGLError(GCGLenum error, const char* functionName, const char* description, ConsoleDisplayPreference display) 7876 { 7877 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { 7878 String str = "WebGL: " + GetErrorString(error) + ": " + String(functionName) + ": " + String(description); 7879 printToConsole(MessageLevel::Error, str); 7880 } 7868 void WebGLRenderingContextBase::synthesizeGLError(GCGLenum error, const char* functionName, const char* description) 7869 { 7870 printToConsole(MessageLevel::Error, makeString("WebGL: ", GetErrorString(error), ": ", functionName, ": ", description)); 7881 7871 if (m_context) 7882 7872 m_context->synthesizeGLError(error); 7873 } 7874 7875 void WebGLRenderingContextBase::synthesizeLostContextGLError(GCGLenum error, const char* functionName, const char* description) 7876 { 7877 printToConsole(MessageLevel::Error, makeString("WebGL: ", GetErrorString(error), ": ", functionName, ": ", description)); 7878 m_contextLostState->errors.add(error); 7883 7879 } 7884 7880 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h
r291468 r291749 49 49 #include <memory> 50 50 #include <wtf/CheckedArithmetic.h> 51 #include <wtf/ListHashSet.h> 51 52 #include <wtf/Lock.h> 52 53 … … 549 550 void updateActiveOrdinal(); 550 551 552 struct ContextLostState { 553 ContextLostState(LostContextMode mode) 554 : mode(mode) 555 { 556 } 557 ListHashSet<GCGLint> errors; // Losing context and WEBGL_lose_context generates errors here. 558 LostContextMode mode { LostContextMode::RealLostContext }; 559 bool restoreRequested { false }; 560 }; 561 551 562 RefPtr<GraphicsContextGL> m_context; 552 563 RefPtr<WebGLContextGroup> m_contextGroup; 553 564 Lock m_objectGraphLock; 554 565 555 bool m_restoreAllowed { false };556 566 SuspendableTimer m_restoreTimer; 557 567 … … 653 663 GCGLenum m_unpackColorspaceConversion; 654 664 655 bool m_contextLost { false }; 656 LostContextMode m_contextLostMode { SyntheticLostContext }; 665 std::optional<ContextLostState> m_contextLostState; 657 666 WebGLContextAttributes m_attributes; 658 667 … … 1096 1105 1097 1106 // Wrapper for GraphicsContextGLOpenGL::synthesizeGLError that sends a message to the JavaScript console. 1098 enum ConsoleDisplayPreference { DisplayInConsole, DontDisplayInConsole };1099 void synthesize GLError(GCGLenum, const char* functionName, const char* description, ConsoleDisplayPreference = DisplayInConsole);1107 void synthesizeGLError(GCGLenum, const char* functionName, const char* description); 1108 void synthesizeLostContextGLError(GCGLenum, const char* functionName, const char* description); 1100 1109 1101 1110 String ensureNotNull(const String&) const; -
trunk/Source/WebKit/ChangeLog
r291739 r291749 1 2022-03-23 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 After losing context due to too many contexts, getError() does not return CONTEXT_LOST_WEBGL 4 https://bugs.webkit.org/show_bug.cgi?id=236965 5 6 Reviewed by Kenneth Russell. 7 8 Remove recording of synthetic webgl context lost error from the proxy. 9 This is now recorded in the WebGLRenderingContextBase. 10 11 * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp: 12 (WebKit::RemoteGraphicsContextGLProxy::synthesizeGLError): 13 (WebKit::RemoteGraphicsContextGLProxy::getError): 14 * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h: 15 1 16 2022-03-23 Fujii Hironori <Hironori.Fujii@sony.com> 2 17 -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp
r291468 r291749 216 216 return; 217 217 } 218 m_errorWhenContextIsLost = error;219 218 } 220 219 … … 228 227 return static_cast<GCGLenum>(returnValue); 229 228 } 230 return std::exchange(m_errorWhenContextIsLost, NO_ERROR);229 return NO_ERROR; 231 230 } 232 231 -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h
r291477 r291749 367 367 368 368 HashSet<String> m_enabledExtensions; 369 GCGLenum m_errorWhenContextIsLost = NO_ERROR;370 369 IPC::StreamClientConnection m_streamConnection; 371 370 };
Note:
See TracChangeset
for help on using the changeset viewer.