Sockets: Weird behavior on iOS

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AlvaroAV
:warning: Old Version Published before Godot 3 was released.

Hello,

I have a multiplayer game, where I have a 1 vs 1 between 2 players and the socket server moves the enemy (enemies in the future but I’m testing with one right now)

  • Each player sends its own position to the server, and the server broadcast the position to the other player

  • The server moves an enemy that the players has to avoid touching

I’m sending messages from the server like: #MV:ID/X/Y

The main logic is working, the enemy and the players are moving right but:

  • When I try the game on PC (Os X) the player & enemies movement are smooth, everything works fine

  • When I try the game on iOS, everything works same as PC but the movement is not smooth

Let’s say the enemy is moving from (50,50) to (100, 50), on the computer the movement is completely smooth but on iOS it seems it ignores some packages.

I’m sending movement message every 50ms

E.G:

  • On PC the enemy moves to (50, 50), (50.5, 50), (51, 50), (51.5, 50), (52, 50)… let’s says it moves 0.5 pixel each time

  • On iOS the enemy moves like (50, 50), (50.5, 50), (51, 50), (51.5, 50) and then (54, 50)

I’m debugging the app and the sames messages reach the PC and the mobile, but the movement on the mobile is different… questions:

  • Does iOS manage sockets different than PC/Mac ?
  • Am I sending too many information per second ? (20 messages/second)
  • If the mobile is receiving all the packages, why the movement is different ?
  • Could it be that iOS process some messages at the same time ?

I checked the network statistics on XCode and the max used bandwidth is less than 6KB/s

UPDATE

I have made some debugging and find out this:

  • On PC the movement messages are queued 3 at a time like:
    #MV:4/50/50#MV:4/50.5/50#MV:4/51/50
  • On iOS the movements messages are queued like 20 at a time like:
    #MV:4/50/50#MV:4/50.5/50#MV:4/51/50#MV:4/51.5/50#MV:4/52/50#MV:4/52.5/50#MV:4/53/50#MV:4/53.5/50#MV:4/54/50#MV:4/54.5/50#MV:4/55/50#MV:4/55.5/50#MV:4/56/50#MV:4/56.5/50#MV:4/57/50#MV:4/57.5/50#MV:4/58/50#MV:4/58.5/50...

It seems on mobile the socket read function or parse command function is not executed as frecuent as on PC.

Any ideas around this ?