<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Crazy lag on Unity Client while trying to deserialize MsgPack data. Issue with patching. (SOLVED)]]></title><description><![CDATA[<p>I have been developing a small game using Unity as the client. I downloaded your source code and it was working until I put about 400 world objects down. These objects do not move or update at all.</p>
<p>Now, when the player moves, there are huge lag spikes. I narrowed it down to line 180 in Room.cs (Patch function):</p>
<p><code>var newState = MsgPack.Deserialize&lt;IndexedDictionary&lt;string, object&gt;&gt; (new MemoryStream(this._previousState));</code></p>
<p>I believe this is because any time there is an update, it attempts to deserialize the entire state, when it only needs to actually deserialize the difference and apply it.</p>
<p>Does anyone have any ideas on how to fix this?</p>
<p>The only solution I can think of would be to have a different room for the static world objects so that they would not need to get serialized for every patch... this seems like a bit of a hack though.</p>
<p>I do realize it is expensive to load the world from the server, but I would like the world to be randomly generated and then sent to the player as they load sections. Is this possible with Colyseus?</p>
]]></description><link>http://discuss.colyseus.io/topic/44/crazy-lag-on-unity-client-while-trying-to-deserialize-msgpack-data-issue-with-patching-solved</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 15:36:11 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/44.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Mar 2018 10:10:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Crazy lag on Unity Client while trying to deserialize MsgPack data. Issue with patching. (SOLVED) on Fri, 16 Mar 2018 18:23:51 GMT]]></title><description><![CDATA[<p>I have been developing a small game using Unity as the client. I downloaded your source code and it was working until I put about 400 world objects down. These objects do not move or update at all.</p>
<p>Now, when the player moves, there are huge lag spikes. I narrowed it down to line 180 in Room.cs (Patch function):</p>
<p><code>var newState = MsgPack.Deserialize&lt;IndexedDictionary&lt;string, object&gt;&gt; (new MemoryStream(this._previousState));</code></p>
<p>I believe this is because any time there is an update, it attempts to deserialize the entire state, when it only needs to actually deserialize the difference and apply it.</p>
<p>Does anyone have any ideas on how to fix this?</p>
<p>The only solution I can think of would be to have a different room for the static world objects so that they would not need to get serialized for every patch... this seems like a bit of a hack though.</p>
<p>I do realize it is expensive to load the world from the server, but I would like the world to be randomly generated and then sent to the player as they load sections. Is this possible with Colyseus?</p>
]]></description><link>http://discuss.colyseus.io/post/137</link><guid isPermaLink="true">http://discuss.colyseus.io/post/137</guid><dc:creator><![CDATA[diericx]]></dc:creator><pubDate>Fri, 16 Mar 2018 18:23:51 GMT</pubDate></item><item><title><![CDATA[Reply to Crazy lag on Unity Client while trying to deserialize MsgPack data. Issue with patching. (SOLVED) on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/39">@diericx</a>,</p>
<p>I see! Thanks for taking your time to report this.</p>
<p>One thing you can do is storing the world objects outside the room's state, and send it directly to the client when he joins the room. e.g.</p>
<pre><code>onInit () {
  this.world = createWorldObjects();
}

onJoin (client, options) {
  this.send(client, this.world);
}
</code></pre>
<p>You'll receive the data in your <code>OnData</code> handler in the client-side.</p>
<p>Hope this helps!<br />
Cheers!</p>
]]></description><link>http://discuss.colyseus.io/post/139</link><guid isPermaLink="true">http://discuss.colyseus.io/post/139</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Crazy lag on Unity Client while trying to deserialize MsgPack data. Issue with patching. (SOLVED) on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a> Worked perfectly!! Thank you so much man, this is really cool.</p>
]]></description><link>http://discuss.colyseus.io/post/140</link><guid isPermaLink="true">http://discuss.colyseus.io/post/140</guid><dc:creator><![CDATA[diericx]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>