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

Make headless-gl context aware #182

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Make headless-gl context aware #182

wants to merge 5 commits into from

Conversation

dhritzkiv
Copy link
Member

@dhritzkiv dhritzkiv commented Jan 7, 2020

For use in workers, etc.

See

To do:

Closes #151

@dhritzkiv
Copy link
Member Author

@robertleeplummerjr with more work, is this something that'd be useful in gpu.js? In your project, I see references to workers, but they look like browser workers, and not Node.js Worker Threads.

@robertleeplummerjr
Copy link
Collaborator

We test against web workers currently. However, this would be a very useful addition. When this is added, we'll be sure to add tests to showcase the feature.

loads the package in both main thread and worker thread.
demonstrates two ways of running gl with worker threads - in series, or in parallel. The parallel segfaults currently
@dhritzkiv
Copy link
Member Author

dhritzkiv commented Jan 8, 2020

The good news is that gl works in the most basic usage of worker threads (one worker thread at a time). However, we quickly run into SIGSEGV issues when running it on many threads (main thread + a worker thread, or two worker threads at the same time). Unfortunately, I've had a hard time debugging with LLDB, as it's not revealing exactly where the segfault occurs.

I suspect part of the problem may be global/static data being accessed across threads, specifically

bool WebGLRenderingContext::HAS_DISPLAY = false;
EGLDisplay WebGLRenderingContext::DISPLAY;
WebGLRenderingContext* WebGLRenderingContext::ACTIVE = NULL;
WebGLRenderingContext* WebGLRenderingContext::CONTEXT_LIST_HEAD = NULL;

If that were somehow addressed, I wonder if the Angle library itself would work as expected. Scouring the Angle project's forums, it seems that Angle (at least our version) is not thread-safe. So perhaps this feature is a fool's errand?

@lqomg
Copy link

lqomg commented Jul 31, 2023

Hello, has this plan been terminated? I want to use gl on the main process of Electron 22+, but it is currently not feasible. After consulting a lot of information, I couldn't solve it, probably because of this:
https://www.electronjs.org/docs/latest/breaking-changes#default-changed-loading-non-context-aware-native-modules-in-the-renderer-process-is-disabled-by-default
electron/electron#18397

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

Successfully merging this pull request may close these issues.

add support for using inside Worker (worker_threads module)
3 participants