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

glGetVertexAttribiv throws TypeError when using closure #7472

Closed
ILikeBigBoots opened this issue Nov 8, 2018 · 5 comments
Closed

glGetVertexAttribiv throws TypeError when using closure #7472

ILikeBigBoots opened this issue Nov 8, 2018 · 5 comments

Comments

@ILikeBigBoots
Copy link

Hey there,

I'm getting 2 exceptions when using glGetVertexAttribiv to check for GL_VERTEX_ATTRIB_ARRAY_ENABLED.

The issue is in this part. Commenting it out makes everything work like a charm.

GLint enabled;
glGetVertexAttribiv(0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);

I noticed the issue is in the wasm build as well. Not using closure solves this issue.

Exceptions:

exception thrown: TypeError: Math.o is not a function,TypeError: Math.o is not a function
    at Fb (http://localhost:8000/01_hello_triangle/hello_triangle.js:42:237)
    at _glGetVertexAttribiv (http://localhost:8000/01_hello_triangle/hello_triangle.js:56:80)
    at Va (http://localhost:8000/01_hello_triangle/hello_triangle.js:62:30663)
    at Object.d.callMain (http://localhost:8000/01_hello_triangle/hello_triangle.js:74:176)
    at b (http://localhost:8000/01_hello_triangle/hello_triangle.js:75:157)
    at http://localhost:8000/01_hello_triangle/hello_triangle.js:76:4
printErr @ hello_triangle.html:101
d.callMain @ hello_triangle.js:74
b @ hello_triangle.js:75
(anonymous) @ hello_triangle.js:76
setTimeout (async)
Qb @ hello_triangle.js:75
Pb @ hello_triangle.js:73
Mb @ hello_triangle.js:72
Ob @ hello_triangle.js:72
setTimeout (async)
(anonymous) @ hello_triangle.js:72

and

Uncaught TypeError: Math.o is not a function
    at Fb (hello_triangle.js:42)
    at _glGetVertexAttribiv (hello_triangle.js:56)
    at Va (hello_triangle.js:62)
    at Object.d.callMain (hello_triangle.js:74)
    at b (hello_triangle.js:75)
    at hello_triangle.js:76

I'm using the version 1.38.15 on Linux.
Here is the full cmake command, as mentioned changing closure to 0 fixes the issue:

cmake .. -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_EXE_LINKER_FLAGS="-s DISABLE_EXCEPTION_CATCHING=1 --llvm-lto 1 --closure 1 \
    -fno-exceptions -fno-rtti --shell-file ../../minimal_shell.html" 
@kripken
Copy link
Member

kripken commented Nov 8, 2018

Thanks for reporting - do you have a full testcase that I can reproduce the problem with locally, so I can debug it?

@ILikeBigBoots
Copy link
Author

ILikeBigBoots commented Nov 8, 2018

Sure. The error is slightly different(Math.h, but same TypeError).

https://gist.github.com/ILikeBigBoots/bc06e5b0f774e819663c3f18dc3171ae

emcc (Emscripten gcc/clang-like replacement) 1.38.15 ((unknown revision))

-DCMAKE_EXE_LINKER_FLAGS="--closure 1" 
-DCMAKE_BUILD_TYPE=Release

@kripken
Copy link
Member

kripken commented Nov 8, 2018

Do I also need a CMakeLists.txt file for that? When I tried to build that source file with -O2 --closure 1 I don't see an error - maybe cmake would emit slightly different arguments?

@ILikeBigBoots
Copy link
Author

ILikeBigBoots commented Nov 8, 2018

The CMakeLists is as basic as it gets. I noticed though that specifying it as Release Build_Type is necessary to get the error. Removing it doesn't produce the error.

Just to be sure, this is my CMakeList.txt

cmake_minimum_required(VERSION 3.0)
project(Playground VERSION 0.0.1 LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 11)


set (CMAKE_EXECUTABLE_SUFFIX ".html")

add_executable(hello_triangle ${CMAKE_CURRENT_SOURCE_DIR}/01_hello_triangle/hello_triangle.cpp)

And this is my build.sh

cmake .. -DCMAKE_TOOLCHAIN_FILE=${EMSCRIPTEN}/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_EXE_LINKER_FLAGS="--closure 1" \
-DCMAKE_BUILD_TYPE=Release\


make

@kripken
Copy link
Member

kripken commented Nov 8, 2018

Thanks @ILikeBigBoots! Now I see. Looks like a closure compiler issue, fix in #7476.

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

2 participants