Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug Vulkan with multiple displays hangs on splash screen when second monitor unplugged

Discussion in 'Linux' started by jnobleIT, Apr 29, 2024.

  1. jnobleIT

    jnobleIT

    Joined:
    Oct 10, 2016
    Posts:
    5
    I have a game using vulkan running on Ubuntu 22.04 that looks to see if Display.displays.Length is greater than 1 and activates the second display if it finds it. The second display is a touchscreen display that supports touch there in case that is relevant. I have everything working - both screen work great with vulkan and can maintain 60fps with mutiple displays and everything is running well.

    If I disconnect the second display Unity will not get past the splash screen and never makes it to any of my code. I don't think it even launches the first scene that I can tell - none of my awake methods log out. If I plug the second monitor in then it will proceed - even if I hot plugged it in it will just start running again. It feels like something is cached somewhere that tells Unity that it had two screens last time and it will just sit there waiting for the second screen to show up. I want it to just continue on with only the one screen and my game will handle that, but it just hangs.

    My current workaround is to build with support for both opengl & vulkan. Then I check in a shell script to see if the display count is > 1 and then launch it with vulkan otherwise launch it with opengl and that works, but is not a real solution. I tried deleteing the persistant folder, the /tmp folder and completely re-copying the game to my system but if it ever started with 2 monitors it will never start with only one again that I can see.

    I am currently using 2021.3.8f1 (stuck here because of an audio bug). The last entry I see in the Player.log is usually this or the next one:
    "InitializeOrResetSwapChain 1080x1920 hdr=0 samples=1"
    "Desktop is 1080 x 1920 @ 60 Hz"

    But I never get to the what is typically after those:
    "UnloadTime: 0.804973 ms"

    I feel like there must be caching going on somewhere with vulkan that isn't the /tmp or persistent data path, but I am not having much luck gooogling it. I marked it as a bug as I have a hard time believing this is intended behavior and I am betting this is not a common use case.

    Any assistance would be greatly appreciated.
     
  2. jnobleIT

    jnobleIT

    Joined:
    Oct 10, 2016
    Posts:
    5
    Update: I have created very tiny Unity apps that just show a canvas and some text and they also fail if the second monitor is disconnected, even though they have no code reference to displays and nothing in the scene references anything but display 1. The same apps work fine if I force opengl. The same issue as the big game where it hangs right after the "Desktop is 1080 x 1920 @ 60 Hz" line and sits there. It will hang until I plug the second monitor back in, even if it sits there for a long time, as soon as the second monitor is plugged in the app will continue.

    Vulkan must be detecting some remnants of the second monitor from Ubuntu even though it isn't plugged in and Ubuntu settings doesn't show it. It has to be sitting in a loop waiting for the monitor otherwise it wouldn't just pick up and continue as soon as it is plugged in.

    I haven't filed a bug yet - hoping someone knows more about this than I do and had something else to try or look at just in case it is me.
     
  3. tylerinthezoo

    tylerinthezoo

    Unity Technologies

    Joined:
    Jun 15, 2022
    Posts:
    97
    it would be easier to file a bug since i know that we have some weird multi-display bugs in the past but in your case I don't know what your code does.