Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Loading Screen freezes on Windows Phone

Discussion in 'Windows' started by sentendo, Oct 24, 2014.

  1. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    Hi all,
    I am developing a game for Windows Phone (8.0) and when I change scene with the LoadLevelAsync() (I have the PRO version) I call another thread with a loading screen with a simple animation.
    In Unity Editor all goes well, but when I deploy a Master version on my test device it freezes when the scene actually changes.
    What can I do to solve that?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Hi,

    which Unity version are you on?
     
  3. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    Hi,
    I'm using the last one: 4.5.5
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Does this reproduce consistently? Does it load eventually and just doesn't display anything until then or does it totally freeze?
     
  5. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    It actually loads the new scene. For example I can perfectly hear the music of the new scene, while the loading screen I made is freezed. Then the new scene appears, but a freezed animation for loading is actually useless.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    How have you implemented the "animation"?
     
  7. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    yes, with an external tool (NGUI).
    But I launch it in another thread.
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    How are you launching it in another thread? Unity API is not thread safe, which means you may only access it from Unity main thread. Could you post the code?
     
  9. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    I call the coroutine with:

    Code (CSharp):
    1. private void changeToScene (string newScene){
    2. _newSceneName = newScene;
    3. StartCoroutine ("change");}
    4.  
    and the coroutine which makes the loading and the scene change is:

    Code (CSharp):
    1. IEnumerator change() {
    2. _async = Application.LoadLevelAsync(_newSceneName);
    3. _async.allowSceneActivation = false;
    4.  
    5. while (!_async.isDone) {
    6.  
    7. if (_async.progress >= 0.9f){
    8. _async.allowSceneActivation = true;
    9. }
    10. yield return null;  
    11. }
    12. }
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Coroutines aren't actually executed in another thread. They get called on the main Unity thread.

    I'm not sure what might cause this. Does the scene work correctly when you load it using Application.LoadLevel?
     
  11. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    The scene works properly, yes (of course with the same problem).
    I think it may be the internal function of scene change which blocks the mobile phone (and so even the loading animation). Is it correct? Is there a way to avoid that? On some mobile phone (such the Lumia 630, for instance) it is a serious issue, since the game could appear "freezed" to the players.
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    You mean the scene is black when you load it normally too? So it's not really related to LoadLevelAsync?
     
  13. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    nope, the scene freezes even without any loading screen (as I did before to implement that function)
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    What happens if you make that scene the first scene that Unity loads when you start the game?

    Furthermore, do you have any image effects on the camera in that scene? I've seen them causing such issues in the past, though I think we did fix majority of those cases.
     
  15. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    right now I can't try to put the scene as the main one, since the main is setting up various stuff for the game.
    I have no image effects on my camera.
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    I honestly have no idea what could cause this - did you try removing stuff from your scene to find the culprit?
     
  17. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    I have tried, yes.
    By the way, the question is: does the internal function (the one which changes the scene) block the execution?
    If yes, is there an easy way to avoid that?
     
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Any luck? How much of the scene did you manage to delete?

    I don't quite understand the question. Application.LoadLevel is blocking. Application.LoadLevelAsync is not. Either way, the loading is done in a separate thread, just in the first case, the API blocks until the new scene is ready.
     
  19. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    no lucks :(

    I know the LoadLevelAsync is not blocking, but the problem is when the load is done and internally Unity3D makes the switch.
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Could you be more explicit about it? What problem are you talking about?
     
  21. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    I am just arguing that the function LoadLevelAsync() does something internally when it changes the scene from the previous to the new one. Maybe this part is blocking, could it be?
     
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    It doesn't change the scene in middle of your script, if that's what's you're asking.

    As for the black screen: is there anything useful in the player log?

    Other than that, probably the easiest way to find out what's causing this is to do a binary search on your scene: delete half the objects, if it's still reproducing, delete a quarter, and so on. Once it doesn't reproduce, you know that the thing that caused it is in the list of objects you have just deleted.
     
  23. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    ok, I will try this way. Anyway there is not any black screen at all, only a freeze.
     
  24. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Didn't you say that it doesn't render anything but the sound is there? Might it be that the camera is set to "Don't clear"?
     
  25. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    no, perhaps I expressed myself badly: the game freezes, the sound is there and actually it loads the new one (the music of the new scene). There is not any black screen at all.

    The camera is not set to "Don't clear".
     
    Last edited: Oct 27, 2014
  26. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    If you run out of patience investigating this, feel free to submit a bug - something like this should be fairly obvious to find out and if it isn't, it's a bug.
     
  27. MrXee

    MrXee

    Joined:
    Jan 20, 2014
    Posts:
    7
    @sentendo, has there been any development regarding this issue? I am currently having issues with loading screen freezes on Windows Phone 8.1 and I'm having a hard time figuring out what is the cause. Please let me know if you solved this issue.

    I'm currently having it freeze a lot in multiplayer mode and I am wondering if it's because the multiplayer plugin might not be thread safe with Unity. My issues might not be at all related with yours though but the lack of logs and debug information is leaving me in the dark.

    p.s. I'm using Unity 4.5.5p5
     
    Last edited: Nov 27, 2014
  28. sentendo

    sentendo

    Joined:
    Sep 23, 2014
    Posts:
    47
    sorry @MrXee but I had to remove the animation. I could not resolve my issue.
     
  29. bgprocks

    bgprocks

    Joined:
    Oct 28, 2012
    Posts:
    8
    Was a fix ever found for this??? I have my game freezes after a couple seconds. Game work on all platform, but when deploys to windows phone 8.1 it freezes a couple of second after startup. Just to make sure i was not crazy, i create a new project from scratch. Swtich the platform to windows phone 8, put a cube in the scene, attach a script that spins the cube, build and run....same thing. I see the cube spinning for a fews seconds then stops. I am using unity 5.1.

    I use application.loadlevel in the game, but in the test project, i am not even changing scenes....and it still freezes.
     
  30. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Try breaking in a debugger to see where it freezes. It should give you exact callstack.
     
  31. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    I'm also experiencing freezing on game startup in Universal 10 phone builds on 5.2.1p1.

    Tautvydas: Not sure how to detect where it is freezing in the debugger. I'm able to step through the game init code at first, but then I eventually have to let the game run and then it freezes. Not seeing anything in the VS output window.
     
  32. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Break (pause execution) in the debugger and look at the callstack. It should show you exact place where it's happening.
     
  33. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    After turning off Just My Code, here is what I get (in App.g.i.cs):

    upload_2015-9-30_12-18-40.png

    upload_2015-9-30_12-18-17.png
     
  34. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    You're probably looking at a wrong thread. In VS, press Debug -> Windows -> Parallel Stacks, it should show you the stacks of all threads.
     
  35. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Ah, thanks didn't even know about that. Here's what I'm seeing now. I tried finding the UnityEngineProxy.pdb in the <proj>/players folder but it doesn't seem to exist.
    upload_2015-9-30_12-24-21.png
    upload_2015-9-30_13-40-29.png
    upload_2015-9-30_13-40-14.png
     
  36. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Just tried installing Unity 5.2.0f3 and the project does work on the phone in Windows 10 Universal. So something in 5.2.1 broke it, it appears.
     
  37. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    @noethis, could you go to project properties -> debug -> debugger type, set it to native, save the project, and then find the callstack again? It should give us more insight into what's failing within the engine.
     
  38. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Here's the native callstack. Can't look at the code because it can't load symbols for ntdll.pdb.
    upload_2015-9-30_15-22-9.png
     
  39. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Can you load symbols for UnityPlayer.dll instead? That's the thing we care about.
     
  40. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Is this it? Attached the disassembly.
    upload_2015-9-30_16-22-15.png
     

    Attached Files:

  41. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Yea you're on the wrong thread. Could you show the stacktraces of all threads, or put them to a text file and attach it to your post?
     
  42. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Haha, thanks for being patient with me. :)

    Here's the parallel stacks display. Unity specific threads all seemed to be on the right. Is there a specific thread I'm looking for?
    upload_2015-9-30_17-1-7.png

    upload_2015-9-30_17-0-50.png
     
  43. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Yes, looks like that's the correct one! I suppose the stacktrace of that thread doesn't change much, if at all?
     
  44. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Actually it does appear to be changing every time I pause. Attached a few of the stacks.
     

    Attached Files:

  45. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Could you try disabling Unity analytics to see if it fixes it? The stack trace points somewhere there.

    In mean time, I'll ask our analytics team if they know anything about it.
     
  46. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Did that help? Unfortunately, we are unable to reproduce this issue locally. Is there any chance you could submit a bug with a repro project?
     
  47. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Odd, thought I replied to this. Anyway, yeah, disabling Unity Analytics allows it to run now.

    I'll try and submit a repro. One weird thing that may or may not be related is that every time I load my Unity project the Unity services aren't properly setup. I made a thread about it here: http://forum.unity3d.com/threads/services-keeps-disabling.349085/