Skip to content

Avoid allocations in NetworkedAnimator #12

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

Merged
merged 4 commits into from
Mar 5, 2018
Merged

Avoid allocations in NetworkedAnimator #12

merged 4 commits into from
Mar 5, 2018

Conversation

angusmf
Copy link
Contributor

@angusmf angusmf commented Mar 5, 2018

@TwoTenPvP
Copy link
Contributor

This doesn't work. Animator parameters is not populated before runtime. You probably have to do a check if the array is null, if so, populate it with the parameters.

…ll cached params when ownership to prevent another out-of-range.
@angusmf
Copy link
Contributor Author

angusmf commented Mar 5, 2018

Correct. Turns out you also have to remember to null the array when changing ownership. See update (and thanks for that virtual!)

@TwoTenPvP
Copy link
Contributor

Why are you resetting the array when changing ownership?

@angusmf
Copy link
Contributor Author

angusmf commented Mar 5, 2018

Just doing a null check wasn't sufficient when testing on HLAPI. It would get into the for loop, then get an index out of range when actually reading one of the parameters, which in some way makes sense if you've switched from serializing to deserializing or vice versa. Where I was previously initializing the parameters array I nulled it instead, but that left one out of range error when this happens on ownership change. So I moved it into the ResetParameterOptions and call it when a change happens. I added it to both overrides not based on testing per se. In HLAPI, they reset last sync time in NetworkTransform when auth is started, but not when it is stopped, so I observed errors when interpolation was used because I add and remove auth from objects. I don't know that we have the same issue here, but seemed safest to just do both.

@TwoTenPvP
Copy link
Contributor

Is this relevant to the MLAPI? MLAPI has none of the connectionReady and observer issues that the HLAPI has. The reset seems unnecessary. Please try without the reset and get back to me.

@angusmf
Copy link
Contributor Author

angusmf commented Mar 5, 2018

I would, but don't have a test project based on MLAPI yet.

@TwoTenPvP
Copy link
Contributor

Alright, I'll give it a shot.

@TwoTenPvP
Copy link
Contributor

From my very quick testing, it's not needed. This will simply make the NetworkedAnimator nonfunctional as the parameters set to be synced are all turned off. Take it out of the PR and create another issue if neccecary. After this merge I'll rewrite the Animator to follow the rest of the projects code standard and be a bit cleaner.

@TwoTenPvP TwoTenPvP merged commit f0c0616 into Unity-Technologies:master Mar 5, 2018
@angusmf
Copy link
Contributor Author

angusmf commented Mar 5, 2018

Thanks. I'll finish my test project ASAP.

MrCool92 pushed a commit to MrCool92/MLAPI that referenced this pull request Dec 6, 2020
Avoid allocations in NetworkedAnimator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants