Skip to content

Cannot read properties of undefined (reading 'getParameter') since 3.1.70 (WebGL) #22889

@FloRecisio

Description

@FloRecisio

Hello! Since the version 3.1.70, we have an error at runtime when starting our application using Emscripten and Electron. It worked fine in 3.1.69, I tried to find a commit related to our problem but couldn't find it, so maybe you'll have an idea.
Here is the diff : https://github.com/emscripten-core/emscripten/compare/0486179..12cedf4
If needed, I could test each commit dicotomically, but that would take a lot of time.
The problem is still here in the latest tot version.

Version of emscripten/emsdk with the problem (first and latest):

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.70 (b53978ee3f540dc74761eba127aa7f1b8761a125)
clang version 20.0.0git (https:/github.com/llvm/llvm-project f52b89561f2d929c0c6f37fd818229fbcad3b26c)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\git\emsdk\upstream\bin

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.72-git (ffeb76137e765a0023de2635420a4827ca15106d)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 31af00fda73df8e85e30c71f66e096d486ec8c8b)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\git\emsdk\upstream\bin
Build config: +assertions

The error is :

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getParameter')
    at emscriptenWebGLGet (MyProject.js:10167:24)
    at _glGetIntegerv (MyProject.js:10295:66)
    at imports.<computed> (MyProject.js:6825:20)
    at MyProject.wasm._do_call (MyProject.wasm:0x2b87f34)
    at MyProject.wasm.em_task_queue_execute (MyProject.wasm:0x2b82a89)
    at MyProject.wasm.receive_notification (MyProject.wasm:0x2b83a15)
    at MyProject.wasm.em_task_queue_execute (MyProject.wasm:0x2b82a89)
    at MyProject.wasm._emscripten_check_mailbox (MyProject.wasm:0x2b9df0c)
    at ret.<computed> (MyProject.js:6851:20)
    at MyProject.js:1078:12

The generated js :

   case 33307:
   // GL_MAJOR_VERSION
    case 33308:
    // GL_MINOR_VERSION
    if (GL.currentContext.version < 2) {
      GL.recordError(1280);
      // GL_INVALID_ENUM
      return;
    }
    ret = name_ == 33307 ? 3 : 0;
    // return version 3.0
    break;
  }
  if (ret === undefined) {
    var result = GLctx.getParameter(name_);               <==== getParameter is undefined 
    switch (typeof result) {
     case "number":
      ret = result;
      break;

     case "boolean":
      ret = result ? 1 : 0;
      break;

Some command

target_compile_options(MyProject
    PUBLIC
        -g
        -fdebug-compilation-dir='${PROJECT_SOURCE_DIR}/src'
        -fexceptions
        -flto
)

target_link_options(MyProject
    PUBLIC
        -lembind
        --no-heap-copy
        --preload-file=${CMAKE_BINARY_DIR}/assets.zip@assets.zip
        -pthread
        -fexceptions

        -sSTRICT=1

        -sNO_EXIT_RUNTIME=1
        -sALLOW_MEMORY_GROWTH=1

        -sABORTING_MALLOC=0

        -sASSERTIONS=1
        -g

        -sEXPORT_ALL=1
        -sAUTO_JS_LIBRARIES=1
        -sAUTO_NATIVE_LIBRARIES=1
        -sFETCH=1

        -sWASM=1

        -sPTHREAD_POOL_SIZE=10
        -sEXPORTED_RUNTIME_METHODS=ccall,UTF8ToString,HEAPU32,HEAPF32
        -sINCOMING_MODULE_JS_API=locateFile,preRun,print,printErr,wasmMemory,buffer,instantiateWasm,wasm,onAbort

        -sAUDIO_WORKLET=1
        -sWASM_WORKERS=1
        -sASYNCIFY

        -sOFFSCREEN_FRAMEBUFFER=1
        -sOFFSCREENCANVAS_SUPPORT=1

        -sTEXTDECODER=0
)

Thanks for your help :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions