Unity web player freezes when photon is not running

Options
ximael
edited April 2013 in DotNet
Win xp,
Unity 3.5.5f3,
Photon-Unity3D_v3-2-0-1_SDK(Not PUN).

To reproduce this bug:
1) do not launch photon;
2) run unity app;

Unity editor randomly freezes as well when trying run the app. Standalone app seems fine.
using UnityEngine;
using System;
using System.Collections.Generic;
using ExitGames.Client.Photon;

public class PhotonHandler : MonoBehaviour, IPhotonPeerListener
{
	private const string serverHost = "localhost:5055";
	private const string appName = "ZServer";
	public PhotonPeer peer;
	private IGameListener gameListener;
	public string status = "Disconnected";
	private bool isAppQuit = false;
	public bool inGame = false;

	void Awake()
	{//Debug.Log("PhotonHandler.Awake");
		Application.runInBackground = true;
		DontDestroyOnLoad(this);
		peer = new PhotonPeer(this);
	}

	void Start()
	{//Debug.Log("PhotonHandler.Start");
		Connect();
		Application.LoadLevel("GameHall");
	}

	public void SetGameListener(IGameListener gameListener)
	{
		this.gameListener = gameListener;
	}

	public void OnLevelLoaded() { }

	public void Connected() { }

	public void Disconnected()
	{
		Application.LoadLevel("GameHall");
		if (!isAppQuit)
		{
			Connect();
		}
	}

	void Update()
	{
		try { peer.Service(); }
		catch (Exception e) { Debug.Log(e.StackTrace); }
	}

	public void OnApplicationQuit()
	{
		isAppQuit = true;
		Disconnect();
	}

	public void DebugReturn(DebugLevel level, string message) { }

	public void OnStatusChanged(StatusCode statusCode)
	{
		switch (statusCode)
		{
			case StatusCode.Connect:
				status = "Connected";
				Connected();
				break;
			case StatusCode.Disconnect:
			case StatusCode.DisconnectByServer:
			case StatusCode.DisconnectByServerLogic:
			case StatusCode.DisconnectByServerUserLimit:
			case StatusCode.TimeoutDisconnect:
				status = "Disconnected";
				Disconnected();
				break;
			case StatusCode.EncryptionEstablished:
				status = "Encrypted";
				break;
			default:
				status = "Uncknown" + statusCode;
				break;
		}
//		Debug.Log("PhotonHandler.OnStatusChanged: "+status);
	}

	public void Connect()
	{//Debug.Log("PhotonHandler.Connect");
		try
		{
			peer.Connect(serverHost, appName);
		}
		catch (Exception e) { Debug.Log(e); }
	}

	public void Disconnect()
	{//Debug.Log("PhotonHandler.Disonnect");
		try
		{
			peer.Disconnect();
		}
		catch (Exception e) { Debug.Log(e); }
	}

	public void SendGameRequest(byte customOpCode, Dictionary<byte, object> customOpParameters, bool sendReliable)
	{
		peer.OpCustom(customOpCode, customOpParameters, sendReliable);
	}

	public void SendGameRequest(byte customOpCode, Dictionary<byte, object> customOpParameters, bool sendReliable, byte channelId)
	{
		peer.OpCustom(customOpCode, customOpParameters, sendReliable, channelId);
	}

	public void OnOperationResponse(OperationResponse operationResponse)
	{//Debug.Log("PhotonHandler.OnOperationResponse: "+operationResponse.OpCode);
		switch (operationResponse.OperationCode)
		{
			default:
				if (gameListener != null) gameListener.OnGameOpResponse(operationResponse);
				else Debug.Log("PhotonHandler.OnOperationResponse ERROR");
				break;
		}
	}

	public void OnEvent(EventData eventData)
	{//Debug.Log("PhotonHandler.OnEvent: "+eventData.Code);
		switch (eventData.Code)
		{
			default:
				if (gameListener != null) gameListener.OnGameEvent(eventData);
				else Debug.Log("PhotonHandler.OnOperationResponse ERROR");
				break;
		}
	}

}

Comments

  • Tobias
    Options
    This is not an actual freeze, or is it? It is a freeze when you display the current time (in OnGUI) and this freezes.
    You should always get and handle the return that Connect() provides. It's a bool and if that's false, something is totally wrong and you need to display a message.
  • ximael
    Options
    It is actual freeze, my browser stops responding. When freezes unity editor it stops responding either.
    There isn't any error message, cause it freezes when .unity3d file 100% loaded or when you press play in unity editor.

    WebPlayer log:
    130425 03:18:27 ------------------------------------------------------------
    130425 03:18:27 Instance starting, version 4.0.1f2_9bb580cddf70, UNITY_WEB_ENABLE_AUTODOWNLOAD: 1, GetDisableAutoUpdates(): 0
    130425 03:18:27 Datafile http://somesite.com/WebPlayer.unity3d
    web: player version 3.5.7f6
    GfxDevice: creating device client; threaded=0
    Direct3D:
        Version:  Direct3D 9.0c [nv4_disp.dll 6.14.13.681]
        Renderer: NVIDIA GeForce 8800 GT 
        Vendor:   NVIDIA
        VRAM:     512 MB (via registry)
        Caps:     Shader=30 DepthRT=1 NativeDepth=1 NativeShadow=1 DF16=0 DF24=0 INTZ=1 RAWZ=0 NULL=1 RESZ=0 SlowINTZ=0
    web: load mono
    Mono path[0] = 'C:/Documents and Settings/Administrator/Local Settings/Application Data/Unity/WebPlayer/player/Stable3.x.x/Data/lib'
    Mono path[1] = 'C:/Documents and Settings/Administrator/Local Settings/Application Data/Unity/WebPlayer/mono/Stable3.x.x/Data/lib'
    web: start, src=WebPlayer.unity3d abs=http://bapp.scienart.com/WebPlayer.unity3d
    Initialize engine version: 3.5.7f6
    web: sucessfully initialized
    130425 03:18:28 loader: start ok
    130425 03:18:28 Times: download 0.4 load 0.7
    Loading webdata version: 3.5.7f6
    Begin MonoManager ReloadAssembly
    Platform assembly: C:\Documents and Settings\Administrator\Local Settings\Application Data\Unity\WebPlayer\player\Stable3.x.x\Data\lib\UnityEngine.dll (this message is harmless)
    Non platform assembly: C:\Documents and Settings\Administrator\Local Settings\Application Data\Unity\WebPlayer\player\Stable3.x.x\Assembly-CSharp.dll (this message is harmless)
    Loading C:\Documents and Settings\Administrator\Local Settings\Application Data\Unity\WebPlayer\player\Stable3.x.x\Assembly-CSharp.dll into Unity Child Domain
    Non platform assembly: C:\Documents and Settings\Administrator\Local Settings\Application Data\Unity\WebPlayer\player\Stable3.x.x\Photon3Unity3D.dll (this message is harmless)
    Loading C:\Documents and Settings\Administrator\Local Settings\Application Data\Unity\WebPlayer\player\Stable3.x.x\Photon3Unity3D.dll into Unity Child Domain
    - Completed reload, in  0.088 seconds
    <RI> Initializing input.
    
    <RI> Input initialized.
    
    desktop: 1680x1050 60Hz; virtual: 1680x1050 at 0,0
    Platform assembly: C:\Documents and Settings\Administrator\Local Settings\Application Data\Unity\WebPlayer\mono\Stable3.x.x\Data\lib\System.dll (this message is harmless)
    Platform assembly: C:\Documents and Settings\Administrator\Local Settings\Application Data\Unity\WebPlayer\player\Stable3.x.x\Data\lib\CrossDomainPolicyParser.dll (this message is harmless)
    SocketPolicyClient1: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient1: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient1: About to WaitOne
    
    SocketPolicyClient1: Socket connected
    
    SocketPolicyClient1: Socket error: ConnectionReset
    
    SocketPolicyClient2: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient2: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient2: About to WaitOne
    
    SocketPolicyClient2: Socket connected
    
    SocketPolicyClient2: Socket error: ConnectionReset
    
    SocketPolicyClient3: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient3: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient3: About to WaitOne
    
    SocketPolicyClient3: Socket connected
    
    SocketPolicyClient3: Socket error: ConnectionReset
    
    SocketPolicyClient4: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient4: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient4: About to WaitOne
    
    SocketPolicyClient4: Socket connected
    
    SocketPolicyClient4: Socket error: ConnectionReset
    
    SocketPolicyClient5: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient5: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient5: About to WaitOne
    
    SocketPolicyClient5: Socket connected
    
    SocketPolicyClient5: Socket error: ConnectionReset
    
    SocketPolicyClient6: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient6: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient6: About to WaitOne
    
    SocketPolicyClient6: Socket connected
    
    SocketPolicyClient6: Socket error: ConnectionReset
    
    SocketPolicyClient7: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient7: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient7: About to WaitOne
    
    SocketPolicyClient7: Socket connected
    
    SocketPolicyClient7: Socket error: ConnectionReset
    
    SocketPolicyClient8: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient8: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient8: About to WaitOne
    
    SocketPolicyClient8: Socket connected
    
    SocketPolicyClient8: Socket error: ConnectionReset
    
    SocketPolicyClient9: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient9: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient9: About to WaitOne
    
    SocketPolicyClient9: Socket connected
    
    SocketPolicyClient9: Socket error: ConnectionReset
    
    SocketPolicyClient10: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient10: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient10: About to WaitOne
    
    SocketPolicyClient10: Socket connected
    
    SocketPolicyClient10: Socket error: ConnectionReset
    
    SocketPolicyClient11: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient11: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient11: About to WaitOne
    
    SocketPolicyClient11: Socket connected
    
    SocketPolicyClient11: Socket error: ConnectionReset
    
    SocketPolicyClient12: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient12: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient12: About to WaitOne
    
    SocketPolicyClient12: Socket connected
    
    SocketPolicyClient12: Socket error: ConnectionReset
    
    SocketPolicyClient13: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient13: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient13: About to WaitOne
    
    SocketPolicyClient13: Socket connected
    
    SocketPolicyClient13: Socket error: ConnectionReset
    
    SocketPolicyClient14: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient14: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient14: About to WaitOne
    
    SocketPolicyClient14: Socket connected
    
    SocketPolicyClient14: Socket error: ConnectionReset
    
    SocketPolicyClient15: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient15: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient15: About to WaitOne
    
    SocketPolicyClient15: Socket connected
    
    SocketPolicyClient15: Socket error: ConnectionReset
    
    SocketPolicyClient16: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient16: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient16: About to WaitOne
    
    SocketPolicyClient16: Socket connected
    
    SocketPolicyClient16: Socket error: ConnectionReset
    
    SocketPolicyClient17: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient17: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient17: About to WaitOne
    
    SocketPolicyClient17: Socket connected
    
    SocketPolicyClient17: Socket error: ConnectionReset
    
    SocketPolicyClient18: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient18: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient18: About to WaitOne
    
    SocketPolicyClient18: Socket connected
    
    SocketPolicyClient18: Socket error: ConnectionReset
    
    SocketPolicyClient19: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient19: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient19: About to WaitOne
    
    SocketPolicyClient19: Socket connected
    
    SocketPolicyClient19: Socket error: ConnectionReset
    
    SocketPolicyClient20: Incoming GetPolicyStreamForIP
    
    SocketPolicyClient20: About to BeginConnect to 127.0.0.1:843
    
    SocketPolicyClient20: About to WaitOne
    
    SocketPolicyClient20: Socket connected
    

    Seems, it is unity problem with crossdomain policy.
  • Tobias
    Options
    Ow, that could be! I didn't check Unity's crossdomain handling...
    You could report a bug to them and I could investigate if we can get rid of the freeze by prefetching the crossdomain manually (not sure if we can).