Freezing issue
#1
I state my apologies in advance about this post, I have broswering throught the forum a little to find some more informations about the freezing issue and I'd like to keep this post alive because the problem is still there. There's a similar game made with Unity which I play since 3 years now and it never freezed in single or in multiplayer mode (even with my primitive connection) what happen on this game is that in multiplayer mode the enemies doesn't sync very much well, so for example when the enemy should die it still stay alive and eventually it die after several more shoots but this would be a thousand times better than to have the game freezing costantly. I also would like to say that this game doesn't give you the choice to log in to several servers (for example European, American etc) but only to connects to a single server which work for everyone.
Reply
#2
Freezing happens when you lose your connection to the server. In other games you'll likely either get a disconnect message or crash to desktop, but in this one (currently) the last frame before you were disconnected is likely to be displayed.

It sounds like you'd like to be timed out and automatically reconnected when you experience major package loss (?), but I'm not sure that's an option with the server package being used since I'm pretty sure the servers are hosted player-side rather than on a single system/source (which is probably the case for the game you're talking about). If they were hosted from one location, for instance by the dev, I think he'd have to dedicate the system/bandwidth in order to host the server 24/7, because the server(s) would probably only be available while he was connected to them. 

And I'm not sure even that would solve your problem since the disconnection mechanic may be an inherent feature of the server package rather than something the developer can adjust. @chaozz or someone more familiar with the package being used will have to answer that.
Reply
#3
I was lurking around unity and photon forums for a while. And I stumbled upon this:

https://doc-api.photonengine.com/en/pun/...c_api.html


You can see PUN has a onConnectionFail enum which says

Quote:Called when something causes the connection to fail (after it was established), followed by a call to OnDisconnectedFromPhoton().



So it means OnConnectionFail can be called when and only when there was an existing connection, which at some point dropped or the client got disconnected from the master client.


I have 0 idea about the actual code structure of the game, but based on assumptions and observations, I think any one of the followings might be possible using this


1) Use onConnectionFail to detect if the client got disconnected, then send user data to database (days alive, inventory etc.) and normally exit the player into main screen with a message of "Connection Failed"

However there is one problem. My assumption is that individual players CANNOT send data to databases, they first send the data (also known as the room state) to the master client (host), and the host sends it to the database. But since you already are disconnected from the host, your data won't reach the host thus your latest action, position, inventory will not be stored. What I think it happening is the room state is sent from the player to the host every X seconds, and the host also sends it to database every Y seconds, thus keeping this checkpoint like system when you crash.


Now I don't know how continuing the game session after a client disconnects work, but I can assume it's something like this:

There is a dedicated server instead of a master client. All the clients send their room state to the dedicated server. The dedicated server does its calculation and sends the room states back to them. When a player disconnects, unity detects that and sends some kind of special custom request to the server saying 'Hey I'm having timeouts", and the server drops his connection but saves his session ID and the unity client then tries to reconnect from the frozen state by reusing it's session, thus re-establishing the same connection. Very simplified than what happens in real life but there must be a dedicated server. It is not possible with master client system. Why?

Because 1) Players lag. And lag will cause their room state to be sent to master clients at wrong intervals. Imagine you shot a bullet at 0:14 but due to lag the message was received by the master client in 0:15. Even a single second lag in these fast paced games will cause your bullet to actually come out after the object you are trying to shoot is outside your view. Or maybe you drink a can of beer, but it didn't reach the master client in time. And another player sends his roomstate where you still have the can of beer and the master client decides to keep his version instead of yours because his one is the latest, thrust duplicating your item (which is probably what's happening now in Survius)

So you can see, not only this problem needs a dedicated server to be solved in this way (connection re-establish),but also a dedicated server will fix more problems in the game.

I hope chaozz might shed some more light on my assumptions and think if something's possible using the current master client system, but I doubt it is and even it is, it's gonna become a complex mesh of networking code
Reply
#4
Thanks CannibalHero and DarkCoder for your replies, I truly appreciate it very much cause it allowed me to understand a bit more about this issue. From what I was able to understand the game absolutely need a dedicated server because in this way if a client is having timeouts the server still tries to reconnect and reusing it's session instead of freezing the actual state of the client. As I said in some previous post I believe that if the game has a dedicated server will automatically fix several problems like (freezing client state, duplicating items and stuff like this) I also know that networking is one of the most difficult task for a programmer to code, I am aware of this. Personally if this were necessary I would prefer to completely rewrite the source code than to have the game work in this way, because if the game would be released in this state, people like me with poor connection would have little chance to play the game cause of the constant freezing. So I think this is the main problem to solve. We must find a way all together to prevent the game freezing 100%!
Reply
#5
A dedicated server might fix the issue of freezing, but it won't fix the issue of losing data (eg. days alive) when you crash. That issue is the data held in memory not being saved in the event of a premature disconnect/crash. A fix to that is constantly update the DB as info changed, but that has the downside of being slower (writing to memory is faster than writing to disk); and writing to the DB when something changes might already be possible. However, since updating the DB that much is slower, it would be better to just save all the player data when they disconnect (whether it's a crash or not).

Simplified version:
Changing the server doesn't change the code that's there. Different ways to fix the problem might already be possible.

Edit: I'm tired and am probably forgetting stuff.
Reply
#6
(01-24-2020, 09:27 PM)Mohenjo Daro Wrote: A dedicated server might fix the issue of freezing, but it won't fix the issue of losing data (eg. days alive) when you crash.

But if we fix the freezing issue the game will not crash anymore so you don't have any losing data. From what I've understand if the game has a dedicated server it will not freeze anymore because if a client is having timeouts/temporarily disconnected the server still tries to reconnect and reuse it's session instead of freezing the actual state of the clientso in theory the losing data will be fixed automatically because you don't have any losing data anymore. Im not sure if I am correct here but I understood what you are saying.
Reply
#7
As long as both problems (freezing and data lose) are fixed, then I'm happy lol (I'm very used to big problems being fixed and smaller problems being ignored because "they don't happen much")

I do think the freezing is a code issue more than a dedicated server issue. As dedicated server should be able to allow the client to reconnect, but photon may also allow it.

A bit of what I found doing a quick search (not sure if any of this would actually be helpful to chaozz):
Freezing due to disconnect: https://answers.unity.com/questions/1487...erver.html
Reconnect after unexpected disconnect: https://forum.photonengine.com/discussio...on-timeout
Reply
#8
Thanks a lot Mohenjo Daro for this research because it's looking really useful, I also would be very much happy if both of the issues will be fixed 100%! 

The person who write the post in the first link it say "This works fine as long as the app is connected to the server. But as soon as it is disconnected from the server, the game freezes. Can someone please help with this? EDIT: I have found out that client.Receive causes the problem. Because as soon as I remove the receive part, it does not freeze even after the client is disconnected."


And one other person answered:
"UDP doesn't make connections. The remote host is reachable or not. When you call 

Code:
client.Receive()

 you're blocking the current thread while it waits to get a message on the UDP port. Because the thread is blocked, Unity is starved and can't make updates - so it freezes.

You need to call Select() before doing the receive to check if any data is available on the port, then read the port if there is - this is the basis for non-blocking I/O.
You could try doing the read in another thread but that's also not great because that thread will block - unless you do Select() first - and that just causes things to come to a grind."

Maybe all of this can be done also without a dedicated server at all, I hope so.
Reply
#9
There are two different issues involved and that are continuously mixed throughout this thread:

-One is survius related, it is the missing exception checking / logic that handles players dropping frames while in-game or disconnecting. So because there is missing logic for that the game simply freezes with no feedback. Admins should list that as a bug or as a "suggested feature".

-Second issue is related to your specific case, that is your (very) poor and unstable connection. One cannot simply play REAL-TIME multiplayer games without having the resources for it. Actions have to be sync'd between all players and I remember you mentioned not being able to play when there are two or more players logged in the server, so that's about all your connection can handle.
Reply
#10
(01-26-2020, 12:27 PM)sha1 Wrote: One cannot simply play REAL-TIME multiplayer games without having the resources for it. 

Agree, after all if you dont have an internet connection you can't even run the game. However I play a lot of games in real-time multiplayer mode: broswers game, on Steam, everywhere and I am able to play them also with my (very) poor unstable connection. 

I want to focus the problem here that the game must not freeze when you lose connection. In my life I never played an multiplayer game which freeze when you lose connection, indeed this is my first time happening with this game. So this problem must be solved because even if you have a normal connection the game freeze (although the percentage of it is very small) but you still freeze also if you have a normal connection.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)