Discussion:
[osg-users] [build] ViewerBase::setThreadingModel() not working
Guy Volckaert
2018-07-12 15:22:14 UTC
Permalink
Hi,

When I try to cycle through the threading models by pressing the 'm' key (when the ThreadingHandler is registered) the stats would indicates the correct threading model, but the engine would remain in SingleThreaded. So I started investigating the issue and I noticed that, with OSG v3.6.2, the ViewerBase::setThreadingModel() changed compared with v3.4.0. Below is a snipit of function:


Code:

void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
{
if (_threadingModel == threadingModel) return;

bool needSetUpThreading = _threadsRunning

if (_threadsRunning) stopThreading();

_threadingModel = threadingModel;

if (needSetUpThreading) setUpThreading();
}





If the current threading model is SingleThreaded then _threadsRunning will be false which means that needSetUpThreading will also be false. Therefore, setUpThreading() will never be called if we are in SingleThreaded.

Rolling back the function to v3.4.0 seems to resolve the problem, but I'm not sure if that will cause other issues. There's obviously a reason why it was changed. I would like someone with more experience that I to way in. Below is a snipit of the rolled-back function.


Code:

void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
{
if (_threadingModel == threadingModel) return;

if (_threadsRunning) stopThreading();

_threadingModel = threadingModel;

if (isRealized() && _threadingModel!=SingleThreaded) startThreading();
}




Regards,

Guy

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74324#74324
Robert Osfield
2018-07-12 15:55:02 UTC
Permalink
Hi Guy,

The commit that changes this was:

ommit bb84f1ea3c23625a645b9c2848202bca7c566efb
Author: Konstantin S. Matveyev <***@zorro.ev>
Date: Sat Jan 13 15:46:53 2018 +0300

osgViewer::ViewerBase setThreadingModel func fix: should not start
threading, must only restart

Off the top of my head I only vaguely recall the motivation for the
change. Have a look at the mailing list/forum archives and the commit
on github to see any discussions about this from early January,

Robert.
Post by Guy Volckaert
Hi,
void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
{
if (_threadingModel == threadingModel) return;
bool needSetUpThreading = _threadsRunning
if (_threadsRunning) stopThreading();
_threadingModel = threadingModel;
if (needSetUpThreading) setUpThreading();
}
If the current threading model is SingleThreaded then _threadsRunning will be false which means that needSetUpThreading will also be false. Therefore, setUpThreading() will never be called if we are in SingleThreaded.
Rolling back the function to v3.4.0 seems to resolve the problem, but I'm not sure if that will cause other issues. There's obviously a reason why it was changed. I would like someone with more experience that I to way in. Below is a snipit of the rolled-back function.
void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
{
if (_threadingModel == threadingModel) return;
if (_threadsRunning) stopThreading();
_threadingModel = threadingModel;
if (isRealized() && _threadingModel!=SingleThreaded) startThreading();
}
Regards,
Guy
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74324#74324
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Guy Volckaert
2018-07-12 16:07:01 UTC
Permalink
Hi,

I looked at the commit but the description does not clearly provide a reason for the change. I looked at the forum but could not find anything. I'll try the mailing list next.

Thank you!

Cheers,
Guy

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74327#74327
Guy Volckaert
2018-07-12 16:52:52 UTC
Permalink
Hi,

I also looked at the osg-submissions archives and could not find any trace of this change. I went back as far as June 2017.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74329#74329
Guy Volckaert
2018-07-12 17:22:00 UTC
Permalink
Actually, if we want to adjust the threading affinity when cycling through the threading model, then would`t be better to if we replaced:


Code:

if (isRealized() && _threadingModel!=SingleThreaded) startThreading();




by


Code:

if (isRealized() && _threadingModel!=SingleThreaded) setUpThreading();




Guy

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74330#74330
Robert Osfield
2018-09-03 11:44:03 UTC
Permalink
Hi Guy,

I have looked into the revision that Konstantin made back in January
and it looks to me like the intent was to prevent the viewer from
starting threads before you've called realize:

https://github.com/openscenegraph/OpenSceneGraph/commit/bb84f1ea3c23625a645b9c2848202bca7c566efb#diff-936c2b7991f9f45a3c10c4d64a053ac2

Your suggestion is a more robust way of doing this so Ive applied this
and it works for me:

https://github.com/openscenegraph/OpenSceneGraph/commit/ae3133522d18c1e456d22569137cdf45dac6b2f2

This change is merged with master and 3.6 branch.

Cheers,
Robert.

Robert Osfield
2018-07-12 17:25:48 UTC
Permalink
Post by Guy Volckaert
I also looked at the osg-submissions archives and could not find any trace of this change. I went back as far as June 2017.
Most submissions now come it via pull requests on github.

Robert.
Loading...