Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/lib/libhtml5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,8 @@ var LibraryHtml5WebGL = {
if (!a) return {{{ cDefs.EMSCRIPTEN_RESULT_INVALID_PARAM }}};
c = GL.contexts[c];
if (!c) return {{{ cDefs.EMSCRIPTEN_RESULT_INVALID_TARGET }}};
var t = c.GLctx;
var t = c.GLctx?.getContextAttributes();
if (!t) return {{{ cDefs.EMSCRIPTEN_RESULT_INVALID_TARGET }}};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

var t = c.GLctx?.getContextAttributes();
if (!t) return {{{ cDefs.EMSCRIPTEN_RESULT_INVALID_TARGET }}};

?

Although do note that if the GL context is lost, then all subsequent GL calls will fail as well. So if you have a code path that can somehow recover (if it is an iOS 26.1 internal bug, one might not exist), you will need to call emscripten_is_webgl_context_lost() or register to emscripten_set_webglcontextlost_callback() to be notified of a context loss, to do something else.

I.e. the issue will likely not be isolated to this function, but all subsequent GL operations will fail as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, that is a blind fix for a runtime exception. The fact that the context is not usable any more is out of scope.

The refactoring suggestion imposes another minimal ECMAScript version. I am not that familiar with the project and its application, but the code around suggests ES6-level of coding about when WebAssembly got first introduced. Optional chaining is ES2020.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emscripten project uses Babel to transpile to older ES standards. Using ?. is ok here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then following your advice.

t = t.getContextAttributes();

{{{ makeSetValue('a', C_STRUCTS.EmscriptenWebGLContextAttributes.alpha, 't.alpha', 'i8') }}};
{{{ makeSetValue('a', C_STRUCTS.EmscriptenWebGLContextAttributes.depth, 't.depth', 'i8') }}};
Expand Down