-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Added checks to init() in rapier3d-compat module to catch multiple calls #159
base: master
Are you sure you want to change the base?
Conversation
IMO this doesn’t belong in the lib and is not worth the extra complexity, particularly since you easily can fix this on the consumer side |
I agree it's rather easy to implement on the consumer side, however I still think it's a good addition:
|
Thank you @grischaerbe for this change. I agree that it can easily be fixed on the user side, but the real issue here is the difficulty the user may have to understand that they are having crashes because of double-initialization. So this change can save them some debugging time. |
An alternative approach could be to throw an error (with a good description) if multiple calls to RAPIER.init();
RAPIER.init(); But I don't have a super strong opinion on this and don't wanna block the PR 🙂 |
It seems like this could also be useful in case Rapier is used from multiple external libraries that might not be set up to work together - e.g. see the As far as I can see, there are two main requirements:
From the initial comment, neither requirement is currently met - as far as I can see 1. is not possible (I'd be very interested if there is a workaround), and 2. is not met because calling init() multiple times may either produce no errors, or ones that are hard to debug, so a new user seems unlikely to find out about their error this way. Not to make it too complicated, but could there be two functions? The current At a minimum, should the getting started docs have a clear warning never to call |
As calling
RAPIER.init()
multiple times results in overlapping pointers, weird results and random errors but sometimes also stable situations, it's rather hard to debug and classify.This PR makes multiple calls to
RAPIER.init()
result in a single Promise being resolved.