From ffc7717149f93af32da3b1169a57281d6255decc Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Wed, 28 May 2025 21:54:03 +0800 Subject: [PATCH] (web) add explicit check for failure to create context --- thermion_dart/native/web/src/cpp/ThermionWebApi.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/thermion_dart/native/web/src/cpp/ThermionWebApi.cpp b/thermion_dart/native/web/src/cpp/ThermionWebApi.cpp index 6530a631..9d139410 100644 --- a/thermion_dart/native/web/src/cpp/ThermionWebApi.cpp +++ b/thermion_dart/native/web/src/cpp/ThermionWebApi.cpp @@ -44,6 +44,11 @@ extern "C" attr.majorVersion = 2; auto context = emscripten_webgl_create_context("#thermion_canvas", &attr); + + if(!context) { + std::cout << "Failed to create WebGL context" << std::endl; + return context; + } std::cout << "Created WebGL context " << attr.majorVersion << "." << attr.minorVersion << std::endl;