Search Unity

[UI][Unity 2018.3] Does Canvas.BuildBatch depend on game resolution?

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by dwit_mass_creation, Apr 25, 2019.

  1. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    50
    I have weird problem on PC.
    It looks like Canvas.BuildBatch depends on game resolution.
    I have animation in canvas so it rebuilds in every frame.

    In my scene profiler in Editor shows:
    - for HD(1080p): Canvas.BuildBatch ~ 0ms (or close to it)
    - for 4K: Canvas.BuildBatch ~ 3-4ms

    For build it shows even for smaller resolution: even for HD there is Canvas.BuildBatch 3-4ms. But for smaller resolution it disapears.

    Unfortunatelly there is no source code so I cannot understand why BuildBatch depends on resolution.

    I tested it on Unity 2018.3.10 and 2018.3.13.
     
  2. ozonex

    ozonex

    Joined:
    Dec 7, 2012
    Posts:
    12
    I tested this problem more on my device and I have some interesting findings.

    In the editor, when i expand Game window to 2450x1080 everything works fine, 7ms total on CPU (BuildBatch 0.01ms), but when i extend it to 2500x1080 Canvas.BuildBatch starts using additional 7ms alone every frame on the cpu. On 2480x1080 it takes ~3ms.

    Few more pixels makes it calculate something expensive, so it looks like bug. I have no idea how resolution can affect building batch of canvas.

    I disabled everything in canvas and left only one animated sprite (animated position and color). When sprite animates it force canvas to rebuild, thats ok. But somehow in our case it takes lot of CPU after exceeding certain resolution.

    On every device that resolution is different. On some its lower than 1920x1080 so our game works very poorly on them at that resolutiin, because BuildBatch uses 50-60% CPU.

    Any ideas why Canvas.BuildBatch can depend on game resolution?
     
  3. dwit_mass_creation

    dwit_mass_creation

    Joined:
    Jun 18, 2015
    Posts:
    50
    It looks like Canvas.BuildBatch is waiting for Render Thread so when I disable all UI frame time is still the same but instead of Canvas.BuildBatch it is Gfx.WaitForPresent. So it was a problem with frame time.

    Btw problem with frame time was caused by Windows DirectX 11 and VSync. Only Exclusive Fullscreen is working ok. Fullsceen Window had problems on worse hardware (for example laptops). For other renderers (DirectX 12, Vulcan, OpenGL) or without VSync (even for DirectX 11) this problem didn't occur.