From f1576160d78bdad2ed73377d16ebd5a67233f42a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 12 Jul 2022 13:58:29 +0200 Subject: [PATCH] LibWeb: Don't crash when failing to create WebGL context on non-Serenity This makes Ladybird stop panicking on websites that try to use WebGL. --- .../Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp index 332edc1969..58416155cf 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp @@ -41,10 +41,17 @@ JS::ThrowCompletionOr> WebGLRenderingContext::crea return RefPtr { nullptr }; } +#ifndef __serenity__ + // FIXME: Make WebGL work on other platforms. + (void)context_attributes; + dbgln("FIXME: WebGL not supported on the current platform"); + fire_webgl_context_creation_error(canvas_element); + return RefPtr { nullptr }; +#else // FIXME: LibGL currently doesn't propagate context creation errors. auto context = GL::create_context(*canvas_element.bitmap()); - return adopt_ref(*new WebGLRenderingContext(canvas_element, move(context), context_attributes, context_attributes)); +#endif } }