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. Dismiss Notice

Bug Shader Graph is extremely slow since the LTS. 3000 MS instantiate of nodes.

Discussion in 'Shader Graph' started by EricFFG, Jun 2, 2023.

  1. Ben_at_Work

    Ben_at_Work

    Joined:
    Mar 16, 2022
    Posts:
    58
    Ben's doing testing on the shader I provided to see what we can cross of the list as suspects for the lag. I would imagine if anyone else has complex shaders they could provide or could do tests to isolate potential causes, it might get us closer to understanding exactly what the source of the problem is. I guess having about a hundred exposed parameters on a material was an unexpected use case, though to me that was just standard prototyping (hard coding comes after you perfect the values).

    Apparently if you delete all the parameters, the speed increases dramatically even with the same graph complexity.

    Deleting out all of the comments and headers which I insert using Shader Graph Markdown in the form of parameters had no effect. So those types of unused parameters, even when exposed, aren't the likely source.

    I assume there are multiple sources of lag that accumulate over complexity, but perhaps one or two that are more extreme and which we could be helping to find rather than talking in circles.
    • Is the undo lag directly proportionate to the standard action lag, or is there a specific feature that hits undo lag harder? My jump from 13 seconds to 10 minutes was massive and unexpected. Is that ratio different than what other people see?
    • How does copy-paste lag compare (I didn't include those numbers) to undoing, creating nodes, adding connections, and breaking connections? Getting a full set of those numbers might serve as a sort of bug report. If we can get a count of the number of nodes, keywords, and parameters to go with it, we could start building a data pile for the engineers.
    • Is it possible to make a small graph with extreme lag by isolating and repeating a bad feature?
    • Does nesting with subgraphs change the result? If you take a complex laggy graph and shove it into a subgraph, which types of lag respond? Will undoing and standard actions in the main graph suddenly go faster?
    Stuff like that we can be doing in small spurts. It's not exactly my specialty or my responsibility, but the whole point of the forum is to volunteer our efforts.
     
    IffyJackson likes this.
  2. EricFFG

    EricFFG

    Joined:
    May 10, 2021
    Posts:
    176
    I got a report that this issue is apparently fixed in upcoming .3.8
     
    adamgolden likes this.
  3. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    89
    Thank you for the update, Eric. Please manage your expectations here. There are a LOT of issues mentioned in this thread with users on several different types of hardware and platforms, so saying "the issue" is fixed could lead some people here to believe that the team as miraculously fixed all performance issues everywhere for everyone - which is not the case.

    For the internal bug that I made with Ben_at_Work's test data, there is a specific engineer assigned to investigate it and he will be working on it in the next week or two. Nothing has been resolved with that yet.
     
  4. IffyJackson

    IffyJackson

    Joined:
    May 23, 2017
    Posts:
    18
    Thanks for the update, Ben.

    Do you perhaps have news about the findings of the engineer?
     
  5. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    676
    Unity 2021.3.28f1 here, I've only added a few keywords into an unlit node. I just want to change some floats.

    30 seconds between keystrokes. How are we supposed to work like this?

     
  6. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    89
    As an update, the engineer assign to work on this issue has found some ways of improving performance in the test cases provided by Ben_at_Work. His results are quite promising - so we're hoping to publish these updates in a future version soon (after they've gone through the full testing process to ensure they don't cause other regressions.) He's continuing to investigate the issues - looking for even more speed-ups. I don't have a time estimate for how soon we'll be able to get these improvements to you - but they are coming.

    @funkyCoty - your issue appears to be different from those we've look at so far. If you'd like to send me a DM with your shader (including any dependencies), I can attempt to reproduce it on my end and file a separate bug for it.
     
    Last edited: Aug 28, 2023
  7. Ben_at_Work

    Ben_at_Work

    Joined:
    Mar 16, 2022
    Posts:
    58
    I've had some of the same issues that @funkyCoty posted where typing numbers into a float parameter causes lag with each and every digit I type. A possible fix on that specific one would be to not apply the new value/color to the graph until a confirmation action is taken (widget loses focus, enter button, close the selector, etc.) rather than seeming to compile with each tweak. Of course that's still an imperfect solution since it reduces testing speed.

    My graph is taking 8 seconds or so to enter a single number of a float or change a single property of a color. If I continue typing while it loads, it does seem to send the more completed float, but the loading starts and is unavoidable the moment I make a change. If you hit delete in the middle of typing, it queues up a separate action and must complete the load.

    1<2<3<4<5<6<7<8<9, where < is deleting, the result should be 9. Before it can get there, though, it will first load to 1, then 2, then 3, and so on (not always displaying them, however), instantly beginning the compile for the next action. If you don't interrupt this process the queue appears to complete in that full form, causing a sequence of recompiles one after the next.

    Deleting appears to count as a change action when the value is not already zero, incurring lag. If the value was 4, then I hit delete, I think it will auto-fill the now blank value to zero which is why it counts as a change. Once the value is zero, however, delete no longer incurs that lag. I can similarly type a repeating string of zeroes (0000) without lag because the underlying value hasn't changed. Typing example below:

    0 (starting from)
    <
    1 (lag)
    < (lag)
    0
    <
    0
    00
    000
    1 (lag)
    11 (lag)
     
    IffyJackson likes this.
  8. laurent-h

    laurent-h

    Joined:
    Sep 29, 2016
    Posts:
    78
    I have a very simple repro case that might be easy for the dev team to use :
    - I use HDRP's template sample scene
    - I have imported the FullScreen Samples (custom pass, custom post process, etc)
    - I have added EdgeDetection custom pass in the scene
    - now i'm trying to edit the graph
    -> every node add or delete takes ages
     
  9. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    676

    Bug report: New Incident created: IN-53876
     

    Attached Files:

    Last edited: Sep 5, 2023
    BACALL likes this.
  10. SeanR10Chambers

    SeanR10Chambers

    Joined:
    Jan 20, 2022
    Posts:
    3
    Just adding that we're experiencing similar issues in 2022.3.6f1.

    Adding/duplicating/deleting nodes, or dis-/reconnecting anything takes an eternity, often 3+ min for a single operation.
    Not to mention the time undo takes.

    Granted they are pretty complex shaders, but it has gotten so bad that I'm allocating several weeks of dev time to rewriting stuff in HLSL.

    It was always the intention to do this down the line, but shadergraph as a "rapid prototyping tool" is just not usable.
    The fact that rewriting in HLSL at this stage is a more attractive & possibly faster solution just due to how terribly unoptimized the UI is, is very disheartening.

    I really hope the engineers your engineer(s) manage to improve the the whole system substantially.
    Will any of those improvements be available as a backport? Or will our project need to be updated to a new lts version?
     
    Ben_at_Work likes this.
  11. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    89
    Our performance improvement changes have gone in and will be available in both the latest alpha of 2023.3 as well as the latest LTS version of 2022.3 as soon as the newest build is published. It will most likely be 2022.3.10f1.
     
  12. EricFFG

    EricFFG

    Joined:
    May 10, 2021
    Posts:
    176
    Good to know
    .9 is workable again but It still takes around 1 second for things to react in a medium-large shader (using subgraphs extensively)
     
  13. SeanR10Chambers

    SeanR10Chambers

    Joined:
    Jan 20, 2022
    Posts:
    3
    That's great to hear! I will check with the relevant people if we can make the upgrade to 2022.3.10f1.

    On a somewhat unrelated note: your youtube shader tutorials have been a fantastic resource, thanks a ton for providing them for free to the community!
     
    BenCloward likes this.
  14. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,460
    Yeah I have some priceless subgraphs in my toolkit thanks to @BenCloward :D ..actually have them named like _____ByBenCloward.shadersubgraph ..and later realized he actually works for Unity and is active on the forum. Thanks from me as well!
     
    BenCloward likes this.
  15. IffyJackson

    IffyJackson

    Joined:
    May 23, 2017
    Posts:
    18
    Came here to say that there's a night and day difference in performance in .10.

    Thank you for fixing this!
     
    BenCloward and adamgolden like this.
  16. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    215
    Are there any plans to bring these improvements to 2023.1?
    We can't downgrade to 2022 LTS and can't risk updating to an alpha, so currently it looks like we'd be stuck with an unusable shadergraph for another few months...
     
  17. EricFFG

    EricFFG

    Joined:
    May 10, 2021
    Posts:
    176
    Oh look, I am opening .10 now

    2023-10-04_14-16-36.gif

    my entire scene is flashing like a disco, all third party shaders broken

    Also I find that recompiling a shader on .9 and .10 freezes the entire editor for 30-60 seconds
    You are supposed to do stability updates, not change any fundamentals, how is this still not clear?

    What are you guys doing, what the hell is going on in there??

    Can we please finally work on shaders again, its been a long time, jesus christ
     
    funkyCoty likes this.
  18. EricFFG

    EricFFG

    Joined:
    May 10, 2021
    Posts:
    176