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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Bug Ver. 2021.3.9 - Newly introduced error for DrawMeshInstanced calls in codes

Discussion in 'General Graphics' started by TerraUnity, Sep 3, 2022.

  1. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    A lot of our projects and products rely on our custom GPU renderer based on Graphics.DrawMeshInstanced calls to render models efficiently. Now suddenly after +8 years of working with this API, in Unity 2021.3.9 we receive this error:

    However the models are still being rendered properly but this error spams the console and makes the projects unusable. This also leads to a state where even none of Unity's own standard shaders working and receiving the same error!

    Since our solution was based on DrawMeshInstanced and we chose this to avoid needing to touch any shader codes whether it's a custom shader or Unity's and was working on all shaders by default, but it broke the entire ideology and affected our development heavily.

    So guides and hints on this from Unity graphics staff is strongly needed here since I guess it affected a lot of users.
     
  2. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    The mentioned behavior and error comes from this line in the changelog:

    here: https://unity3d.com/unity/whats-new/2021.3.9
     
  3. zeiksz

    zeiksz

    Joined:
    Mar 10, 2019
    Posts:
    9
    I got this after upgrading to 2022.1.16f1 (from 15f1).
     
  4. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    This behavior stopped our development, an input to address this from Unity graphics team is highly needed!

    Thanks for the report. What shaders do you use with DrawMeshInstanced?
     
  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    Hi!
    We used to silently ignore this (shader not reading any instanced properties and using instanced rendering). This lead to incorrect behaviour when used. After this fix it's promptly issuing an error.
     
    TerraUnity likes this.
  6. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    Thanks for the heads up on this. For the past few days, we were trying to sync an instanced shader with DrawMeshInstanced without receiving this error but none worked. It is really appreciated if you could share a simple instanced shader which works without errors since we tried every possible instancing data in shaders but failed!

    And by this, you mean even none of Unity's built-in shaders will work with DrawMeshInstanced anymore! That's sad to hear!
     
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    Looks like we have an incoming bug report about this o_O
    I'll post an issue tracker link when it's there.
     
    TerraUnity likes this.
  8. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    Thank you so much for the follow-up on this. Please let us know if it is confirmed as a bug and its condition in issue tracker.
     
  9. primaerfunktion

    primaerfunktion

    Joined:
    Jan 16, 2012
    Posts:
    98
    Just a quick + 1 from me. Relying on this for my Grass Solution as well.
     
  10. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    OK, looks like we found the culprit. It doesn't find any instanced properties when it's compiling variants asynchronously. We'll fix this, the error can be safely ignored and if it doesn't appear in the player.
     
  11. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    Thanks for the update! Looking forward to the fix.
     
  12. DelgadoUprep

    DelgadoUprep

    Joined:
    Jun 28, 2022
    Posts:
    9
    For me, this only appears when teleporting player to a different location, then the game crashes. A Fix would be extremely welcomed.
     
  13. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    Do you use TerraWorld?
     
  14. Roodbrooster

    Roodbrooster

    Joined:
    Jun 26, 2020
    Posts:
    1
    I'm having similar issues with my grass shader. I've tried disabling the asynchronous compilation of shaders; which makes the error go away while editing the scene.

    However, when opening a Prefab to edit it; the log is spammed with 999+ of the same error as discussed, almost instantly. Might be something there as well? The grass renders perfectly fine; it just makes it somewhat unworkable as I have difficulty seeing actual errors.

    EDIT: Forgot that you can just collapse the console to atleast have these errors bundled together. That's workable enough for now I suppose! Hopefully a fix can be made soon. My Unity version is 2022.1.18f1
     
    Last edited: Oct 1, 2022
  15. al57

    al57

    Joined:
    Feb 13, 2014
    Posts:
    13
    I'm just tired of all the unity's bug, have a quick proof of concept to make this morning ...
    This is just killing productivity.
    @TerraUnity Did you find a "work around"

    Regarding the perpetual issue I have with unity since like 3 / 4 years (after 10 years working on several project)
    I'm considering to stop my subscription and find a another dev tools.
     
    antosond likes this.
  16. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    765
    Any idea when? Because it's still happening in 2021.3.11.
     
  17. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    It landed recently in 2023.1.0a16, backports will follow.
     
    TerraUnity likes this.
  18. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    765
    So no idea then when the fix will be released for Unity 2021? The version the bug was reported for? The LTS version that's supposed to be stable? Because that information might actually be useful. :rolleyes:
     
  19. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    I'd say around 3-4 weeks.
     
    Genebris, TerraUnity and FargleBargle like this.
  20. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    Disabling the asynchronous compilation of shaders in Graphics settings will stop these errors in the editor so you can try out before the official fix.
     
    Sluggy and solkyoshiro like this.
  21. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    Unity 2022.1.20f

    Is it possible to disable the error until the bug is fixed ?

    Debug.unityLogger.logEnabled = false;
    Debug.unityLogger.filterLogType = LogType.Exception;
    Application.logMessageReceivedThreaded += Handler;

    I've tested this with no success.
     
    Last edited: Oct 31, 2022
  22. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    @dyox
     
    TerraUnity likes this.
  23. VizualNate

    VizualNate

    Joined:
    Apr 9, 2022
    Posts:
    3
    Disabling this has not stopped the messages for me. Am I missing something?

    upload_2022-10-31_21-38-17.png
     
  24. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    @VizualNate probably you're seeing a different issue. Please submit a bug report, we'll take a look at it.
     
  25. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    Disabling Async Shader Compilation did not work for me either.
     
  26. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
  27. VizualNate

    VizualNate

    Joined:
    Apr 9, 2022
    Posts:
    3
    I continue to get thousands of these error messages in 2021.3.14F1 - new installation today. I am relatively new to Unity, but this didn't happen several versions ago and is very distracting when trying to learn and develop projects.
     
  28. URPian

    URPian

    Joined:
    Aug 13, 2012
    Posts:
    33
    Error still present in Unity 2021.3.14f1.
    In the Issue Tracker 2021.3.14f1 is apparently "fixed". Can anyone confirm if it's working for them?
    Thanks
     

    Attached Files:

    • err.JPG
      err.JPG
      File size:
      55 KB
      Views:
      52
    Last edited: Nov 22, 2022
  29. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    As I said earlier, there may be some other issue that manifests itself the same way. If the fix doesn't work in your case, please report another bug.
     
    TerraUnity and URPian like this.
  30. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    175
    yep, it's totally not working - just spoke to the developers of Vegetation Studio Pro (one of the major users of draw mesh instanced) and they said the unity fix isn't working and to regress to unity 2021.3.8 to stop the problem happening. This is a pretty major bug for an LTS release - I run LTS so as not to have fundamental issues like this.
     
    antosond, Sluggy and URPian like this.
  31. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    175
    Also the developer of Vegetation Engine posted that it is not fully fixed -


    I still get the issue in 2021.3.14 in 2 shaders:

    1. Surface Shader (with instancing variants support) + Vegetation Studio Instanced Indirect. If the async shader compilation is disabled, the error goes away. So I think the bug is still not entirely fixed, or there is something missing with the instanced indirect rendering.

    2. VertexFrag Shader + Vegetation Studio Instanced Indirect. This one was missing the multi_compile_instancing pragmas in some passes, so the error is expected.

    I hope this helps narrow down the issues.
     
  32. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    765
    Have you considered the possibility that the so called "fix" simply doesn't work? Saying "we fixed it, so anyone still having problems should report a new bug" sounds a bit like gaslighting. If people are still getting the same errors they were before you fixed it, then maybe you didn't really fix it. Sounds like you need to dig a bit deeper. I'd suggest coordinating with Awesome Technologies. Vegetation Studio has had a lot of issues since 2021.3.9 came out, and seems like a good test case for any real fixes going forward.

    Meet the new bug
    Same as the old bug
    Don't get fooled again
     
    Last edited: Nov 22, 2022
  33. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    @FargleBargle Imagine there's two or more issues with the same symptoms. We got a bug report that has specific reproduction steps and fixed it. If there's more to it, we need a new bug report, with different reproduction steps. And we'll be happy to fix it as soon as we have a way to reproduce it. Right now we don't, and this is why I'm asking for more bug reports.
     
  34. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    175
    To reproduce - take unity 2021.3.14 and install vegetation studio pro, then install nature manufacture meadow pack, create a scene, add a terrain, add one of the trees from the nature manufacture meadow pack into a biome and have it populate across the whole terrain. Now go to the project heirarchy view and type anything in the heirarchy search bar and watch your console fill with the error message.

    If you do a build of this scene your console log will also be totally spammed with errors - until you turn off async shader compile and then do a build - which fixes it.
     
  35. VizualNate

    VizualNate

    Joined:
    Apr 9, 2022
    Posts:
    3
    To be very honest, while I have years of experience on other platforms, I do not know enough about Unity development to make a full bug report. I have been loading very simple scenes (just a few objects and some controllers). I have looked at the bug report, but I do not see the bug's "attached file" that I could download and test.

    As soon as the file loads, even before previewing or compilation, the errors begin. Every time I move my mouse cursor over the viewport or select the instance assets, the errors stack up, in my case, always a multiple of 2, usually 12 or so each time I move the mouse over the viewport, off the viewport or select the instanced objects, and probably during other operations. I could not really work around the errors without the console collapse option. There are hundreds in the first few minutes, and there are easily 30K errors listed in the console when I checked after working for less than an hour. In the case of this file, the instances are capsules, if that helps.

    There are no similar errors in Ver. 2021.3.8 (just checked again now) but there have been in each of the versions I have tried since then. I have begun ignoring the errors, but it doesn't make sense to leave them.
     
  36. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    765
    When I go to the bug tracker, there are already several reports on this issue that have been flagged as duplicates. Why create more? Users in this forum have told you the issue is still not solved, and told you specific ways to reproduce it. You work for Unity, so why is it so hard to simply communicate this information to the bug team? It sounds like you could help, but won't, because we didn't put the right cover on our TPS reports.

    Again, the steps to reproduce:
    1. Create a project in a version of Unity prior to 2021.3.9
    2. Add a terrain, Vegetation Studio, and a bunch of instanced trees
    3. Make sure the scene runs without errors
    4. Upgrade the project to Unity 2021.3.9+
    5. Watch the errors pile up every time you open it
    If you need more info, or a test scene, contact Awesome Technologies. Their Discord channel has been blowing up about this issue for months.
     
    Last edited: Nov 22, 2022
    URPian likes this.
  37. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    OK, I went ahead and re-checked both duplicates, Mac + Win. All three issues have been fixed by the original pull request.
    Because I'm asking you to follow the established process for bug reports. A message on the forum is not a bug report.
    This process exists for a number of reasons. According to this process the bug that was reported was fixed. If we get another bug report that shows how to reproduce it, we'll fix it as well.
    I'm on the team that owns this area. All I ask to do - for three weeks now - is to follow the process and report a bug. If you're using an asset from the Asset Store that doesn't work, you can ask the asset author(s) to file a bug report. I'm pretty sure they will if they didn't do it yet.
     
  38. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,164
    @FargleBargle a mandatory like for the TPS reports!

    But let me explain why the formalities are important:
    - exact unity versions are important
    - exact package versions are important
    - exact vegetation studio version is important
    - actual content is likely important too
    - configuration is most important! both project's and editor's.
    Bug reporting tooling makes sure all of the above is captured and carefully delivered to the QA team so that they can reproduce the issue first, and, most importantly, also verify in the end that the fix did its job.

    I've seen hundreds of bugs which were caused by configuration issues that you never realize to affect your project. So please excuse the call for formalities, but it's a vital step in fixing something that is not obvious to the developer from reading the post here on the forums.
     
    TerraUnity likes this.
  39. Chalkcs

    Chalkcs

    Joined:
    Apr 23, 2013
    Posts:
    2
    I can confirm that disabling asynchronous shader compilation does not solve anything in Unity 2022.1.23f1

    I replicated this issue in a fresh project with only TerraWorld, so it is not a symptom of another issue.
     
    Last edited: Nov 27, 2022
  40. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    765
    @aleksandrk & @Yury-Habets It might take a while for me to file a bug report. After first seeing this problem when trying to upgrade from Unity 2021.3.7 to 2021.3.11 several months ago, I reverted my main project and one other that used Vegetation Studio back to 2021.3.7. Seven other test projects - that didn't use Vegetation Studio - upgraded with no problems. I can't submit either of the affected projects to demonstrate the bug, since they are 50GB and 10Gb respectively. To gather all the other information needed for a "proper" bug report, I'll need to either screw up one of those projects again, or create a new one from scratch. I don't have a team to delegate any of that to, so it'll need to wait until I have a few days worth of free time to waste on it.

    Considering all the people here and on the Awesome Technologies Discord channel that have reported the same problem, not to mention users of Vegetation Engine, TerraWorld, and who knows how many other assets, I'm surprised nobody else seems to have filed one though. It seems I'm not the only one having problems filling out those TPS reports.
     
    Last edited: Nov 27, 2022
  41. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    It's likely that someone did. I'll keep an eye on the list of duplicates of the original report, just in case.
     
  42. URPian

    URPian

    Joined:
    Aug 13, 2012
    Posts:
    33
    Bug Report Generated: "New Incident created: IN-24374 - DrawMeshInstancedProcedural error for TerraWorld"

    I only have the above "Incident" code in my mail. Kindly check if this one would be of any assistance to fix the error.

    Thank you for your efforts and time in fixing this issue.


    ----
    Steps to produce errors:

    - Installed Unity 2021.3.14f1 LTS from the Hub
    - Created a fresh project using Hub's 3D (URP) Core Template
    - Imported "TerraWorld" 2.51.0 Package from Package Manager
    - "TerraWorld is going to import the package and set needed settings automatically" > OK, Continue pressed

    - ERROR:
    Shader error in 'InjectLightingAndDensity': undeclared identifier 'Attenuation' at kernel CSMain at InjectLightingAndDensity.compute(331) (on d3d11)
    - Selected a Location in map
    - Import of Forest Template began

    - ERRORs:
    " GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced.
    UnityEngine.GUIUtilityProcessEvent (int,intptr,bool&)"

    - Import finished.
    - Terrain generated

    CONTINUOUS ERROR(s) x5 times the speed:

    Shader properties can't be added to this global property sheet. Trying to add _RefractionTex (type 4 count 1)
    UnityEngine.GUIUtilityProcessEvent (int,intptr,bool&)


    Shader properties can't be added to this global property sheet. Trying to add _RefractionTex_ST (type 2 count 1)
    UnityEngine.GUIUtilityProcessEvent (int,intptr,bool&)


    Shader properties can't be added to this global property sheet. Trying to add _RefractionTex_TexelSize (type 2 count 1)
    UnityEngine.GUIUtilityProcessEvent (int,intptr,bool&)


    Shader properties can't be added to this global property sheet. Trying to add _RefractionTex_HDR (type 2 count 1)
    UnityEngine.GUIUtilityProcessEvent (int,intptr,bool&)


    CONTINUOUS ERROR(s) x 40 times the speed
    DrawMeshInstanced does not support the shader 'TerraUnity/Standard' because it does not read any instanced properties. Try switching to DrawMeshInstancedProcedural if the shader is doing procedural instancing.
     
    Last edited: Nov 29, 2022
    TerraUnity and aleksandrk like this.
  43. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    @URPian Thanks for the bug report and reproducing the steps with TerraWorld, to minimize the process and have less errors, please import TerraWorld in a bulit-in pipeline template and submit bugs since current TW version is supported in BRP and SRP support is limited and brings irrelevant shader errors as above; this way, Unity engineer team can follow-up the case better.

    @aleksandrk Any news on this? So many people (potentially any customer with Unity 2021.3.9+) are rushing into our Discord servers to report this bug and they have no idea where it comes from!
     
    URPian likes this.
  44. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    Yes, I asked QA to prioritise this bug report. They reproduced the issue. We'll take a look soon :)
     
    Zaddo and URPian like this.
  45. melgeorgiou

    melgeorgiou

    Joined:
    Nov 3, 2012
    Posts:
    750
    In the middle of upgrading a project and just stumbled on this issue as well. We also have custom GPU rendering based on Graphics.DrawMeshInstanced.

    @aleksandrk , Any ETA on when the Unity 2020.3.X fix will be released?

    Thanks,

    - Mel
     
  46. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    The fix is in the queue, I'll post an update when it lands - we'll know, in which version it'll appear as soon as it does.
     
    melgeorgiou likes this.
  47. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,750
    I just checked the submitted bug report (IN-24374). It's trying to use the TerraUnity/Standard shader (it's for BiRP) in URP, so it's using the error shader instead. So the error is legit - the error shader doesn't support instancing.
     
    URPian likes this.
  48. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,159
    Yes, as I mentioned here TerraUnity/Standard shader is for BRP and that's why I asked the submitter to redo the report in built-in rendering pipeline project to have proper debugging, but thanks for the confirmation.

    But still TerraUnity/Standard shader in BRP receives the instancing error in question falsely based on massive reports we get from our users even though I can confirm that it supports instancing and is used extensively along with our GPU renderer system in TerraWorld based on DrawMeshInstanced API!
     
    URPian likes this.
  49. unity_ESPpfKWcV64y3Q

    unity_ESPpfKWcV64y3Q

    Joined:
    Feb 25, 2018
    Posts:
    4
    I got this error in editor but gpu instancing is working fine for my custom gpu instancing shader. But it is not such lucky on android and ios. It entirely missing on android and ios...
     
    URPian likes this.
  50. catfink

    catfink

    Joined:
    May 23, 2015
    Posts:
    175
    My issues with this particular newly introduced error span a bit further than whether it is actually being issued correctly or not (and the argument from many here still seems to be not).

    My concern is that when this issue happens it absolutely spams the log file with thousands of the same error message. Now if it did this only in the editor I would be less concerned - us developers would be duly informed and that's who actually needs to know about this.

    The problem is it does this in builds as well. So if you do happen to miss this error in the IDE (and I have examples where it doesn't happen in the IDE and does happen in a build) the result is a complete tanking of the FPS due to the console log being spammed with messages.

    This in itself seems to be a very poor decision at the Unity level - the last thing we as developers need is an error that spams the console and kills FPS for the built version of our games. By all means issue the error in the IDE but in a build my view is it should be issued once for any particular shader and no more. Particularly as this error occurring doesn't actually cause a graphical issue, it's the error message spamming the console that creates the issue and users FPS goes through the floor as a result.