Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Shader Graph Massive Lag Spike in Unity Editor

Discussion in 'Editor & General Support' started by sourtess, Jan 21, 2019.

  1. sourtess

    sourtess

    Joined:
    Nov 19, 2017
    Posts:
    6
    Hello everyone,

    I am currently working on a VR project for Oculus Go and have recently decided to use Shader Graph to create custom shaders which allow for fancy animation and manipulation. However, each time I open graph of some fresh shader, I can't even move nodes around / set connections / etc. because Editor causes delay in about ~3 seconds between each action. Simply moving node from one place to another can take about 5-6 seconds. The project itself runs on Oculus Go smoothly, so I experience no issues with lightweight pipeline itself.

    I am using MacBook Pro 2018 and so far I experienced no issues with any kind of delay or lag spike in Unity Editor. I was wondering if anyone experienced the same and I would be really glad to get the community support on this one since Shader Graph would help my team to advance immensely. I can provide any additional information on project settings / laptop specifications if needed (I am just not sure where to start).

    Thanks!
     
    knightOfSecrets likes this.
  2. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    737
    Hello,

    Can you share an Editor.log file after this session? We add some performance statistics and that can be a good way for use start identifying the issue. A profiler dump would be extremely helpful as well :

    1. Open the Profiler window (Analysis > Profiler)
    2. Enable "Profiler Editor" in the toolbar which should start recording
    3. Interact the slow ShaderGraph
    4. Stop recording and use the "Save" action from the toolbar to share the session with us

    One other question : do you think the performance is affected by the size of the graph, e.g. number of nodes / edges?

    In the 2019.1 cycles we have a bunch of performance improvements for the rendering of nodal UIs like ShaderGraph but basic interaction like dragging nodes around should be fairly snappy even in 2018.3.
     
  3. laessnb

    laessnb

    Joined:
    Jun 10, 2014
    Posts:
    101
    For us it's only with complicated shader graphs (100 nodes or so, often with a few subgraphs). Each action, no matter how trivial, causes a preview recompile (often even just adding a new property without rewiring it), which takes over 10 seconds.
     
  4. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    737
    Ok it seems like this might come from Shader Graph itself and not the UI technology layer I was suspecting caused issue for you. I'll let the product team chime in on that, thanks for your reply.
     
  5. saschka

    saschka

    Joined:
    May 24, 2014
    Posts:
    5
    Yep same thing here. I first thought it's cause I'm on a 2015 MacBook but now switched to a 2018 MacBook Pro and it's exactly the same thing. Unity & co is super smooth and the shaders or VFX play super smooth in the editor but as soon as the shader graph window is opened all interactions lag 2-3 seconds. I'm surprised that this is now constant on my second laptop. (first was Unity 2018, not trying 2019, all the same effect) It basically makes any shader graph / VFX graph usage impossible.

    Any general news on this?
     
    Last edited: Mar 31, 2019
  6. saschka

    saschka

    Joined:
    May 24, 2014
    Posts:
    5
    Ok here's a strange observation. The shader graph interface runs super smooth unless it covers to top part off the unity interface (The title bar and the play / tool bar). As soon as I move it over that the interface & unity are super laggy (2-5sec for any interaction). Then when I move the shader graph window lower in the frame everything recovers slowly.

    So it's usable for now.
     
  7. sroq

    sroq

    Joined:
    Jun 28, 2015
    Posts:
    13
    Hi, I have the same issue. Macbook Pro 2016/Unity2019.1.0b9. The shader graph editor is lagging. It is very uncomfortable. The issue is still if the graph is very simple (or empty), but only if the shader editor runs in separated window (as Saschka mentioned above).
     
  8. fuzzygoat

    fuzzygoat

    Joined:
    Feb 11, 2016
    Posts:
    29
    Hi, does anyone know what causes this? I am having the same problem, where if the top left corner of the SG window overlaps the top left corner of the Unity editor (where the rotate, move, scale tools are) then the SG UI frame rate drops to 2 FPS and the computers fans spin up to full. I am using Unity 2019.1.0f2, LWRP 5.7.2 running on macOS Mojave 10.14.4 (iMac 5k)
     
    Last edited: Apr 29, 2019
  9. NineOhGames

    NineOhGames

    Joined:
    May 15, 2017
    Posts:
    3
    Are you using a second monitor? I've noticed the same issue when I have the shader graph window open in my second monitor but runs pretty smoothly when I disconnect the second monitor and use the laptop monitor instead
     
  10. krides

    krides

    Joined:
    Apr 7, 2011
    Posts:
    38
    Yep. This "solved" my issue with it too.
     
    Nightsquid likes this.
  11. djsell

    djsell

    Joined:
    Aug 29, 2013
    Posts:
    77
    Wow, I came to this thread because I was having the same issue on my 2016 MBP. Same result here. If I have the shader graph editor maximized overtop of Unity, the shader graph editor is practically unusable. If I drag the top of the shader graph editor down a little so that unity title bar is visible behind, it works flawlessly. I can also keep the shader graph editor maximized if I minimize Unity without any performance hit.
     
    etahnp likes this.
  12. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    I can confirm having the above issues on Mac OS Mojave 10.14.5 (2018 MacBook). I can only work with the Shader Graph if I close the main Unity window when working in a separate Shader Graph window.

    In addition, I noticed another issue – the Shader Graph freezes whenever I set a parameter name on the blackboard to one that includes spaces. In this case I have to close the Shader Graph window and reopen it.

    I do not have any of these issues in the Visual Effects Graph – assuming they use the same underlying framework, I'd wager a guess that the issues are indeed in the Shader Graph.

    If anyone from Unity would like more info, please let me know.
     
    chrismarch likes this.
  13. thecrippler

    thecrippler

    Joined:
    Feb 11, 2017
    Posts:
    4
    I get pretty bad slow-downs in a few situations. The following are consistently reproducible on Window and Mac:

    • When I have a sub-graph included, I get a "compiling preview shaders" when I do just about anything. Connect/Disconnect a node, add a node, duplicate a node.
    • Large graphs (100+ nodes) cause low frame rate and poor interaction in the Scene View window (worse when using sub-graphs).
    • The scene view window slows down significantly more when I have the shadergraph window docked. Floating the window definitely improves performance. Closing any shadergraph windows will return the scene view to normal performance.
    • When I have a sub-graph and another shader open in two separate windows, and the shader has that same sub-graph included I get a complete freeze after about 3-5 edits. Each time I make a change the shader compile time seems to double or triple. I've been able to work around this by making 1-2 edits in the sub-graph, without the shader open, then restarting unity.

    I'm using Unity 2019.1.10f1, LWRP 5.7.2
    Windows 10 and MacOS Mojave 10.14.6
     
  14. Neogene

    Neogene

    Joined:
    Dec 29, 2010
    Posts:
    93
    Macbook Pro Mojave 10.14.6 (2018 MacBook Pro - 32GB RAM), with 4-5 nodes using time it starts to lag as hell. Unity 2019.2.6 Mac.

    Ok after some tests the only way to avoid lag/freezes is to disable Editor Metal support inside Player Settings.
     
    Last edited: Sep 28, 2019
  15. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    386
    MacBook Pro (15-inch, 2017) Mojave IOS
    2.8 GHz Intel Core i7
    16 GB 2133 MHz LPDDR3
    Radeon Pro 555 2048 MB
    Just added a PBR shader in LWRP and added two nodes .Mac hangs.I think making the shader window in full screen causes the issue(Not sure).
     
  16. knightOfSecrets

    knightOfSecrets

    Joined:
    Jul 29, 2019
    Posts:
    2
    I am having the same issue, its even worse, you say it takes 3 secs and 5 secs, in my case its minutes
     
  17. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    467
    Still occurs in 2019.3.9f1 with Shader Graph 7.3.1 on Mac OS 10.14.4 on a MacBook Pro 15-inch 2018. If I attempt to do any interactions (drag, click fields, etc.) with the properties window inside the Shader Graph window, it moves at ~1-4 fps. This is with a brand new PBR shader graph with only the default nodes. However, if I minimize the Unity Editor and keep the Shader Graph window visible, I can interact with the properties window at a reasonable framerate. Thanks for the tip!
     
    Peter-Chen and florianhanke like this.
  18. Peter-Chen

    Peter-Chen

    Joined:
    Jan 19, 2016
    Posts:
    2
    This problem persists in 2021.1. I have submitted a bug report from Unity editor.
     
  19. cofcof

    cofcof

    Joined:
    Sep 17, 2013
    Posts:
    10
    Yeah, I am having the same problem I have a complex Triplanar sub-graph, its a little annoying but I will deal as long as it's not me screwing up that will lead to user end lag.
     
  20. spiglebach

    spiglebach

    Joined:
    Aug 4, 2020
    Posts:
    1
  21. besttof

    besttof

    Joined:
    Jul 17, 2012
    Posts:
    29
    Disappointingly this is still an issue two years later, and looking at the (deep) profiler it is obvious that drawing the UI is the issue here:

    upload_2021-12-25_12-21-18.png

    This is the result of panning around a bit in an empty, fresh shader graph in Unity 2021.2.6f
     
  22. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Sooo, found this post. Sorry for the necro, but hopefully this will be to some use for somebody.
    It's not a perfect match for the upper posts, but, who knows.

    Fault description: Connecting nodes with edges causes lag spikes.
    Analysis: Connecting can cause much of Garbage (GC alloc). Starting point is
    NodeUtils.GetForest()
    , followed by some recursive calls
    NodeUtils.GetChildNodesRecursive()


    Deep profiling example of a reduced graph:
    deepProfile.png

    Swallow profiling example (reconnect an existing edge) of a bigger graph
    (> 2GB GC, > 50M GC calls, deep profiling fails):
    highConnectGraph.png
    swallowProfileHighGC.png
    Solution in my case:
    Putting the nodes with the high connection count into a sub-graph. The higher level is now responsive (<1 s lag).
    highInternalConnectSubGraph.png

    It seems the complexity for traversing edges of the graph seems to be of some kind of O(n²).
    I don't know if this is only for nodes with high port-count or for all the edges in the graph.

    Packages:
    Unity 2021.2.13f1, also tested previously with 2021.2.3f1
    ShaderGraph 12.1.4

    I hope this helps. Greetings.

    [Edit: Made the images thumbnails]
     
    MattDavis likes this.