Skip to content

Pthreads + webgl causes exception #8831

Description

@sergeyext

The following code

int main()
{
        if (glewInit() != GLEW_OK) {
                std::cout << "No glew" << std::endl;
                return 1;
        }
        if (glfwInit() != GLFW_TRUE) {
                std::cout << "No glfw" << std::endl;
                return 2;
        }

        auto w = glfwCreateWindow(100, 100, "Foo", 0, 0);
        glfwMakeContextCurrent(w);

        GLuint bufId;
        glGenBuffers(1, &bufId);
        glBindBuffer(GL_ARRAY_BUFFER, bufId);
        glBufferData(GL_ARRAY_BUFFER, 256, nullptr, GL_STATIC_DRAW);

        return 0;
}

being compiled with flags -s USE_PTHREADS=1 -s USE_GLFW=3 -s USE_WEBGL2=1 crashes with Assertion failed: target_thread, at: /path/to/emsdk/emscripten/1.38.31/system/lib/pthread/library_pthread.c,355,emscripten_async_queue_call_on_thread on glBufferData call.

It works correctly if we comment out glBufferData or build the code without threading support. Threading and shared buffers in browser are enabled and a minimal example with ClearColor() and Clear() work correctly even from a worker thread.

Also crashes with webgl1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions