Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity Multiplayer Editor frequently freezing when clicking Play

Discussion in 'Connected Games' started by Flarup, Jun 12, 2018.

  1. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    60
    Hello all,


    After starting to work more with integrating Unity Networking as well as Unity DiscoveryService into our game, I frequently experiences that the editor freezes when I click Play. I don't get any errors in the Editor.log file, but it always ends with the following lines when it freezes:

    Packing sprites:
    [ 159 MB ]- Repacking is not required. Check took 62.729582 ms.
    [ 159 MB ]Reloading assemblies for play mode.
    Begin MonoManager ReloadAssembly

    After googling the issue I could see that closing down all the networking services was important to do. Thus, I have added the following method in our subclass of DiscoveryService:

    void OnApplicationQuit()
    {
    Debug.Log("OnApplicationQuit1");
    StopBroadcast();
    NetworkClient.ShutdownAll();
    NetworkManager.Shutdown();
    NetworkTransport.Shutdown();
    Debug.Log("OnApplicationQuit2");
    }

    I can see in the log that this code is being run whenever I exit Play mode in editor, but it doesn't fully solve my problem.

    We're using Unity 2017.4.3f1 and is building for Android.


    Any ideas why editor frequently freezes when clicking Play, after we've started integrating Unity Networking?


    Thank you very much in advance for all help.


    Kind regards,
    Uffe Flarup
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,584
    I don't have anything specific to your issue, just that the editor appearing to freeze in Play mode often is caused by getting caught in an infinite loop somewhere in your code. Something to look for.
     
  3. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    60
    I tried to look for that as well, but CPU usage is about 0% when it freezes. In the Windows Task Manager it looks like this:

    upload_2018-6-17_16-36-44.png

    (the red "Svarer ikke" text means "Not responding")

    If anyone knows why Discovery Service (or maybe some other part of Unity Networking) is causing Editor to freeze, I'll be really happy to know something about it.


    Kind regards,
    Uffe Flarup
     
  4. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    60
    Here's some additional information about what I've tried:

    1) I have attached the Visual Studio debugger. It CAN (after a while) figure out that the process it's attached to is not responding, but it CANNOT tell me WHY it's not responding, or WHERE the code is hanging.

    2) I have made a small editor script which shuts down NetworkClient, NetworkServer, NetworkManager and NetworkTransport, and I run this script after I have run the game in Editor, to make sure that all Unity networking code gets shut down. Unfortunately, the editor still frequently freezes when I click Play in Editor.

    3) It never freezes the FIRST time I click Play after having restarted Unity Editor. And it only freezes if I've been running a game where I used Unity networking.

    4) When I click Play, it doesn't even get to clearing the Console before it freezes. And it doesn't even get to call my Awake functions.

    5) As seen in my post above, CPU usage is 0% when it freezes, so it doesn't look like an infinite loop.


    Any good ideas about how to debug such a freeze in the Unity Editor?

    Thanks a lot in advance.


    Kind regards,
    Uffe Flarup