Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: GLctx is undefined #2112

Open
Ycblue opened this issue May 16, 2019 · 4 comments
Open

TypeError: GLctx is undefined #2112

Ycblue opened this issue May 16, 2019 · 4 comments

Comments

@Ycblue
Copy link

Ycblue commented May 16, 2019

Hi, I'm fairly new at WASM and WebGL and I have been trying to run the shader tutorial from DanRuta (https://github.com/DanRuta/webassembly-webgl-shaders) and my browser always runs into this error when running the index.html file.
The details of the error look like this:
`TypeError: GLctx is undefined[Weitere Informationen] appWASM.js:1:250880

_glCreateProgram http://localhost:8080/dist/appWASM.js:1

<anonym> http://localhost:8080/dist/appWASM.wasm:251208

<anonym> http://localhost:8080/dist/appWASM.wasm:251921

_createContext http://localhost:8080/dist/appWASM.js:1

ccall http://localhost:8080/dist/appWASM.js:1

createCanvas http://localhost:8080/:25

loadImage http://localhost:8080/:45`

I gather that there is some type error going on in the generated js file, but i'm really not familiar with it. Do you have any idea what could have caused this error?

Edit:
The build command I used was:
emcc -o ./dist/appWASM.js ./dev/cpp/emscripten.cpp -O3 -s ALLOW_MEMORY_GROWTH=1 -s USE_WEBGL2=1 -s WASM=1 -s NO_EXIT_RUNTIME=1 -std=c++1z -s EXTRA_EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" -s LINKABLE=1 -s EXPORT_ALL=1

@kripken
Copy link
Member

kripken commented May 16, 2019

Try building without optimizations, or with adding -s ASSERTIONS=1 - those assertions may help find a problem.

Otherwise, I'd build with --profiling and investigate that JS to see what's going on there.

@Ycblue
Copy link
Author

Ycblue commented May 17, 2019

Hi, thanks for the fast reply!
I've tried it with optimizations off and with assertions, but the same problem still pops up!
I'm currently figuring out what I can find through profiling and hope that it can give me some insights.
Are there any other ways I could go about and find a solution?

Meanwhile, another different thing happened earlier with the same code. After the WASM and JS files were built, I had to manually correct an IF-clause in the JS file. Since it is generated automatically with glue code, I assume it has to be a bug of some kind?

@kripken
Copy link
Member

kripken commented May 17, 2019

Sounds like that could be a bug, yes.

If you can't figure it out, if you can provide a testcase showing the problems that should be enough for us to debug them.

@nazure
Copy link

nazure commented Nov 29, 2020

I encountered the same error and needed to make a minor change to the tutorial code.

emscripten_webgl_create_context() (in the tutorial's Context.cpp) failed to find the Canvas by id.
And this is due to HTML5 selectors requiring a '#' in front when querying by id.

I fixed the code in Context::Context() to append a '#' in front of the id before calling emscripten_webgl_create_context().

You could also compile with DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 which uses the old getElementById() method instead of querySelector(). Though this is not recommended and will generate a console warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants