Exception while reading commands from incoming data

Options
t_fukushima
edited June 2013 in DotNet
Hello.
I encountered the Exception, but I can not know the cause.
I am using the SDK following

> ExitGames-Photon-Server-SDK_v3-2-10-4248
> Photon-Unity3D_v3-2-1-0_SDK

and My unity client received DebugReturn.

>DebugReturn
> Level = ERROR
> msg = Exception while reading commands from incoming data: System.ArgumentException: CompareBaseObjects can only be called from the main thread.
> Constructors and field initializers will be executed from the loading thread when loading a scene.
> Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

> at GameListener.DebugReturn(DebugLevel level, System.String message) in ...
> at ExitGames.Client.Photon.PeerBase+<>c__DisplayClass2.<EnqueueDebugReturn>b__0()
> at ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands()
> at ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands()
> at ExitGames.Client.Photon.PhotonPeer.Service()


What happened, Please tell me.

Comments

  • Tobias
    Options
    I can't reproduce the issue here - just re-tried the demo from our SDK.

    Please try to reproduce it with the demo loadbalancing from the SDK.
    If you can: Let us know how you build and for which platform.
    If you can't: Check if your callbacks are causing this issue somehow. DispatchIncomingCommands() can cause callbacks in your code.
  • Thanks for the response.

    So, I develop our titles client build by Unity3d 4.0.1f2, and Platform is Windows7.
    Server platform is Windows7 Professional or Windows Server 2008R2.
    I try to investigate the our callback function.
  • Tobias
    Options
    Let us know if you find it or how we could reproduce the problem.
  • I'm sorry to have kept you waiting and I have a question.

    I must not call the UnityEngine API from the callback method of the class inheriting the IPhotonPeerListener?
  • Tobias
    Options
    Calling UnityEngine API from callbacks should be fine in general. Maybe some side-effect is causing the issue.
    What exactly are you doing?
  • Unity API I'm running from the callback are as follows:

    -Debug.Log()

    and I read in another forum, 'It is an error to call the Debug.Log() from a other thread than the main thread'.
  • Tobias
    Options
    Ah, yes, that could be.
    We try to enqueue everycallback to be dispatched by the main thread, so the callbacks should normally be called from the main thread.
    Do you know which callback we are talking about?
  • >Do you know which callback we are talking about?

    I'm talking about the following callbacks:

    -IPhotonPeerListener.OnStatusChanged
    -IPhotonPeerListener.OnEvent
    -IPhotonPeerListener.OnOperationResponse

    Wrong?
  • Tobias
    Options
    I will re-check those. As said, usually we will call them only from the main-thread and logging is fine then.
    I didn't run into this issue yet.
  • Um...Once we have to disable Debug.Log(), problem no longer occurs.
    I try to reviewing our code again.
    Thanks.
  • Tobias
    Options
    I think I found some cases where incoming data might trigger a callback right away (in a "wrong" thread). I didn't decide yet how to refactor this.
    I would like to know more about this specific case: In which callbacks / situations was your issue triggered?