Topic: Webgl online mode desyncs when window is minimized

Hi guys,
I am not sure if this happens on other platforms, but in WebGL builds, online matches go out of sync if one of the players minimizes the window (or selects another tab on their browser). The reason is most browsers refresh non-selected tabs only once a second. For this reason, UFE can't send data enough times, and desync happens.

After doing some research, I found out that by adding these lines to index.htm file you can call a function in unity with an interval (like 250 milliseconds for 4 calls a second)


        document.addEventListener('visibilitychange', function () 
            {
                if (document.visibilityState == "hidden") 
                {
                    //myGameInstance.SendMessage("Receiver", "DoSomething");
                     isActive = setInterval(function() { myGameInstance.SendMessage("Receiver", "DoSomething"); }, 250);
                } 
                else 
                {
                    //myGameInstance.SendMessage("Receiver", "DoSomethingElse");
                    clearInterval(isActive);
                    isActive = false;
                }
            }
        );

This code calls a method named DoSomething() on a gameobject called Receiver every 250 milliseconds. So kind of solves the problem. I just need to call a UFE method that sends an empty input message over the network. But unfortunately, I don't know what that method might be.
Does anybody know of a method that does that? How can I force UFE network code to send input data?
This would extremely help me and everybody else that is trying to make a UFE WebGL game.


Thanks

Share

Thumbs up 0 Thumbs down

Re: Webgl online mode desyncs when window is minimized

Any help would be appreciate on this guys

Share

Thumbs up Thumbs down

Re: Webgl online mode desyncs when window is minimized

Bump

Share

Thumbs up Thumbs down

Re: Webgl online mode desyncs when window is minimized

Are you using UFE 1 or UFE 2? If you are using UFE 2, you are in the wrong forum.
Use this one for UFE 2:
http://www.ufe3d.com/forum/viewforum.php?id=15

As for the problem itself, I don't think the solution involves UFE as much as it does the browser (or WebGL) itself. As you said it yourself:

The reason is most browsers refresh non-selected tabs only once a second. For this reason, UFE can't send data enough times, and desync happens.

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.
Don't forget to check our discord channel.

Re: Webgl online mode desyncs when window is minimized

Yes, the problem is with WebGL and browsers. It probably happens for most of the online games using netcode roleback tech. I want to fix this issue for UFE and I can share it with you to use it on UFE 3.0.
I just need to know which class (gameobject) does the sending of the input through the network and I can call the update method manually to fix this. Can you please tell me the name of that class?

Thanks

Share

Thumbs up Thumbs down