Shapes not rendering in builds (investigation megathread)

Avatar
  • updated

I'm getting reports of Shapes not rendering when building for certain platforms, and unfortunately I don't know why this keeps happening. There seems to be some cases where GPU instancing doesn't work, even though I've set everything up correctly on my end (as far as I know), and even though the platforms you test on, should support GPU instancing.

This thread will serve as a centralized discussion thread on this issue, as they are likely all related.

It seems like it only happens when GPU instancing is on (correct me if I'm wrong!), which means that somehow GPU instancing is either not supported, or not working even though the platform should support it. This could be due to any number of things, such as, the platform misreporting instancing support, or a plugin disabling instancing silently, or a render pipeline configuration that silently suppresses GPU instancing.

However, GPU instancing is the primary way Shapes makes itself performant, you shouldn't have to disable it.

I would start by testing a few things to investigate further:

  1. Do a clean reinstall of Shapes, and see if you still have issues. This is very important to do before reporting any bugs in general. The package manager and Unity in general often struggle to update assets cleanly, so you may have cached files in a broken state, which often leads to weird issues like this. We have multiple reports [1] [2] [3] of clean reinstalls solving this issue
  2. Please check for any build or runtime logs for warnings/errors related to Shapes or shaders
  3. If you are using immediate mode rendering in Shapes, try disabling immediate mode GPU instancing in the Shapes settings window, and then see if it works. If it works after this, we know that it's related to GPU instancing. If it still doesn't work, then let me know!
  4. Unity has a way to check if your current platform actually supports GPU instancing, I would run this on your target platform to double check that it is actually supported.
  5. Make sure all shader instancing variants are included in your graphics settings. Unity can't predict which shaders you will use in immediate mode, and so it will sometimes strip them from builds


other than that I'm at as much of a loss as you are - I've implemented instancing support the way one should, it works just fine on many platforms, including iOS and Android for many, so I don't know why it seems to fail in some specific cases. There might be some hidden setting somewhere that disables GPU instancing elsewhere, though that's something I wouldn't know of

Do let me know if you find something out that might help us resolve this!

Reported issues:

Target platformUnity versionRender PipelineInstancing off works?
iOS (iPhone 13 pro)2020.3.24URPyes
Android/iOS2021.2.0 & 2020.3.5URPyes
M1 mac mini???
WebGL in chrome2019 & 2020Built-inyes
WebGL 2.02019.4.12??
WebGL 2.02019.3.0
2020.1.3
2020.1.11
2020.2.13
Built-in?
Editor2021.2.0Built-inyes
Editor2021.1.10URPyes

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
b toqq

Hi - I can add to this - the same iOS build I use (2020.3.24 on blank URP project) works correctly both in editor and in standalone build on on M1 Mac Mini. I can see no issues there.

On the iPhone, I noticed it defaulted to "medium" graphics quality, and M1 defaults to "high". I set the iPhone build to high also, but still the issue persists.

Also, I manually made sure that the shaders are in the shadervariants file, and added to the build. I also added a manual line in the scene just to ensure the shader would be noticed by Unity.

Still, no change - the line I added through the scene is visible but the Immediate mode lines are not.

No error or warnings beyond what I posted earlier.

Avatar
b toqq

I also attached the Frame Debugger both to the (working) M1 build and the (not working) iphone build.

Notably - the iPhone build completely lacks the "Draw mesh (instanced)" draw calls in the command buffer.

Avatar
Thomas Brown

I just had an issue where turning off GPU Instancing also resolved my issue despite the tested devices supporting GPU Instancing.

I have a feeling this was linked to the way I was possibly animating my ImmediateMode shapes. I was dynamically creating an object and within said object I was animating properties of the object using DOTween. From there I was drawing my shapes with the given properties using the Draw command.

Because the above is pretty vague without my code I'll go ahead and add it below.

Interaction Ring Code

This was with the following setup
Unity: 
2018.4.30f1
Render Pipeline: Built In
Platforms:
Android & iOS

Avatar
James Moulang

I had this issue on Android, in Unity 2020.3.32f1, specifically with rectangles with rounded corners (immediate mode only) - a Shapes reinstall fixed my issue (after a lot of shaders rebuilt)

Avatar
Maks Michalski

I've noticed this issue when rendering discs in immediate mode in 2021.2.9f1. None of the suggestions had helped, but strangely if i add a disc component to the scene (even disabled) all starts to work normally, which is an acceptable workaround for now. Hope that info helps.

Avatar
ann michelsen

Unsure if this helps anyone or if its even relevant. But I had users on my live game, sending support emails on that they could not see the lines/shapes in the game, (very few users have issues, estimating to like 1 out of a 100 devices). I have now figured out that if I swap the shapes from Flat 2D to Billboard it starts to work for these users. I do not know why the Flat 2d is not working on some devices while it works on the majority. Maybe this helps someone.

Avatar
garfounkel

Not sure if it's the exact same issue because it happened in the Editor for me (haven't checked in build) but some of the symptoms are the same:
- Drawing two Discs (or more) in immediate mode wouldn't display any of them (but drawing only one works).
- Deactivating GPU instancing solves it.
- Unity 2020.3.10f1, URP 8.2.0, Shapes 4.1.3, Platform: Editor

However, I found an acceptable workaround accidentally by doing a clean Shapes reinstall. The reinstall in itself didn't solve it but it made it so that the shaders were compiled using the built-in pipeline despite my project using URP. When I force configure the shaders to use URP, immediate mode stops drawing my Discs (even on a clean Shapes install). So the workaround for me was to leave the shaders compiled for Built-in RP which does not cause negative side effects (yet) as far as I can tell. Not sure if that helps but maybe this is an issue with the way shaders are compiled for URP?

Here's the Shapes's config that works for me if that helps anyone (Unity 2020.3.10f1, URP 8.2.0, Shapes 4.1.3):

Image 588

Avatar
mikael klasson

Here's an extremely simple repro case for when this bug occurs on my Pixel 4a running Android 12.


Unity 2021.3.1f1 or 2020.3.33f1.

Shapes 4.1.3.

Built-in render pipeline.

  1. Create new 2D 2021.3.1f1 project.
  2. Import Shapes.
  3. Create empty GameObject in the scene and add TestShapes.cs to it.
  4. Change build settings platform to Android.
  5. Build android apk.
  6. Run on device and bug out.

Disabling Shapes' GPU Instancing gets rid of the bug.

The exact same procedure causes the same bug on Unity 2020.3.33f1 as well.

TestShapes.cs:

using Shapes;
using UnityEngine;

[ExecuteAlways]
public class TestShapes : ImmediateModeShapeDrawer
{
    public override void DrawShapes(Camera cam)
    {
        using (Draw.Command(cam))
        {
            Draw.Matrix = transform.localToWorldMatrix;
            Draw.Disc(Vector3.zero, 1.0f, Color.blue);
            Draw.Pie(Vector3.zero, 2.0f, -1, 1, Color.yellow);

            // Only the disc is drawn if this last line is uncommented. Otherwise both two shapes above are drawn.
            Draw.Pie(Vector3.zero, 2.0f, Mathf.PI - 1, Mathf.PI + 1, Color.yellow);
        }
    }
}

Avatar
moreno vogel

I have a weird behavior when using shapes with the Hololens 2 (UWP) - specifically when streaming / recording or taking a picture.

The paths get drawn for the user wearing the headset and are visible.

But when evaluating the recordings - all shapes paths are gone. I think it has something to do with the render / capture order of the headset which gets called before shapes had executed its draw command. Is there a way to change when shapes executes the draw command?


Turning off GPU Instancing didn't fix it.

Thanks for your help

Avatar
Freya Holmér creator
Quote from moreno vogel

I have a weird behavior when using shapes with the Hololens 2 (UWP) - specifically when streaming / recording or taking a picture.

The paths get drawn for the user wearing the headset and are visible.

But when evaluating the recordings - all shapes paths are gone. I think it has something to do with the render / capture order of the headset which gets called before shapes had executed its draw command. Is there a way to change when shapes executes the draw command?


Turning off GPU Instancing didn't fix it.

Thanks for your help

this sounds like it's more related to how the screenshot/recording utility works than shapes itself - I'd start looking into that!

if you want to change when immediate mode shapes are drawn, then that's the second parameter of Draw.Command

Avatar
moreno vogel
Quote from Freya Holmér

this sounds like it's more related to how the screenshot/recording utility works than shapes itself - I'd start looking into that!

if you want to change when immediate mode shapes are drawn, then that's the second parameter of Draw.Command

I played around with the Draw.Command parameters and it lead me to changing to the Polyline component which

fixed the problem and made them visible when recording / streaming. Thanks for the help!

Avatar
ushui

On Android, we encountered a problem with Draw.Quad in Immediate mode not drawing.

We also confirmed that the behavior is different between Opaque and Transparent.

Very inexplicably, it was eventually resolved somehow, but let me write it here as one piece of information that will be helpful to others.

My environment

  • macOS 12.3.1 (Mac mini 2018)
  • Unity 2021.3.3f1
  • Shapes 4.1.3
  • Built-in render pipeline
  • Android's Graphics API is Vulkan
  • Test device is Android 9, confirmed to support GPU instancing

Solution to Transparent Quad not drawing

  1. Clean reinstall Shapes.
  2. go to Shapes Settings and change the Quad interpolation quality from Medium to Low and press the Apply shader settings button.
  3. Change the quad interpolation quality back from Low to Medium and press the Apply shader settings button.
    (This may sound strange, but it seems important to let the shaders compile.)
  4. Create a GameObject for Quad. You may disable it after creation.
    (This is also puzzling, but would it be needed for loading shaders?)

Solution to Opaque Quad not drawing

  1. perform steps 1 through 3 in the Transparent case. (If you have already done so, skip this step)
  2. Uncheck GPU instancing in Shapes Settings.

The latter method of disabling GPU instancing would be unacceptable to many.

But after this, I encountered a strange phenomenon.

After doing the iOS build, I did another clean install and did the Android build again, and now it works fine without disabling GPU instancing.

Even though several clean installs so far have not improved the situation.

Not all cases are the same, but at least in this case, the GPU instancing-related problem occurred in Opaque.

I am not sure if it is a Shapes bug or a Unity bug, but it would be very good if we could use this as a hint for a fix.

Avatar
jake rabinowitz

I'm running into this issue on Windows, and might have some new info:

  • "It seems like it only happens when GPU instancing is on (correct me if I'm wrong!)"

I'm actually seeing this issue with GPU instancing both on AND off. It's actually worse with instancing off.



I'm using immediate mode drawing with the following file: https://pastebin.com/J6pZiYJv

Editor View

Image 607

Everything looks good in the Game & Scene views in the editor.

Build: GPU Instancing enabled (default)

Image 608

The border RegularPolygon is not rendered.


Build: GPU Instancing disabled

Image 609

All the RegularPolygon, RegularPolygonBorders, and Lines are missing.  Only the PolygonPath and PolyLine are visible.  Interestingly, in the original project where I noticed issues, the opposite was the case!  The RegularPolygon, RegularPolygonBorders and Lines all rendered properly, but the PolygonPath and PolyLine didn't render.

Interesting Finding:

I've noticed that if I add a Shape GameObject to the scene (Hierarchy > right click > Shapes), and deactivate the GameObject, that will fix the problem for those shapes.

For example: in the "GPU Instancing Disabled" case, if I add a RegularPolygon to the scene with default settings, all the RegularPolygon & RegularPolygonBorders will render properly, even if that new RegularPolygon's GameObject is deactivated.

Image 611

Similarly, if I remove that RegularPolygon GameObject and instead add a Line, the lines render properly, but the RegularPolygons don't.

Image 612

If I add GameObject versions of ALL the different types of object, they all render properly.  This happens in the GPU Instancing On and Off cases. 

Full Repro Steps

  1. Create a new 2D URP Unity project (Unity 2021.3.4f1).
  2. Import Shapes 4.1.3 from Package Manager. (import everything).
  3. When prompted about URP Immediate Mode, say yes.
  4. Open the Render Pipeline -> Add Renderer Features -> Shapes Render Feature
  5. Create an empty game object "Radar Chart"
  6. Create the script "RadarChart" and paste in these contents: https://pastebin.com/J6pZiYJv

From there I see all of the above issues.

Repository for your convenience: https://github.com/JakeRabinowitz/UnityShapesBugRepro

Other Info:

OS: Windows 10 Pro  19043.1766

Graphics Card: RTX 3080

Driver: Geforce Game Ready Driver 516.59

Unity 2021.3.4f1

Avatar
blis

URP build for Windows on Unity 2021.3.4
I had a problem with shapes not rendering in build but working fine in editor.

Clean reinstall of shapes helped. :)

Avatar
todd noel

Built-in RP build for Windows on 2021.3.11. Clean install didn't fix it. 

Turning off GPU instancing fixed it but the performance hit is unacceptable. 

Graphics.DrawMeshInstanced is working fine as we use it elsewhere in the project.

Anything else we can do? 

Avatar
Freya Holmér creator
Quote from todd noel

Built-in RP build for Windows on 2021.3.11. Clean install didn't fix it. 

Turning off GPU instancing fixed it but the performance hit is unacceptable. 

Graphics.DrawMeshInstanced is working fine as we use it elsewhere in the project.

Anything else we can do? 

are you using the latest version? a clean reinstall should really fix this, unless you have some custom shader stripping that removes Shapes shader

Avatar
todd noel

We are using the latest version. I did another clean install and it still didn't work in the build. 


Shapes was working fine until we switched to 2021.3 from 2020.3. It's not really feasible for us to switch back now. 


Is there a way to tell if something is stripping the Shapes shader? I added all the shapes shaders to the Graphics/"Always Included Shaders".


Avatar
Freya Holmér creator

That would be my go to, I'm not sure how to verify it in builds I'm afraid :c

Avatar
rswa

is there any code strip when build optimize?

It's normal in unity editor(2021.3.12), but got the issue in unity player (release and development  build).

I already clean reinstalled shapes and use Built-in RP

my pc is window 10 pro

I tested GPU Instancing off in the setting of shapes. all my rectangles gone in unity player omg (editor working but low fps)

I think this is not GPU instancing issue..

Avatar
Freya Holmér creator

Unity does strip shaders, but later versions of Shapes *should* force include shaders regardless. but it's possible it's broken, or it's broken on Unity's end. At this point I truly don't know why it wouldn't work I'm afraid

Avatar
yinon oshrat

I did reimport the plugin as you suggested and it solved the problem for me.
Will it help you to get my git diff between the version before the reimport and after it? 

Avatar
John Murphy
Quote from Freya Holmér

are you using the latest version? a clean reinstall should really fix this, unless you have some custom shader stripping that removes Shapes shader

Not sure if I'm late to the party and missing something. I've been using Unity 2021.3.15f1 and URP on Windows 11 Desktop. Ran into Shapes not working in build on a project using a HUD for an XR project, (Works in editor but elements missing in build) so I decided to see if the same symptoms showed up in the sample project, and sure-enough it also works in the editor but not the build. Tried turning off GPU instancing but it was worse. A full re-install of Shapes made no difference.
Tried same version of unity with URP on Windows 10 Laptop same result so at least it is readily reproducible.

Image 660

Avatar
Gavin Rossiter

I had this issue too.
Immediate mode lines were not rendering in builds only (other non-line shapes e.g. ring/disc worked) .
Unity 2022.2.0f1, HDRP 14.0.4, Shapes 4.2.1.
Shapes was compiled for HDRP with GPU Instancing on. 
I turned off GPU Instancing and then immediate mode line rendering worked in one scene, but not in another, very odd.

I did a clean install of Shapes, which compiled it for Built-In and now everything works, even with GPU Instancing.  It's strange that the Built-In shaders work in HDRP but I'm not looking a gift horse in the mouth.
So I guess this fix mentioned earlier in the thread works in HDRP too https://shapes.userecho.com/communities/1/topics/385-shapes-not-rendering-in-builds-investigation-megathread?redirect_to_reply=1217#comment-1217.
Perhaps the issue lies somewhere in the compilation process from Built-In to a scriptable render pipeline.

Avatar
Olle Landin

Unity: 2021.3k.21

Device: Pixel 3 - Android 12

URP 12.1.10

Shapes 4.2.1


I have had a lot of trouble getting my 3d lines to show in IM-mode on my android. The only thing that works is to turn off GPU Instancing. On my Pixel 3 i got SystemInfo.supportsInstancing == true, so it should work?

I also tried this approach

https://shapes.userecho.com/communities/1/topics/385-shapes-not-rendering-in-builds-investigation-megathread?redirect_to_reply=1217#comment-1217.


...but that caused even bigger issues. With the shaders built for the built in RP, IM-mode did not even work in the editor (Mac M1). 


I also tried Edit-->Project Settings->Graphics-->Instancing Variants: Keep All, but that made no difference. 

Is there any other way to ask the device if GPU instancing is supported? Seems like a huge waste being forced to keep it off.

Avatar
Hamster On Coke

Hey,

I'm having issues using normal Component Shapes (not immediate draw mode) on Samsung Galaxy A12 device.

Using URP.

Shapes component that use transparent shaders are drawn correctly, however Opaque components are not drawn.

The logcat outputs shows  fragment shader link errors:

Image 703

 The device specs:

Image 704

Clean installation of Shapes doesn't help. 
Rebuilding shaders and materials doesn't help.

Any clues on how to debug this?

Thanks,

Cheers

Mike

Avatar
Hamster On Coke

Update:

- All devices that uses PowerVR GE8320 GPU seems affected. It's actually quite popular budget GPU used in a lot of samsung devices.
- That GPU is known for having issues with shader compilation.
- Unity is working on providing bugfixes to other GE8320 related errors.
- For the shapes part, this is where it gets interesting:
I've narrowed down the issue, and the shader compilation error only happens when MSAA is turned on. As soon as I switch it off, all Opaque shaders starts to render again.

SOLUTION: Turn off MSAA if you detect PowerVR GE8320.

Avatar
Anthony Massingham

I was experiencing the same issue when deploying to Android (Pixel 3a and Galaxy Tab S8+) in 2022.2.13.

Changing the instancing variants option from 'Strip Unused' to 'Keep All' resolves the issue.

Image 710

Avatar
D. Park

Without the shader variants stripping, my project build takes too long. To go around this issue while keeping 'Strip Unused' options ON, I tried to identify the specific type of immediate draw and made dummy GameObjects, and applied the relevant materials for them. Those immediate draw types(for me, spheres) finally showed up in the build and I kept the 'Strip Unused' Option ON, so build time is intact.

Image 711

Avatar
Clee

I was also experiencing the same issue with Unity 2022.3 when building for Android, with both URP and Built-in.

The solution mentioned in the previous reply did work for me. The GameObjects with the Shapes materials can even be in a scene that is never actually loaded, it just needs to be included in the build.

Alternatively, putting all the generated materials in a 'Resources' folder did also work for me, as it should have the same effect of forcing the materials to be included in the build.

Either way, the most important thing I have found is that after changing this, it is important to trigger a recompile of all the shaders or nothing changes in the build for some reason. In theory this should work by making a "Clean Build", but at least for me this did not change anything when using "Build & Run" afterwards to install the game on an Android phone.

What did work in the end was deleting the "ShaderCache" and "PlayerDataCache" folders inside the "Library" folder. (Only deleting ShaderCache also did not consistently trigger a recompile)