-
Notifications
You must be signed in to change notification settings - Fork 11
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
Infinite loop when applying impulse to shape #24
Comments
What I've discovered so far... When a body has a separate shape component (as per compount shapes), after the shape is initialized, the shape calls Then on the next tick, the
The problem is that this code is thus being executed twice, and when this happens, This doesn't happen when there is no separate What I haven't yet understood is why this problem did not occur in A-Frame 1.3.0. |
The difference seems to be that when the
|
Done a bit of digging in A-Frame but can't easily identify what has led to this change in ordering. Ether way, aframe-physics-system should be more robust to this sequence. Here's an example using A-Frame 1.3.0 that shows the same problem: So I'm not too bothered what the exact cause of the subtle change in ordering is - we should make aframe-physics-system robust to either order... |
I atempted a fix for this by calling That does fix the problem in 1.4.0. However things stop working at 1.3.0 with that fix. In both this example, and in the glitch example linked above, we then hit this error:
We had a problem with the code to set up A further oddity - in the glitch example, if I replace the Why is it not set up? Well it seems that wuith 1.3.0, on the initial call to the (as an aside, don't confuse 2 flags: But even if this flag is not set up on the first call to |
OK, problem with the fix is fairly simple. Just as the This bit of code is problematic when that's the case, as it clears out
|
Stepping back, let's look at the overall flow here...
When So what's curious (and probably the cause of the regression) is why But also, we can make A-Frame physics system resilient by replacing this code:
with this:
I've tested that fix with the example at 1.3.0 and 1.4.0, and with the glitch at 1.3.0 and 1.4.0, and it seems good. |
OK, this is happening due to these lines:
The Therefore an alternative fix is probably just to modify the code above to this:
(then |
Turns out that fix doesn't work, because But this fix does work:
Or rather, this fixes the original problem described in this issue. But it doesn't fix the glitch, because the glitch had engineered a different route to duplicate calls to |
Splitting this out as a separate issue as it's not straightforward
Further issue spotted in Cannon example. When clicking to apply an impulse in the compound example. Seems to be specific to this example...
aframe-physics-system.js:18053 Uncaught RangeError: Maximum call stack size exceeded
at LocalDriver.applyBodyMethod (aframe-physics-system.js:18053:3)
at body.applyImpulse [as __applyImpulse] (aframe-physics-system.js:18916:16)
at LocalDriver.applyBodyMethod (aframe-physics-system.js:18053:27)
at body.applyImpulse [as __applyImpulse] (aframe-physics-system.js:18916:16)
at LocalDriver.applyBodyMethod (aframe-physics-system.js:18053:27)
at body.applyImpulse [as __applyImpulse] (aframe-physics-system.js:18916:16)
at LocalDriver.applyBodyMethod (aframe-physics-system.js:18053:27)
at body.applyImpulse [as __applyImpulse] (aframe-physics-system.js:18916:16)
at LocalDriver.applyBodyMethod (aframe-physics-system.js:18053:27)
at body.applyImpulse [as __applyImpulse] (aframe-physics-system.js:18916:16)
The text was updated successfully, but these errors were encountered: