- Home /
MasterServer.RegisterHost causing a bad frame rate?
I am using unity networking for a network game. I am searching for a few hours for a reason for bad FPS and couldn't find anything until I changed something that looks completely unrelated. I run my server with the following lines using the default unity master server:
Network.InitializeServer(8, mPort, true);
MasterServer.RegisterHost(mGameName, mServerName, "");
10 seconds after calling this my FPS go down to a level that makes playing impossible. Removing the RegisterHost command fixes the problem. To test it I used an empty scene so there is not much that could cause this. Still if I use RegisterHost the FPS go down. What could be the reason for that? Maybe a bug in unity? Or maybe someone evil on the public master server tries to cause troubles? Has anyone a private master server and can test this?
I use a scene only containing this script on a gameobject + camera:
using UnityEngine;
using System.Collections;
public class FrameRateTest : MonoBehaviour
{
float mTimeSum = 0;
float mAvgFrameTime = 0;
float mFps = 0;
// Use this for initialization
void Start () {
Network.InitializeServer(8, 54443, true);
MasterServer.RegisterHost("testgame1234", "testserver1234", "");
}
// Update is called once per frame
void Update ()
{
mTimeSum += Time.deltaTime;
if (Time.frameCount % 60 == 0)
{
mAvgFrameTime = (mTimeSum / 60);
mFps = 1.0f / mAvgFrameTime;
mTimeSum = 0;
}
}
private void OnGUI()
{
GUILayout.BeginVertical();
GUILayout.Space(100);
GUILayout.Label(mAvgFrameTime + " avg frame time");
GUILayout.Label(mFps + "fps");
GUILayout.EndVertical();
}
}
Answer by devluz · Feb 05, 2015 at 03:33 AM
This seems to be a known bug for years and no one seems to be interested in fixing it. This is a huge disappointment.
Here is the bug report: http://issuetracker.unity3d.com/issues/masterserver-dot-registerhost-causes-slowdown-after-10-seconds
Your answer