Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Black border in UWP app

Discussion in 'Windows' started by Stef93, Aug 23, 2019.

  1. Stef93

    Stef93

    Joined:
    Jul 15, 2014
    Posts:
    5
    I'm running a Unity UWP app with the Unity view in a grid like so:

    Code (CSharp):
    1. <Grid Background="Gray">
    2.         <Grid.ColumnDefinitions>
    3.             <ColumnDefinition/>
    4.             <ColumnDefinition Width="3*"/>
    5.             <ColumnDefinition/>
    6.         </Grid.ColumnDefinitions>
    7.         <Grid.RowDefinitions>
    8.             <RowDefinition/>
    9.             <RowDefinition Height="3*"/>
    10.             <RowDefinition/>
    11.         </Grid.RowDefinitions>
    12.         <Frame Grid.Row="1" Grid.Column="1" x:Name="UnityFrame"/>
    13.     </Grid>
    This works fine, except for the fact that a black border appears right after Unity starts rendering. Initially everyting looks good as it's starting up:

    This is what it looks like when I take a screenshot after it's done loading:

    Looks perfectly fine, except there's actually a black bar on the left and top (not right and bottom), that's not visible in the screenshot:

    It seems like the bars are even outside of the frame element:

    The bottom and right side are perfect without any bars. Something to note is that it does appear without bars for a fraction of a second and then adds them afterwards. Also, the bars disappear when the app is out of focus. When the app (not necessarily the Unity frame) gets brought back into focus, the bars reappear. You should be able to recreate this by simply building any UWP app and editing the MainPage.xaml to something like:


    Code (CSharp):
    1. <Grid Background="Gray">
    2.         <Grid.ColumnDefinitions>
    3.             <ColumnDefinition/>
    4.             <ColumnDefinition Width="3*"/>
    5.             <ColumnDefinition/>
    6.         </Grid.ColumnDefinitions>
    7.         <Grid.RowDefinitions>
    8.             <RowDefinition/>
    9.             <RowDefinition Height="3*"/>
    10.             <RowDefinition/>
    11.         </Grid.RowDefinitions>
    12.         <SwapChainPanel Grid.Row="1" Grid.Column="1" x:Name="m_DXSwapChainPanel">
    13.             <Grid x:Name="m_ExtendedSplashGrid" Background="#FFFFFF">
    14.                 <Image x:Name="m_ExtendedSplashImage" Source="Assets/SplashScreen.png"/>
    15.             </Grid>
    16.         </SwapChainPanel>
    17.     </Grid>
    Anyone have any ideas as to what these lines are and why they are being added?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,651
    A few ideas:

    1. Do you know what the border thickness is set to? Perhaps it's default to something similar.
    2. Perhaps it's indicating XAML element focus?
    3. It's really weird it's not visible in screenshots! Perhaps it's some kind of debugging thing? Does it happen when you launch app from start menu rather than Visual Studio?
    4. Are you certain this happens due to Unity rendering? Did you try using graphics debugger to see the resolution Unity is rendering at vs the actual size of the swapchainpanel?
     
  3. Stef93

    Stef93

    Joined:
    Jul 15, 2014
    Posts:
    5
    Here's a video of the problem:

    In the video I'm starting starting the app with Visual Studio in focus. When I set focus to my own app with the mouse, the bars appear. Then I alt-tab a couple times.

    1. I have checked the BorderThickness from the Grid down to the SwapChainPanel and they are all 0 or striked through. I have also set the primary and secondary FocusVisualThickness to 0 wherever possible. I couldn't reach the ContentPresenter and the UnityView to set those.



    2. I've added a button and a textbox and the black lines remain even when I focus on the button or textbox. The black lines appear and disappear when alt-tabbing between applications.
    3. It does still happen in a release build when I start it from the start menu, unfortunately. I've also tested in on a different computer and it still happens.
    4. Due to the domain and/or firewall settings at the company I work at, I can't install the graphics debugger. I've set the resolution of the frame to a hard 500x500 in XAML. From there I tried setting Unity's render resolution, but that has no effect on the bars.

    Are you able to replicate it by placing the SwapChainPanel in a Grid?

    EDIT: I have now implemented a button that calls the UnityPlayer.AppCallbacks.Instance.UnityPause() function and I notice that the black bars disappear when the game is paused. They reappear when the game continues.
     
    Last edited: Aug 27, 2019
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,651
    Visual Studio includes a graphics debugger, you don't need to install anything extra. You can do Debug -> Graphics -> Start Diagnostics.
     
  5. Stef93

    Stef93

    Joined:
    Jul 15, 2014
    Posts:
    5
    I don't have that option. I can go to Debug > Graphics > Start Graphics Debugging an Installed App Package and I get:



    Then I click yes and it tries to download and install, but after a while it says:



    Regardless, I did some more testing with other versions. I am currently working with Unity 2019.2.1f1. When building a UWP app in Unity 2018.1.9f2 the black bars never disappear. Even if it is out of focus. This occurs with both the .Net and IL2CPP backend. It also seems to be a part of Unity as the bars are not visible while the splash screen is playing and they only appear after the scene has been loaded.

    Edit: Previously I tested it on a different, but similar laptop. I now did a test build on a different computer entirely (Surface Studio 2 specifically) and I'm not getting the black bars on that. I suspect it may be something driver or hardware (graphics card?) related. I don't intend to find a fix anymore since it is a minor issue and inconsistent across hardware.
     
    Last edited: Aug 28, 2019
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,651
    Can you submit a bug report on this? We can then dig into it further.