-
Notifications
You must be signed in to change notification settings - Fork 86
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
ClientRemoteProperty doesn't update in edge case #155
Comments
@ambergamefam Do you by chance have some simple repro code I could run to test this out? I can't seem to reproduce the original issue on my end. I do entirely agree with the queued events logic though. If the promise is just waiting for the first event to come through, then subsequent queued events will likely get dropped. So yeah, that's definitely a problem. Not sure why I'm unable to reproduce the issue though. |
I was able to create a repro. Looks like this only happens A) on Deferred signal behavior, and B) only in cases where data is coincidentally set for the player on the same frame where the player requests an initial value of the property from the server. In my case, since there were lots of services and properties in use, the chance of running into this issue for at least one part of the game was actually pretty high. Source code is not rojo-managed in this case. With my PR, this repro shows all values being replicated to the client, since the queued-up events are handled at once: CommDeferredReproWithFix.rbxl.zip Note that the value "5" is received twice since the initial value is sent to the player on the same frame that the value was assigned to 5. |
I will be setting my game back to "Immediate" signal behavior as a workaround for the time being, but if you could take a look at my fix (#157), I would greatly appreciate it. @Sleitnick |
@ambergamefam Yup, please note the pending comments on the PR |
Fixed in Comm v0.3.2, and Knit updated to v1.5.2 with the fix |
@Sleitnick There will still be an edge case if you don't create a closure when deferring the :Observe() callback |
What is the edge case? They should be functionally equivalent |
From the comment I linked:This is incorrect. This needs to be: task.defer(function()
observer(self._value)
end) If you call task.defer with the current value, it will emit that value in a deferred thread, regardless if the value changed between now and when the observer runs. An example of this is when the value changes multiple times when multiple client events get processed in serial. For example:
|
Essentially here's the difference: local value = 1
task.defer(print, value)
value = 2
print(value) Prints: 2
1 VS local value = 1
task.defer(function()
print(value)
end)
value = 2
print(value) prints:
|
Fix: #157
Currently, there is an edge case where a RemoteProperty can initialize with an old value sent from the server, and never updates with the latest value. This is actually super common in cases where Knit properties are created and updated for a player as soon as they join the game, and has caused problems in my game.
This is the problematic line of code:
RbxUtil/modules/comm/Client/ClientRemoteProperty.lua
Line 92 in b91a47d
Essentially, this is the the order of things going on that makes this line of code cause problems:
To fix this issue, the remote property either needs to initialize after the last queued-up event is processed, or it needs to queue up these changes, initialize with the first value, then emit change events for the next remote updates.
The text was updated successfully, but these errors were encountered: