Search Unity

[PC][important] Moving UI is cause of alt+tab crashes

Discussion in 'Editor & General Support' started by Kamyker, Nov 5, 2019.

  1. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Hello,

    You can see the bug here: https://www.twitch.tv/videos/504101312?t=00h05m28s

    TLDR
    Don't read this skip to 4th post. It took me around 10h to found the issue.

    Weird issue but it's crucial to make my game successful. Usually in Paladins (and many other games) players are waiting few mins in the queue for their next match. In that time they sometimes play other games keeping Paladins open in the background. That's the case with my game. The issues is that when match is found Paladins crashes Unity game as it tries to change active windows. What's worse is that Unity game can't be closed, Task Manager doesn't show so it freezes PC completely. Even worse is that I'm unable to reproduce this bug on my side making it very hard to find any workarounds. (Edit I am)

    This bug may be related to other ALT+TAB bug I've mentioned in https://forum.unity.com/threads/2019-2-8f-windows-standalone-player-alt-tab-crashing.763820/

    I'm building the game for Windows Standalone 64bit, il2cpp, Unity 2019.2.11f1.

    You can see my game on https://store.steampowered.com/app/1142220/BeatAim__Rhythm_Shooter/

    So far it's doing pretty good considering how little I did to promote it. Game is also very early in development but some players already love it. May be huge especially as it has infinite replayability and works perfectly for streamers that can take song requests from viewers. I need Unity help otherwise I'll be forced to freeze the project and port my game to other engine as bugs like that are unacceptable. I imagine part of refunded game copies come from the ALT+TAB bug itself.

    I guess disabling Exclusive Fullscreen may be a workaround but it's not acceptable in my case as the game is supposed to be highly competitive and disabling it increases input lag significantly.

    Edit
    Good news, I've been able to reproduce that bug, I will try to narrow the project to see if it's really engine issue...

    Edit2
    So far this bug is very random happens like 30% of the times. Doesn't matter if I'm playing my game or sit in the main manu.

    Edit3
    It actually does matter. I was very lucky to get the bug in menu. It was caused by DOTween and solved by updating to newest version. It's still weird to me that alt+tab didn't cause the issue but Paladins requesting to swap active windows did.

    Well one bug down but it still persists in the game.
     
    Last edited: Nov 6, 2019
  2. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    I've been testing it for 5h+ still bug is random, tried to narrow down by commenting a lot of code but it didn't help. I suspect there's infinite loop somewhere in Unity engine on windows swap. I'd say this is major issue with Standalone builds that if something like this happens users are not able to go to Task Manager and alt+F4 doesn't work.

    Wouldn't it be possible to somehow handle window minimizing, listening to Alt+F4 on separate thread to game? It looks like everything works on the same freezing pc completely if infinite loop happens.
     
  3. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Story continues... It seems that reason for Paladins bug are tweens libraries (or how Unity handles them). So far tried DOTween and LeanTween. It's probably linked to Alt+Tab crash players are having that I can't reproduce.

    Both those lines crash Unity when Paladins queue pop and it tries to minimize Standalone Unity build.
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         transform.LeanMoveLocalX(10, Random.Range(1f, 5f)).setLoopPingPong().setEase(LeanTweenType.easeInOutQuad);
    4.         //transform.DOLocalMoveX(10, Random.Range(1f, 5f)).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.InOutQuad);
    5.     }
    I've also upgraded to newest Unity version 2019.2.11f1.
     
  4. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Sad list of what crashes or not:
    • Empty build (actually 100 cubes doing nothing) - works (amazing)
    • DOTween - crash
    • LeanTween - crash
    • Surge Tween - crash
    • iTween - crash
    • Heavy load in Update (that makes my fps 5) - works
    • Heavy load in OnApplicatonFocus/Pause (that takes 1-2 sec) - works
    Narrowing down the issue it looks like crash happens when tweens do their work on UI element...

    Ok found it: if anything moves in the UI game freeze upon Paladins queue pop.

    1. Attach this to an image:
    Code (CSharp):
    1.     private void Update()
    2.     {
    3.         transform.position = new Vector3(Mathf.PingPong(Time.time, 3) * 100, transform.position.y, transform.position.z);
    4.     }
    2. Run Unity Build and Paladins.
    3. In Paladins go into training vs bots queue
    4. Alt tab into Unity game
    5. Wait for Paladins to find a game
    5. Freeze bcs of single ui element moving :eek:

    More:
    Bug happens with:
    - both Net and il2cpp
    - manipulating object's transform.position or ((RectTransform)transform)
    - Unity versions: 2019.2.8, 2019.2.11, 2019.3.0b9

    Bug doesn't happen with:
    - image component disabled on UI object
    - image object not moving
     
    Last edited: Nov 6, 2019
  5. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Simple project is in included to Bug Case 1196538
     
  6. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Good news Unity QA successfully reproduced the issue.
     
  7. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
  8. DropNodes

    DropNodes

    Joined:
    Jun 11, 2019
    Posts:
    39
    yeap voted, having the same issue in 2019.2.11f1, 2019.2.6f1 worked fine so it happened in one of the latest versions
     
  9. DropNodes

    DropNodes

    Joined:
    Jun 11, 2019
    Posts:
    39
  10. DropNodes

    DropNodes

    Joined:
    Jun 11, 2019
    Posts:
    39
    Did that issue solved in 2019.2.15? it's not in known issues (like it was in .14) but neither in the fixed list.
     
  11. DocFalko

    DocFalko

    Joined:
    May 15, 2018
    Posts:
    1
    Still an issue with some of my testers. Project uses UI extensively.
     
  12. DropNodes

    DropNodes

    Joined:
    Jun 11, 2019
    Posts:
    39
    they said it is fixed on 2019.2.16f1 which will be release these days
     
  13. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Got the issue again in 2019.3.11. Not sure what was the cause...

    Most annoying bug I've seen in any application/game/engine. Makes PC completely frozen.

    It happened when alt+tabbing while game is exiting.
     
  14. masterride2016

    masterride2016

    Joined:
    Jan 8, 2018
    Posts:
    1
    I had the saaame issue. For me, it happend because i used Vulkan. not DirectX11/12. weird bug indeed.
    So i switched to Directx12 and everything works fine!!
    (Unity version 2020.2.1f1)