Comments (10)
Yes that is how I am working around it and how I worked out that this is likely the issue.
Please feel free to close the issue if you want, as this seems to be another emscripten / wasm bug.
from joltphysics.
Ok I guess this is what is happening: (from https://en.cppreference.com/w/cpp/thread/condition_variable/wait)
If these functions fail to meet the postconditions (lock.owns_lock()==true and lock.mutex() is locked by the calling thread), std::terminate is called. For example, this could happen if relocking the mutex throws an exception.
But of course in the Jolt code the lock is acquired immediately above the wait code, so I'm not sure what is going wrong.
std::unique_lock lock(mLock); mCount -= (int)inNumber; mWaitVariable.wait(lock, [this]() { return mCount >= 0; });
from joltphysics.
Hello,
I've not seen this crash before and it also doesn't make sense to me for the same reasons you mention. I'm guessing that it is not happening in the native version of your app or you would have created an issue sooner.
You could try commenting out the #ifdef JPH_PLATFORM_WINDOWS
bits in the Semaphore class to make your Windows native app run the same code and check if you can repro the crash that way?
In any case I don't see any bugs mentioned in the emscripten issue trackers.
Maybe you can try another browser like Firefox (not Safari because that has issues with multithreading)?
from joltphysics.
Yeah it's just happening in Chrome currently.
Firefox fails for other reasons (hitting 2 GB mem usage with opengl calls fails), but seems to execute this code ok.
Do you have any more info about the Safari multithreading issues?
will try the JPH_PLATFORM_WINDOWS semaphore change on native.
from joltphysics.
Using condition_variable mWaitVariable on native Windows works fine (as expected).
from joltphysics.
Do you have any more info about the Safari multithreading issues?
See for example jrouwe/JoltPhysics.js#110 and #577
Luckily the issue seems to have been fixed in a recent development build of Safari.
Using condition_variable mWaitVariable on native Windows works fine (as expected).
A workaround that we could try is to make Linux/WASM use pthreads semaphores. Maybe those will work (at least they won't call std::terminate).
from joltphysics.
I'm hitting similar crashes in my non-Jolt code. So I even if I run Jolt with the single-threaded task manager, I still need to solve the issue. I think it's most likely miscompilation or misexecution of atomic variables, resulting in double-frees of reference-counted objects.
from joltphysics.
If you figure out what it is then I'd be curious to hear about it.
from joltphysics.
I have narrowed it down a little. Seems to be a combination of memory growth and atomics. Something like when the total amount of mem allocated to the WASM program (which I think takes the form of a single large buffer) increases, some atomic variable is accessed or changed incorrectly, leading to the 'crash'.
from joltphysics.
That makes sense, reallocation and atomics don't go together very well. But then you should be able to work around it by disabling memory growth -s ALLOW_MEMORY_GROWTH=0
and making sure that the initial memory block is large enough -s TOTAL_MEMORY=XXX
(both parameters for emcc).
from joltphysics.
Related Issues (20)
- ā%dā directive output may be truncated writing between 1 and 11 bytes into a region of size 9 HOT 2
- Limiting render rate to simulation frequency (#873) Causes simulation to jitter in the sample app. HOT 2
- `ContactConstraintManager` asserts when constrained body has limited DOFs HOT 11
- `GetBodyCreationSettings()` stores NaNs when using limited DOFs HOT 1
- Compiling with double-precision for macOS <10.14 fails HOT 2
- Version mismatch and other bizarre problems on macOS / XCode HOT 1
- Size of `TransformedShape` and `Body` is not as expected on ARM32 with double-precision HOT 1
- Crash in WASM / Emscripten in browser HOT 5
- [Feature Request] gjk treat quadratics as polyhedrons with convex radius HOT 5
- Large incorrect CollideShapeResult::mPenetrationDepth from mesh-capsule collision HOT 4
- UNDETERMINISTIC report!!!Regarding ContactManifold! HOT 3
- vehicle physics on Car (vehicleConstraint) are little bit broken HOT 1
- Add a bit of documentation regarding library initialization HOT 4
- [Feature request] A way to clear mCachedResult in Shape Settings HOT 1
- Setting custom memory allocator when targetting WASM HOT 4
- Compiling Jolt with SSE targetting WASM HOT 4
- compile error. HOT 1
- How to set mass? HOT 1
- Question regarding objects lifecycle HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from joltphysics.