WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-236965-20220317210136.patch (text/plain), 33.17 KB, created by
Kimmo Kinnunen
on 2022-03-17 12:01:38 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Kimmo Kinnunen
Created:
2022-03-17 12:01:38 PDT
Size:
33.17 KB
patch
obsolete
>Subversion Revision: 291407 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0c3c3a9998cd32cd3d50daa446a68d1fb04a53d8..f0987d61f7f1a9ab6954052b448b3e1b7f75cd31 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,51 @@ >+2022-03-17 Kimmo Kinnunen <kkinnunen@apple.com> >+ >+ Recycling a webgl context when it has been lost and restored causes a crash >+ https://bugs.webkit.org/show_bug.cgi?id=238024 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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: >+ > 2022-03-17 Oriol Brufau <obrufau@igalia.com> > > Clarify code for logical-to-physical mappings, and add physical-to-logical mappings >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 15a35377b2ef6816f7e072f0d8f938c1d7fe8654..5dd2dfe118bd30367f7e6f3d75c3f9a368f78e48 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,22 @@ >+2022-03-17 Kimmo Kinnunen <kkinnunen@apple.com> >+ >+ Recycling a webgl context when it has been lost and restored causes a crash >+ https://bugs.webkit.org/show_bug.cgi?id=238024 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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: >+ > 2022-03-17 Nikolas Zimmermann <nzimmermann@igalia.com> > > Build broken on macOS Monterey 12.3 - PassKitSPI related error >diff --git a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >index 01543b5e90f6fc23e96dbfaa402a78563b921b65..8f09945f1de4c1f135c14381f669ae15cc5b7ced 100644 >--- a/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >+++ b/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp >@@ -6452,16 +6452,6 @@ void WebGLRenderingContextBase::loseContextImpl(WebGLRenderingContextBase::LostC > m_contextLost = true; > m_contextLostMode = mode; > >- if (mode == RealLostContext) { >- // Inform the embedder that a lost context was received. In response, the embedder might >- // decide to take action such as asking the user for permission to use WebGL again. >- auto* canvas = htmlCanvas(); >- if (canvas) { >- if (RefPtr<Frame> frame = canvas->document().frame()) >- frame->loader().client().didLoseWebGLContext(m_context->getGraphicsResetStatusARB()); >- } >- } >- > detachAndRemoveAllObjects(); > loseExtensions(mode); > >@@ -7771,33 +7761,6 @@ void WebGLRenderingContextBase::maybeRestoreContext() > if (!m_restoreAllowed) > return; > >- int contextLostReason = m_context->getGraphicsResetStatusARB(); >- >- switch (contextLostReason) { >- case GraphicsContextGL::NO_ERROR: >- // The GraphicsContextGLOpenGL implementation might not fully >- // support GL_ARB_robustness semantics yet. Alternatively, the >- // WEBGL_lose_context extension might have been used to force >- // a lost context. >- break; >- case GraphicsContextGL::GUILTY_CONTEXT_RESET_ARB: >- // The rendering context is not restored if this context was >- // guilty of causing the graphics reset. >- printToConsole(MessageLevel::Warning, "WARNING: WebGL content on the page caused the graphics card to reset; not restoring the context"); >- return; >- case GraphicsContextGL::INNOCENT_CONTEXT_RESET_ARB: >- // Always allow the context to be restored. >- break; >- case GraphicsContextGL::UNKNOWN_CONTEXT_RESET_ARB: >- // Warn. Ideally, prompt the user telling them that WebGL >- // content on the page might have caused the graphics card to >- // reset and ask them whether they want to continue running >- // the content. Only if they say "yes" should we start >- // attempting to restore the context. >- printToConsole(MessageLevel::Warning, "WARNING: WebGL content on the page might have caused the graphics card to reset"); >- break; >- } >- > auto* canvas = htmlCanvas(); > if (!canvas) > return; >diff --git a/Source/WebCore/loader/FrameLoaderClient.h b/Source/WebCore/loader/FrameLoaderClient.h >index 79435a3ac24756f7f9d94a5926c2016e91167228..45f5522b486ed24fe1df07982c1f750829bd65a8 100644 >--- a/Source/WebCore/loader/FrameLoaderClient.h >+++ b/Source/WebCore/loader/FrameLoaderClient.h >@@ -340,9 +340,6 @@ public: > > #if ENABLE(WEBGL) > virtual bool allowWebGL(bool enabledPerSettings) { return enabledPerSettings; } >- // Informs the embedder that a WebGL canvas inside this frame received a lost context >- // notification with the given GL_ARB_robustness guilt/innocence code (see GraphicsContextGL.h). >- virtual void didLoseWebGLContext(int) { } > virtual WebGLLoadPolicy webGLPolicyForURL(const URL&) const { return WebGLLoadPolicy::WebGLAllowCreation; } > virtual WebGLLoadPolicy resolveWebGLPolicyForURL(const URL&) const { return WebGLLoadPolicy::WebGLAllowCreation; } > #endif >diff --git a/Source/WebCore/platform/graphics/GraphicsContextGL.h b/Source/WebCore/platform/graphics/GraphicsContextGL.h >index 322091365e0fc6d1b3655e6ecb9d888286287302..7dee66eccdf6417f8b74960fcd1aab6b984740bd 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContextGL.h >+++ b/Source/WebCore/platform/graphics/GraphicsContextGL.h >@@ -1375,15 +1375,6 @@ public: > // Has no other side-effects. > virtual bool isExtensionEnabled(const String&) = 0; > >- // GL_ARB_robustness >- // Note: This method's behavior differs from the GL_ARB_robustness >- // specification in the following way: >- // The implementation must not reset the error state during this call. >- // If getGraphicsResetStatusARB returns an error, it should continue >- // returning the same error. Restoring the GraphicsContextGLOpenGL is handled >- // externally. >- virtual GCGLint getGraphicsResetStatusARB() = 0; >- > // GL_ANGLE_translated_shader_source > virtual String getTranslatedShaderSourceANGLE(PlatformGLObject) = 0; > >diff --git a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp b/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp >index 67fbc44febdaf63e9d28a085e3cfd52f1a828dfe..63f5d396a5c37bbf1d7138aa6f6e207265fc380c 100644 >--- a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp >+++ b/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp >@@ -2923,11 +2923,6 @@ bool GraphicsContextGLANGLE::isExtensionEnabled(const String& name) > return m_availableExtensions.contains(name) || m_enabledExtensions.contains(name); > } > >-GLint GraphicsContextGLANGLE::getGraphicsResetStatusARB() >-{ >- return GraphicsContextGL::NO_ERROR; >-} >- > String GraphicsContextGLANGLE::getTranslatedShaderSourceANGLE(PlatformGLObject shader) > { > if (!makeContextCurrent()) >diff --git a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h b/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h >index f4dc87db52e0e29700a207793511ae0ae956a22d..be104c557a6b7fef0835b998b435ed465881e593 100644 >--- a/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h >+++ b/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.h >@@ -329,7 +329,6 @@ public: > bool supportsExtension(const String&) override; > void ensureExtensionEnabled(const String&) override; > bool isExtensionEnabled(const String&) override; >- GCGLint getGraphicsResetStatusARB() override; > void drawBuffersEXT(GCGLSpan<const GCGLenum>) override; > String getTranslatedShaderSourceANGLE(PlatformGLObject) override; > >diff --git a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp >index 21e829fbd101df6d469316f9d29ced86b4ac9606..489699c4ee3cf409a43757afef7a465e34cdfabd 100644 >--- a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp >+++ b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.cpp >@@ -159,11 +159,6 @@ bool ExtensionsGLOpenGLCommon::isEnabled(const String& name) > return supports(name); > } > >-int ExtensionsGLOpenGLCommon::getGraphicsResetStatusARB() >-{ >- return GraphicsContextGL::NO_ERROR; >-} >- > String ExtensionsGLOpenGLCommon::getTranslatedShaderSourceANGLE(PlatformGLObject shader) > { > ASSERT(shader); >diff --git a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.h b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.h >index 2c37fac965c0216da05ac5fb8eaaeb683d44a7e6..b7406c49706c603e6a39babe1e23c93c10b20797 100644 >--- a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.h >+++ b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLCommon.h >@@ -43,7 +43,6 @@ public: > virtual bool supports(const String&); > virtual void ensureEnabled(const String&); > virtual bool isEnabled(const String&); >- virtual int getGraphicsResetStatusARB(); > virtual String getTranslatedShaderSourceANGLE(PlatformGLObject); > virtual void drawBuffersEXT(GCGLSpan<const GCGLenum> bufs) = 0; > >@@ -57,7 +56,7 @@ public: > virtual void drawElementsInstancedANGLE(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLvoidptr offset, GCGLsizei primcount) = 0; > virtual void vertexAttribDivisorANGLE(GCGLuint index, GCGLuint divisor) = 0; > >- // EXT Robustness - uses getGraphicsResetStatusARB() >+ // EXT Robustness > virtual void readnPixelsEXT(int x, int y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, void *data); > virtual void getnUniformfvEXT(GCGLuint program, int location, GCGLsizei bufSize, float *params); > virtual void getnUniformivEXT(GCGLuint program, int location, GCGLsizei bufSize, int *params); >diff --git a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.cpp >index 997e79ee5d4c17e2120bb3df4e02550260a4c38f..54b1700150950e1db6472cccab1aa9c9568e2a73 100644 >--- a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.cpp >+++ b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.cpp >@@ -166,26 +166,6 @@ void ExtensionsGLOpenGLES::drawBuffersEXT(GCGLSpan<const GCGLenum> /* bufs */) > notImplemented(); > } > >-int ExtensionsGLOpenGLES::getGraphicsResetStatusARB() >-{ >- // FIXME: This does not call getGraphicsResetStatusARB, but instead getGraphicsResetStatusEXT. >- // The return codes from the two extensions are identical and their purpose is the same, so it >- // may be best to rename getGraphicsResetStatusARB() to getGraphicsResetStatus(). >- if (m_contextResetStatus != GL_NO_ERROR) >- return m_contextResetStatus; >- if (m_glGetGraphicsResetStatusEXT) { >- int reasonForReset = GraphicsContextGL::UNKNOWN_CONTEXT_RESET_ARB; >- if (m_context->makeContextCurrent()) >- reasonForReset = m_glGetGraphicsResetStatusEXT(); >- if (reasonForReset != GL_NO_ERROR) >- m_contextResetStatus = reasonForReset; >- return reasonForReset; >- } >- >- m_context->synthesizeGLError(GL_INVALID_OPERATION); >- return false; >-} >- > void ExtensionsGLOpenGLES::readnPixelsEXT(int x, int y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, void *data) > { > if (m_glReadnPixelsEXT) { >diff --git a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.h b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.h >index 9bb52f9baaacb5716c4d02b9b5bf791a78f750e1..1d85664deeee9409973a0c442cf545f045db7ef5 100644 >--- a/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.h >+++ b/Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.h >@@ -98,9 +98,6 @@ public: > void drawElementsInstancedANGLE(GCGLenum mode, GCGLsizei count, GCGLenum type, GCGLvoidptr offset, GCGLsizei primcount) override; > void vertexAttribDivisorANGLE(GCGLuint index, GCGLuint divisor) override; > >- // EXT Robustness - reset >- int getGraphicsResetStatusARB() override; >- > // EXT Robustness - etc > void readnPixelsEXT(int x, int y, GCGLsizei width, GCGLsizei height, GCGLenum format, GCGLenum type, GCGLsizei bufSize, void *data) override; > void getnUniformfvEXT(GCGLuint program, int location, GCGLsizei bufSize, float *params) override; >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp >index 363e9617706d8f1d84d9d79c92dd9e01d01973cb..4a9e8fae037eef40ded9f2ceaf872fa158a43afb 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp >@@ -3070,11 +3070,6 @@ bool GraphicsContextGLOpenGL::isExtensionEnabled(const String& name) > return getExtensions().isEnabled(name); > } > >-GLint GraphicsContextGLOpenGL::getGraphicsResetStatusARB() >-{ >- return getExtensions().getGraphicsResetStatusARB(); >-} >- > void GraphicsContextGLOpenGL::drawBuffersEXT(GCGLSpan<const GCGLenum> buffers) > { > return getExtensions().drawBuffersEXT(buffers); >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h >index e8997b2e5043f63762015eb152292788c3596526..53e1d1d4baeff8dd268b982674979c6d9f59310a 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h >@@ -372,7 +372,6 @@ public: > bool supportsExtension(const String&) final; > void ensureExtensionEnabled(const String&) final; > bool isExtensionEnabled(const String&) final; >- GLint getGraphicsResetStatusARB() final; > void drawBuffersEXT(GCGLSpan<const GCGLenum>) override; > String getTranslatedShaderSourceANGLE(PlatformGLObject) final; > >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in b/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in >index 6cc8a50850d2c0b47145bea3db44fe1c6749781b..3f4e54be27baf8e9e7d95c475bb4be8459007efc 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in >+++ b/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in >@@ -284,7 +284,6 @@ messages -> RemoteGraphicsContextGL NotRefCounted Stream { > void GetActiveUniformBlockName(uint32_t program, uint32_t uniformBlockIndex) -> (String returnValue) Synchronous > void UniformBlockBinding(uint32_t program, uint32_t uniformBlockIndex, uint32_t uniformBlockBinding) > void GetActiveUniformBlockiv(uint32_t program, uint32_t uniformBlockIndex, uint32_t pname, uint64_t paramsSize) -> (IPC::ArrayReference<int32_t> params) Synchronous >- void GetGraphicsResetStatusARB() -> (int32_t returnValue) Synchronous > void GetTranslatedShaderSourceANGLE(uint32_t arg0) -> (String returnValue) Synchronous > void DrawBuffersEXT(IPC::ArrayReference<uint32_t> bufs) > void GetInternalformativ(uint32_t target, uint32_t internalformat, uint32_t pname, uint64_t paramsSize) -> (IPC::ArrayReference<int32_t> params) Synchronous >diff --git a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h b/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h >index 4a53f88736f8e0c9e9d9d38001ffed352977cd81..10ee924f04506a8acad3524b2b114d9c0a88a32b 100644 >--- a/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h >+++ b/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h >@@ -1321,13 +1321,6 @@ > m_context->getActiveUniformBlockiv(program, uniformBlockIndex, pname, params); > completionHandler(IPC::ArrayReference<int32_t>(reinterpret_cast<int32_t*>(params.data()), params.size())); > } >- void getGraphicsResetStatusARB(CompletionHandler<void(int32_t)>&& completionHandler) >- { >- GCGLint returnValue = { }; >- assertIsCurrent(workQueue()); >- returnValue = m_context->getGraphicsResetStatusARB(); >- completionHandler(returnValue); >- } > void getTranslatedShaderSourceANGLE(uint32_t arg0, CompletionHandler<void(String&&)>&& completionHandler) > { > String returnValue = { }; >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h b/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h >index f0b8ca98f90b316ffd05d39b38e82b13cbbc468d..74fe17bfa4cc61fc7f4226971663211f7adcf3bc 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h >@@ -314,7 +314,6 @@ public: > String getActiveUniformBlockName(PlatformGLObject program, GCGLuint uniformBlockIndex) final; > void uniformBlockBinding(PlatformGLObject program, GCGLuint uniformBlockIndex, GCGLuint uniformBlockBinding) final; > void getActiveUniformBlockiv(GCGLuint program, GCGLuint uniformBlockIndex, GCGLenum pname, GCGLSpan<GCGLint> params) final; >- GCGLint getGraphicsResetStatusARB() final; > String getTranslatedShaderSourceANGLE(PlatformGLObject arg0) final; > void drawBuffersEXT(GCGLSpan<const GCGLenum> bufs) final; > void getInternalformativ(GCGLenum target, GCGLenum internalformat, GCGLenum pname, GCGLSpan<GCGLint> params) final; >diff --git a/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp b/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp >index 1f29606fbb38354e0875e85e73dc686b53918ebe..431adc939adc236ac772659da54433a322d33d30 100644 >--- a/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp >+++ b/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp >@@ -2267,17 +2267,6 @@ void RemoteGraphicsContextGLProxy::getActiveUniformBlockiv(GCGLuint program, GCG > } > } > >-GCGLint RemoteGraphicsContextGLProxy::getGraphicsResetStatusARB() >-{ >- int32_t returnValue = { }; >- if (!isContextLost()) { >- auto sendResult = sendSync(Messages::RemoteGraphicsContextGL::GetGraphicsResetStatusARB(), Messages::RemoteGraphicsContextGL::GetGraphicsResetStatusARB::Reply(returnValue)); >- if (!sendResult) >- markContextLost(); >- } >- return returnValue; >-} >- > String RemoteGraphicsContextGLProxy::getTranslatedShaderSourceANGLE(PlatformGLObject arg0) > { > String returnValue = { }; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 8bbcc6dd1827ff8c147bcdf80bdc138e58af7a56..b517577efa6470102270e375b61bd5b9dd51e909 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,40 @@ >+2022-03-17 Kimmo Kinnunen <kkinnunen@apple.com> >+ >+ Recycling a webgl context when it has been lost and restored causes a crash >+ https://bugs.webkit.org/show_bug.cgi?id=238024 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 : >+ http://webkit.org/b/236965 >+ >+ FAIL Expected restore be ignored, but it was not. >+ http://webkit.org/b/238034 >+ >+ * webgl/max-active-contexts-webglcontextlost-prevent-default.html: >+ > 2022-03-17 Andres Gonzalez <andresg_22@apple.com> > > Fix for accessibility/aria-tab-xxx.html tests in isolated tree mode. >diff --git a/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt b/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt >index 714a8be226ed5c59fcf9d68e1fb432b77aa10396..c93dcc9d12d2d22b3734384a5968e60430c275e0 100644 >--- a/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt >+++ b/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default-expected.txt >@@ -1,2 +1,73 @@ >-CONSOLE MESSAGE: There are too many active WebGL contexts on this page, the oldest context will be lost. >-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. >+Test that first losing context, trying to restore it, and then doing something to really lose it does not crash. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+TEST COMPLETE: 42 PASS, 10 FAIL >+ >+Running test: loseMethod: loseContext, loseMethod2: loseContext >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+PASS getError was expected value: INVALID_OPERATION : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: loseContext, loseMethod2: manyContexts >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: loseContext, loseMethod2: gpuStatusFailure >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: loseContext, loseMethod2: nothing >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: manyContexts, loseMethod2: loseContext >+PASS Got webglcontextlost and restore was attempted. >+FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR : >+FAIL getError expected: INVALID_OPERATION. Was NO_ERROR : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: manyContexts, loseMethod2: manyContexts >+PASS Got webglcontextlost and restore was attempted. >+FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: manyContexts, loseMethod2: gpuStatusFailure >+PASS Got webglcontextlost and restore was attempted. >+FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: manyContexts, loseMethod2: nothing >+PASS Got webglcontextlost and restore was attempted. >+FAIL getError expected: CONTEXT_LOST_WEBGL. Was NO_ERROR : >+PASS gl.isContextLost() is true >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: gpuStatusFailure, loseMethod2: loseContext >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+FAIL getError expected: INVALID_OPERATION. Was NO_ERROR : >+FAIL Expected restore be ignored, but it was not. >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: gpuStatusFailure, loseMethod2: manyContexts >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+FAIL Expected restore be ignored, but it was not. >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: gpuStatusFailure, loseMethod2: gpuStatusFailure >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+FAIL Expected restore be ignored, but it was not. >+PASS getError was expected value: NO_ERROR : >+Running test: loseMethod: gpuStatusFailure, loseMethod2: nothing >+PASS Got webglcontextlost and restore was attempted. >+PASS getError was expected value: CONTEXT_LOST_WEBGL : >+FAIL Expected restore be ignored, but it was not. >+PASS getError was expected value: NO_ERROR : >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default.html b/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default.html >index 36847a9344954540dcfd49d96a352cb19b863333..b3a2126ecaddca4afcbcca16bb5e7d425345b732 100644 >--- a/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default.html >+++ b/LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default.html >@@ -1,21 +1,152 @@ >-<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> >+<!DOCTYPE html> >+<html> >+<head> >+<meta charset="utf-8"> >+<link rel="stylesheet" href="resources/webgl_test_files/resources/js-test-style.css"/> >+<script src="resources/webgl_test_files/js/js-test-pre.js"></script> >+<script src="resources/webgl_test_files/js/webgl-test-utils.js"></script> >+</head> >+<body onload="test()"> >+<div id="description"></div> >+<div id="console"></div> > <script> >-if (window.testRunner) { >- testRunner.waitUntilDone(); >- testRunner.dumpAsText(); >-} >- >-var maxNumberOfActiveContexts = 16; >-var contexts = []; >-for (var i = 0; i <= maxNumberOfActiveContexts; i++) { >- var canvas = document.createElement("canvas"); >- canvas.addEventListener("webglcontextlost", function(event) { >- event.preventDefault(); >- if (!contexts[0].isContextLost()) >- document.getElementById("result").textContent = "FAIL"; >- if (window.testRunner) >- testRunner.notifyDone(); >+"use strict"; >+description("Test that first losing context, trying to restore it, and then doing something to really lose it does not crash."); >+ >+// The test would crash with following sequence: >+// 1. Cause a real context lost. In this test, "gpuStatusFailure". >+// 2. Page would try to restore the context. This would start the restore timer. >+// 3. Before the restore timer fires, really lose the context. In this test, "manyContext". >+// 4. The restore timer would fire, and restore function would use nullptr context. >+ >+var wtu = WebGLTestUtils; >+var gl; >+ >+async function waitForEvent(element, eventName, timeoutMS) >+{ >+ timeoutMS = timeoutMS || 2000; >+ return new Promise((resolve, reject) => { >+ function timeoutHandler() { >+ element.removeEventListener(eventName, handler, { once: true }); >+ reject(); >+ } >+ const rejectID = setTimeout(timeoutHandler, timeoutMS); >+ function handler(event) { >+ clearTimeout(rejectID); >+ resolve(event); >+ } >+ element.addEventListener(eventName, handler, { once: true }); > }); >- contexts[i] = canvas.getContext("webgl"); >+} >+ >+async function waitForWebGLContextRestored(canvas, timeoutMS) >+{ >+ await waitForEvent(canvas, "webglcontextrestored", timeoutMS); >+} >+ >+async function waitForWebGLContextLostAndRestore(canvas, timeoutMS) >+{ >+ let event = await waitForEvent(canvas, "webglcontextlost", timeoutMS); >+ event.preventDefault(); >+} >+ >+function testDescription(subcase) { >+ return Object.keys(subcase).map((k) => `${k}: ${typeof subcase[k] === "function" ? subcase[k].name : subcase[k]}`).join(", "); >+} >+ >+async function runTest(subcase) >+{ >+ debug(`Running test: ${testDescription(subcase)}`); >+ >+ const canvas = document.createElement("canvas"); >+ canvas.width = 1; >+ canvas.height = 1; >+ gl = wtu.create3DContext(canvas); >+ const WEBGL_lose_context = wtu.getExtensionWithKnownPrefixes(gl, "WEBGL_lose_context"); >+ >+ const webglcontextlostandrestore = waitForWebGLContextLostAndRestore(canvas); >+ const webglcontextrestored = waitForWebGLContextRestored(canvas); >+ let expectRestoreIgnored = subcase.loseMethod(gl, WEBGL_lose_context); >+ >+ try { >+ await webglcontextlostandrestore; >+ testPassed("Got webglcontextlost and restore was attempted."); >+ wtu.glErrorShouldBe(gl, gl.CONTEXT_LOST_WEBGL); >+ } catch (e) { >+ if (e) >+ throw e; >+ testFailed("Timed out waiting webglcontextlost that would attempt to be restored."); >+ } >+ expectRestoreIgnored = subcase.loseMethod2(gl, WEBGL_lose_context) || expectRestoreIgnored; >+ >+ try { >+ await webglcontextrestored; >+ if (expectRestoreIgnored) >+ testFailed("Expected restore be ignored, but it was not."); >+ else >+ shouldBeFalse("gl.isContextLost()"); >+ } catch (e) { >+ if (e) >+ throw e; >+ if (!expectRestoreIgnored) >+ testFailed("Did not expect restore be ignored, but it was."); >+ else >+ shouldBeTrue("gl.isContextLost()"); >+ } >+ >+ wtu.glErrorShouldBe(gl, gl.NO_ERROR); >+} >+ >+function loseContext(gl, WEBGL_lose_context) >+{ >+ if (!WEBGL_lose_context) { >+ testFailed("Could not find WEBGL_lose_context extension"); >+ return; >+ } >+ let wasLost = gl.isContextLost(); >+ WEBGL_lose_context.loseContext(); >+ if (wasLost) >+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION); >+ return true; // Request for restore is ignored. >+} >+ >+function manyContexts() >+{ >+ // This causes the older contexts to be lost, including the first one we created >+ // for testing. >+ const contexts = [] >+ for (let i = 0; i < 50; ++i) >+ contexts.push(document.createElement("canvas").getContext("webgl")); >+ return true; // Request for restore is ignored. >+} >+ >+function gpuStatusFailure(gl) >+{ >+ internals.simulateEventForWebGLContext("GPUStatusFailure", gl); >+ gl.clear(gl.COLOR_BUFFER_BIT); >+ return true; // Request for restore is honored. >+} >+ >+function nothing() >+{ >+ return false; >+} >+ >+const loseMethods = [loseContext, manyContexts]; >+if (window.internals) >+ loseMethods.push(gpuStatusFailure); >+ >+const subcases = []; >+for (const loseMethod of loseMethods) >+ for (const loseMethod2 of loseMethods.concat(nothing)) >+ subcases.push({loseMethod, loseMethod2}); >+ >+async function test() >+{ >+ for (let subcase of subcases) >+ await runTest(subcase); >+ finishTest(); > } > </script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 236965
:
454999
|
455371
|
455373