-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Silent failure where components not initialized if they are modified immediately after object creation. #4973
Comments
For me this looks more a problem in the box component not use the update() https://github.com/aframevr/aframe/blob/master/src/geometries/box.js |
@arpu, I'm not sure I understand. There is no box component in the example. There is a box geometry (which you linked to - this doesn't need an update() method) and the a-box primitive. I'm pretty sure this same problem would reproduce with an just the same. |
Looking into why this does fail, it looks like the issue is that, in the case above
So the issue is that the removeAttribute ends up getting acted on after the setAttribute operation, and hence the component ends up getting removed. A potential fix would be for setAttribute to check for any pending tryRemoveLater event listener on the component, and remove any that is found. The event listener is set up here: FIx would be made somewhere around here: My understanding is that there is no way to directly check for attached event listeners, so we'd need some additional state to track the pending removal. |
Or a simple (more self-contained fix) might be here: Line 489 in 269d178
to something like this (not tested yet):
|
Fix proved to be a little more complicated
I'll offer my fix in a PR. |
Description:
A problem that I have hit, which may be due to A-Frame restrictions around entity creation, but it would be good to at least get a clear error message when making unsupported API calls, rather than (as currently happens) getting a silent failure to initialize the component.
I have a very simple bit of code that is creating an entity and applying a component to it. However, after appending the entity to the scene (before it has initialized), it may further modify the attributes on the entity, as per the example below.
(this example is simplified: in my case the last 2 lines of code occur in a different context, where it's less obvious the component may still be initializing).
When it does this, no error messages are generated, but the component initialization never actually happens at all.
It would be ideal if these further attributes updates could be processed and applied when the component initializes. However I recognize this may not be possible.
I note the docs here do say that operations after appendChild() and before initialization completes, are limited:
https://aframe.io/docs/1.2.0/introduction/javascript-events-dom-apis.html#adding-an-entity-with-appendchild
Assuming that setAttribute() is forbidden as well as getAttribute(), it would be great to do a couple of things:
I'd be happy to work on a PR for the above, if you agree it would be a worthwhile change to make.
The text was updated successfully, but these errors were encountered: