Online Multiplayer Object Sync Problem

1 favourites
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • This is quite an interesting bug. The same hing happened to me aswell.

  • Ashley , I was having this issue, and I figured out the cause.

    When synced objects have no changes to their positions(if its synced?) or synced instance variables, the peers will think these objects have timed out and destroy them (they don't get destroyed for the host).

    Simply by changing a synced variable every few ticks (on the host side?), it keeps the objects alive.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Prominent

    Please submit a bug report with a minimalistic project github.com/Scirra/Construct-3-bugs

  • Also, another thing worth mentioning is that if the host's window is minimized, it seems as if data stops sending- like it is being paused(even though the setting to not pause while unfocused is correctly set).. I'm guessing the lag simulation uses the time in construct to alter the gameplay, but when minimized the time stops completely.

    So objects will be destroye and recreated on the peer side when this happens, even if the host is changing the data constantly- the minimized window prevents data sending.

    I'll create another bug report when I get the time..

  • Also, another thing worth mentioning is that if the host's window is minimized, it seems as if data stops sending- like it is being paused(even though the setting to not pause while unfocused is correctly set).. I'm guessing the lag simulation uses the time in construct to alter the gameplay, but when minimized the time stops completely.

    So objects will be destroye and recreated on the peer side when this happens, even if the host is changing the data constantly- the minimized window prevents data sending.

    I'll create another bug report when I get the time..

    This is a known issue with multiplayer and the window out-of-focus implementation of certain browsers.

    Ashley Did this ever get sorted out in the Chromium bugtracker?

    I remember having a discussion about this in the past, with a potential workaround using service workers to keep the game active in the background.

  • This is a known issue with multiplayer and the window out-of-focus implementation of certain browsers.

    I'd be interested to know more about this, if anyone has some details about it. I don't destroy or recreate any synced objects while my game is playing (except when peers connect/leave). So having objects disappear and reappear (with their non-synced values reset), and sometimes not recreated at all, is a bit concerning.

    I feel like it is related to the latency simulation.. but I haven't tested it with real-world high latency yet to find out.

    I tested it locally WITHOUT latency simulation, with nw.js minimized and it was alright.

    When I tested with simulation, I tried testing with simulation values of 0.000001 and minimized, and the latency would begin climbing up to 900s when minimized (objects disappearing while this happens), and then when unminimized the latency of the peer would fall back down below 50.

    So I think there is something within the simulation itself that is causing problems..

    again, i haven't tested with real-world high latency- but I have with low latency, locally, and when minimized the latency doesn't begin to climb(since the latency isn't simulated).

    Also keep in mind, that if the synced objects don't have their data changed much, they timeout quicker.

  • Edit:

    I noticed that objects were still appearing and disappearing even though I was updating the synced variables, but the way I was updating them was by setting their variable with Self.variable (without any picking).

    I had a suspicion that some objects weren't setting their variable, So I put it into a for each loop to make sure each one was getting set, and this seems to fix the issue. There are sometimes rare cases when the latency is over 900 (when the browser of the host is minimized), but for the most part the objects stay.

    It also seems to only matter if the host is changing the variable, since peers set their values to the host's.

    I still added code to compensate for recreated objects, just in-case it does happen, since it can reset any un-synced variables and settings. On the host side, the objects will never randomly disappear (since it is the host).

  • Thanks for the tips, as I experienced the same de-sync on peer objects and didn't find any information anywhere else. Is Construct 2 having less bug fixing that before C3 ? Just a question, no joke.

  • They probably have most their attention on C3, so maybe that's the case. More reason to be very precise with bug reporting to make it easy for them to consider fixing stuff- they probably don't want to dig around in old code and figure stuff out if they have new things to work on.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)