Search Unity

Bug Random "failed to open source file" when using git and custom function node?

Discussion in 'Shader Graph' started by bitinn, Mar 2, 2021.

?

Have you experienced custom function node "failed to open source file" and fixed by "save asset"?

  1. Many times

    1 vote(s)
    100.0%
  2. A few times

    0 vote(s)
    0.0%
  3. Never

    0 vote(s)
    0.0%
  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi Unity team,

    I am trying to chase down a shader graph bug that happens a lot in our team (~100 people):

    - I often create utility subgraph with a single custom function node in it
    - Often but not always, when members git checkout shader containing my subgraph, they see Pink material
    - And a "failed to open source file" warning throws, point to the HLSL file my subgraph reference.
    - The workaround has always been to open the subgraph and "save asset" again, the issue is gone 100% of the time.

    But why? I observe many shader author mention this, but no one has offered a reason.

    I assume shader graph hold shader compilation cache somewhere, and they probably aren't committed into git, so it would appear when members: (1) git checkout, (2) focus unity window, (3) shader graph regenerates this cache, (4) SG somehow couldn't locate the HLSL file.

    Is this known, what's the best practice on this?

    (We are on Unity 2019.4.16f1 with HDRP and Shader Graph 7.5.2, also we use Cache Server v1.)