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
Schema may not be registered when the networked component is initialized #267
Comments
Actually the workaround I'm describing here may not be enough. I think in my app I had cases but I'm not sure anymore were "register schema" was after "scene loaded". So just to be safe, you can use
or better in the previous workaround described in the previous comment, call
so you are sure of the order. |
In my app where I had the issue randomly before when using networked component in the html, I removed all networked component from the html and I'm using a single js file with something like this:
and in my html
So here scene loaded always come after DOMContentLoaded so this is good. (Edit: this assumption is false, see latest comment) So maybe the real fix to do in networked-aframe is to wait for scene loaded event before calling |
I am experiencing the same bug. Thanks @vincentfretin for describing your tests, I'll look into them. |
Ahhhhh, with my previous slideshow code that worked great since june last year, I just had an error "this.data.src.startsWith is not a function" with someone on Safari that I suspect sent to me bad data probably |
networked-aframe/src/Schemas.js Lines 53 to 59 in fec4c84
should log at least an error if the template is not found when template is not '' which is the default networked-aframe/src/components/networked.js Line 118 in 393ec7b
Ideally getComponents(template) should be delayed if the template doesn't currently exist, wait 1s, check, wait 1s, check, and give an error after 3s? In this case it should return a Promise and we need to adapt the code because this.componentSchemas will be set asynchronously. This is not a small change.
I'll add a setTimeout 3s before calling addNetworkedComponent() in my this.el.sceneEl.hasLoaded branch lol or create some function ensureTemplateIsRegistered before calling |
Ok I will use this now in my code. I added a
I'm keeping the scene loaded logic to be sure that the template is loaded from the DOM, I had a case on a simple glitch example where |
I edited my comment with the non working code. My assumption was wrong, scene loaded can be before |
Hi Vincent, We were able to fix this by loading an image in the following tag: We had to include the dummy query -Devin |
Hi, putting a query string in the url doesn't cache it? interesting. |
Thank you. I believe we implemented your fix correctly but now getting issue where some people load and are stuck in the middle of the room. I remember seeing this before with the basic NAF examples last summer. Is this related to this bug or is this something different? |
What do you mean by stuck? Please create another issue for this to not pollute this issue, thank you. Or you can join me on slack so we can talk about it. |
Another workaround that can be simpler so that you can still use
It's a little bit hacky but this works great. This will do an extra if when initializing each networked component, but the |
I modified https://glitch.com/edit/#!/naf-project with the above workaround. |
not sure if this helps what i do is to wait for adapter-ready and than register the schemas
|
Yep that works too if you're using |
There can be a race condition case where the schema defined in the footer of the page is not register when the networked init function is executed where it calls
NAF.schemas.getComponents
to get the components to sync based on the registered templatenetworked-aframe/src/components/networked.js
Line 154 in 393ec7b
The issue seems to be always reproducible when there is no assets to download.
I created an example based on the naf-project template where I only commented the two assets sky and grid, and modified the template to not use random-color, which hide the issue actually...
https://glitch.com/edit/#!/naf-schema-race-condition
The issue here is that all avatars stay red, instead of a random color set by the participant and normally synced to other participants.
In the logs we get this order:
With this order,
NAF.schemas.getComponents
returns the default["position", "rotation"]
instead of["position", "rotation", {selector: ".head", component: "material", property: "color"}]
, so not syncing the material color set by the random-color component on the player entity.A workaround is to not set the networked component in the html, but set it with javascript:
and remove
networked="template:#avatar-template;attachTemplateToLocal:false;"
from<a-entity id="player"
I'm not sure how we can fix that... or if we can fix that really...
The issue may appear randomly when you have small asset in
<a-assets>
to download or if you have it already in your cache.The issue is much worse when you register a template that doesn't have position and rotation, you can end up with two participants having a different schema, one sending a vec3 trying to fit as a number in a custom component and you have weird things happening like objects disappearing. Yes I had this case on one of my projects. :D
The text was updated successfully, but these errors were encountered: