Photon Handler Dispatch Incoming Commands HIGH CPU USAGE

I have a serious issue with photon. After running the profiler I can see that Dispatch Incoming Commands is at 90%+ and makes my game unplayable. Why is this happening? Please help me.
I can't play my game with anyone after somebody joins besides me I lag brutally.

Comments

  • Hi @aidangig,

    How many networked objects (e.g. PhotonViews) do you have in the scene? If you have too much objects, this might have a bad influence in terms of performance. Another thing is about the errors logged to the console. Is the CPU usage the same when fixing the issues. Logging errors to the console is somehow expensive in terms of performance.
  • I have just the players connected as the photon views in the scene. Nothing else. That is why I am so confused.
  • Hi @aidangig,

    How many networked objects (e.g. PhotonViews) do you have in the scene? If you have too much objects, this might have a bad influence in terms of performance. Another thing is about the errors logged to the console. Is the CPU usage the same when fixing the issues. Logging errors to the console is somehow expensive in terms of performance.

    Do you have any other advice for me?
  • What about those errors logged to the console? Have you tried to get rid of them?
  • Hi @aidangig,

    Thank you for choosing Photon!

    Try running and profiling PUN demos to see the difference.
  • Hey Everyone!

    Thanks for the support. There is another issue that could be the reason why the Dispatch Incoming Commands is causing so much usage when another player joins.

    The findobjectsoftype is called in a particular script. You can find the script in the link I shared. Please open the link and give me some insight.

    Here is my question on the Unity answers - https://answers.unity.com/questions/1512637/unity-findobjectsoftype-ruining-my-performance.html
  • Never mind. I solved it. It was Photon Network code. I fixed it though in the end. :)
  • JohnTubeJohnTube mod
    edited June 2018
    Hi @aidangig,

    Thank you for choosing Photon!

    Care to share how you solved this and how you modified PUN's code?
    Maybe we can benefit from this and include it in a next update so you won't have to go through any inconvenience when updating PUN.

  • I have the same problems, is there a solution?
  • Hi @Brodyaga,

    Thank you for choosing Photon!

    I guess you use PUN 1 or PUN Classic.
    The problem is due to Unity's FindObjectsOfType.
    Could you switch to PUN2? It may have reduced or removed usage of FindObjectsOfType.

    Or we could ask @aidangig how he managed to improve the performance here.
  • Out of my head, I don't know if you can work around this without PUN modification.
    If so, it's on this page: "Optimization Tips"
    https://doc.photonengine.com/en-us/pun/current/gameplay/optimization
  • @JohnTube, I would gladly switch to PUN 2, but there is no declared support for Playmaker.
  • Did you have a look at the optimization page? Using PhotonNetwork.SendMonoMessageTargets should really help. It's also an option to create a MonoBheaviour subtype for the components that should get callbacks (versus all the scripts that should not). Then set PhotonNetwork.SendMonoMessageTargetType.

    I think Playmaker support for PUN 2 is coming up.
Sign In or Register to comment.