GitHub | Documentation | Become a Patron

HTML5 perfomance issues



  • Hello, I'm trying to make a game with syncronous multiplayer with Colyseus and Defold and I have perfomance issues.
    At first I was using state sync and messages from server to sync clients. State sync was working on 30 FPS and whole game has around 10 FPS on HTML5, Android, Windows and Mac versions because of

    local new_state = msgpack.unpack( utils.byte_array_to_string(self._previousState) )
    

    in room.lua Room:patch.

    Then I turned off room patch by copying library to my project and commenting room.lua:87

    self:patch(message[2])
    

    and sending state info by message from server to clients every frame at 30 FPS. One message contains array of 6-10 elements like this

    2 = {
        segmentRadius = 32,
        skin = cat,
        id = 2,
        segments = {
          1 = {
            y = -316,
            x = -85,
          }
          2 = {
            y = -308,
            x = -93,
          }
          3 = {
            y = -303,
            x = -82,
          }
          4 = {
            y = -295,
            x = -90,
          }
          5 = {
            y = -290,
            x = -79,
          }
          6 = {
            y = -285,
            x = -68,
          }
          7 = {
            y = -277,
            x = -76,
          }
          8 = {
            y = -272,
            x = -65,
          }
          9 = {
            y = -264,
            x = -73,
          }
          10 = {
            y = -259,
            x = -62,
          }
        }
        name = Jessica Jones,
        isolationTimer = 23,
      }
    

    On Windows, Mac and Android it works perfect, but on HTML5 game works at stable 30 FPS around 3-4 seconds and after that Colyseus client freezes and receives no messages from server or client have no resources to decode them: print in room.lua:38 in

     self.connection:on("message", function(message)
    

    works only 3-4 seconds.

    Where can I tweak or optimize my system to solve this perfomance issue?