Hello all,
In our game bullet is used almost exclusively from within the main thread. However when another thread does some raycasting (using btDynamicsWorld::rayTest or btDynamicsWorld::convexSweepTest), the main thread will crash at some point with an access violation. Note that this doesn't happen instantly and can take a lot of ray casts before things go wrong. Also the location itself seems pretty random.
After adding thread locks to all functions using bullet everything seems to be working. As bullet seems to be able to do multithreading itself I assumed everything was thread safe, is this assumption correct?
In case it's relevant: I'm using Windows XP, bullet version 2.74 and boost thread classes.
Multithreaded raycasting.
-
- Posts: 9
- Joined: Mon Jan 17, 2011 11:10 pm
Re: Multithreaded raycasting.
I am having the same issue. Did you find an answer?
-
- Posts: 463
- Joined: Fri Nov 30, 2012 4:50 am
Re: Multithreaded raycasting.
I think you're referring to the parallel solver right? I'm sure bullet could be made entirely multithreaded (though solvers would still normally be just single threaded unless parallel solver or a custom one was used), but I've never seen anything that would say bullet is multithreaded. Read only things should work most of the time, but if the data tries to change during a read it could cause odd behavior/crashes. I had a similar issue when trying to export values from outside the bullet thread while the simulation was running, every once in a while I would get crashes or even really strange simulation errors.-Rick- wrote:After adding thread locks to all functions using bullet everything seems to be working. As bullet seems to be able to do multithreading itself I assumed everything was thread safe, is this assumption correct?
-
- Posts: 149
- Joined: Fri May 24, 2013 6:08 am
Re: Multithreaded raycasting.
Even reading non-atomic values can cause tearing, and anything worth reading is not going to be atomic (eg. floats and vectors and etc). I don't see how you would assume raycasting into the physical world from another thread would be safe. But anyway, it isn't.
-
- Posts: 9
- Joined: Mon Jan 17, 2011 11:10 pm
Re: Multithreaded raycasting.
I can't find what this is referring to in the 2.67 release notes.
"Bullet 2.67 is available...Add support for fast batch raycasting on SPU / BulletMultiThreaded"
http://www.bulletphysics.org/Bullet/php ... &view=next
I would imagine this would help me deal with the issue as well.
Anyone know what this is referring to? I don't see any rayTests done in the BulletMultiThreaded project.
"Bullet 2.67 is available...Add support for fast batch raycasting on SPU / BulletMultiThreaded"
http://www.bulletphysics.org/Bullet/php ... &view=next
I would imagine this would help me deal with the issue as well.
Anyone know what this is referring to? I don't see any rayTests done in the BulletMultiThreaded project.
-
- Posts: 149
- Joined: Fri May 24, 2013 6:08 am
Re: Multithreaded raycasting.
Interesting, I didn't know about this. Look in the Benchmark and ConcaveRaycast demos for #ifdef BATCH_RAYCASTER
I guess you'll have to define that before you can see how it works. Note that this isn't going to make raycasting threadsafe. It looks like it uses a thread barrier to perform raycasts in a large batch, thus the name.
I guess you'll have to define that before you can see how it works. Note that this isn't going to make raycasting threadsafe. It looks like it uses a thread barrier to perform raycasts in a large batch, thus the name.