I’ve been working on an (improved) port of OSG to WebAssembly, and have a question for the experts :-) So far, my port runs well when built with threading support, but some browser implementations currently disable some of the threading support, so I need to have an alternative port which does not attempt to use threads at all.
What I’m curious about is how to configure the OpenThreads build (or whether it is advisable and/or possible to not involve OpenThreads at all) when building OSG. The WebAssembly compiler doesn’t hide the pthreads support in the headers when building single threaded, but doesn’t link against the pthreads library, so my current attempts to build single-threaded fail at link time.
I’ve looked through the OpenThreads CMakeLists, but it’s not obvious to me how to configure without any threading support at all.
Any advice?
Kind regards,
Phil
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
OK, let me rephrase the question then. Is OpenThreads essential in OSG?
I don’t recall if I mentioned earlier, but the multi-threaded version works just fine in multi-threaded WebAssembly. This depends on SharedArrayBuffer support in Javascript, which has been disabled in many browsers to mitigate spectre-style attacks. So I’m trying to support the single-threaded case as well to support those browsers. This is primarily on mobile platforms.
I guess to build a usable single-threaded version, what is needed is a patch to OpenThreads to ignore all pthreads headers, and effectively stub-out some of the methods. In single-threaded WebAssembly there are apparently still gcc-style internals available for atomics, so it wouldn’t be necessary to create new code for all stubs.
Kind regards,
Phil.
> On 30/03/2020, at 10:22 PM, OpenSceneGraph Users <osg-...@lists.openscenegraph.org> wrote:
>
> Hi, Phil,
>
> when you run single threaded osgViewer, you have single thread. Which
> browsers don't like that and why?
>
> Regards,
> Michael.
_______________________________________________
I have a small sample with single threaded osgViewer that might help
you: https://github.com/OGStudio/openscenegraph-cross-platform-guide/tree/master/1.10.SampleWeb
OSG sources host the same Emscripten sample. Though, compile time
flags might need just a bit of tweaking (see
openscenegraph-cross-platform-guide open issues).
Regards,
Michael.