Skip to content
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

OnStateChange Called When Current Value And Previous Values are same #217

Open
TarunPhonato opened this issue Aug 17, 2023 · 4 comments
Open

Comments

@TarunPhonato
Copy link

When Current Value And Previous Values are same why I received OnState Change callback on same time.

It's working fine while playing on Unity Editor.
Unity version : 2020.2.2f1
Colyseus SDK version : 0.15.4

Untitled

@endel
Copy link
Member

endel commented Aug 17, 2023

Hi @TarunPhonato, could you please provide a small project that reproduces this issue? (with code for both server and client)

@TarunPhonato
Copy link
Author

TarunPhonato commented Aug 18, 2023 via email

@endel
Copy link
Member

endel commented Aug 22, 2023

Hi @TarunPhonato, thanks for the reproduction scenario.

I can confirm the misbehavior - they're 2 known-issues from the state sync structures (aka schemas):

1) The re-triggering of events, even if currentValue and previousValue are the same

This is due to the usage of experimental filters. I'd suggest treating this edge case on your end. (There are plans on replacing the current filter/filterChildren implementation with a different solution - filters are going to be slowly deprecated in the future)

2) The callback is not being triggered on the client-side

This can happen when the same schema instance is being re-used in many places within the state. I've just created an issue describing the problem here.. One easy way to fix this, is by calling instance.clone() instead of sharing the same instance.

This issue does not happen when cloning the instances, only when sharing the same instance - which will result in the instance being shared on the client-side as well.


I see you work for Phonato Studios, it would be great if you can convince them to sponsor the project, if the company is benefiting from Colyseus 🙏

Cheers, I hope this helps, and let me know if you have any other questions

@TarunPhonato
Copy link
Author

TarunPhonato commented Aug 28, 2023 via email

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

No branches or pull requests

2 participants