Draw.Line in ImmediateModeShapeDrawer not shown on Android/iOS

Avatar
  • updated
  • Unity's Fault

Hello, Freya, and thanks for the amazing plugin!

I encountered that a straight line drawn with a simple Draw.Line() is showing good in Unity edit/play modes, but is not been drawn on mobile device. I tried either Android and iPhone.

I found a similar post here https://shapes.userecho.com/en/communities/1/topics/192-immediate-mode-drawline-not-appearing-in-standalone-build and as recommended there I turned off GPU instancing for Immediate Mode in Shapes Settings

This workaround works for me (at least I already tested on iPhone).

I still decided to post a message here just to let you know.

My code is pretty simple:

public class DrawController : ImmediateModeShapeDrawer{

...

public override void DrawShapes( Camera cam ) 

{ if( cam != this.cam ) return;
using( Draw.Command( cam ) ) 

Draw.ZTest = CompareFunction.Always

Draw.Matrix = parentTransform.localToWorldMatrix;

Draw.BlendMode = ShapesBlendMode.Transparent

Draw.LineGeometry = LineGeometry.Flat2D;

Draw.Line(new Vector2(-1, 1), new Vector2(-1, -1), 0.05);

...

Reporting a bug? please specify Unity version:
2020.3.5f1
Reporting a bug? please specify Shapes version:
3.2.3
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Unity's Fault

can you try and do a clean reinstall and see if it helps? also, do the platforms you target support GPU instancing?

Avatar
Freya Holmér creator
Quote from miarfe

There is definitely a gpu instancing issue, either within shapes or unity itself. I am coming from a native iOS development context and for me encountering this issue so early with the simplest example makes me question the whole integrity of the library or unity itself. I mean if there is a weird, unexplainable bug in the simplest example what comes for more complex scenarios and edge cases :-S ?

there's unfortunately a huge number of cases that is almost impossible to cover, at least for me, and even for Unity. there are *many* different ways of rendering things in Unity on the *many* platforms that are supported, so there's bound to be some permutation of conditions that can be incorrectly configured either by me, or Unity, or any of the target platforms, or sometimes even the hardware or drivers.

This is one that I don't have an answer for, because as far as I know, I've done everything correctly on my end, so all I'm left with is thinking it has to be some issue on Unity's end. in some cases, it's even been broken when exporting WebGL in specific versions of chrome, but it works in all other cases, so it turned out google had broken something on their end

all I can do really, is to ask people who are having issues, to help me solve this, by checking any and all logs for any hint about what could possibly be wrong, because I don't own all platforms or even have the possibility to test all cases of everything :c

Avatar
miarfe

There is definitely a gpu instancing issue, either within shapes or unity itself. I am coming from a native iOS development context and for me encountering this issue so early with the simplest example makes me question the whole integrity of the library or unity itself. I mean if there is a weird, unexplainable bug in the simplest example what comes for more complex scenarios and edge cases :-S ?

Avatar
daniel

Hey, I am having this issue too, and can reproduce it in a fresh unity project (URP in 2021.2.0f1 & 2020.3.5f1), building the Sample FPS HUD scene to android/iOS the parts that are drawn with the Draw.Line() only show up if GPU instancing is disabled

Avatar
miarfe

I am using a m1 mac mini. After compiling with the Apple Silicon preview version of unity it renders fine. 

Avatar
Freya Holmér creator

it should work fine - are you getting any build errors or runtime errors in the log files anywhere?

also, are you using the latest version of Shapes?

Avatar
miarfe

Hello! I am experiencing the same issue building on iOS. When I turn off GPU Instancing it draws fine. The moment I turn it on the lines don't draw using immediate mode. I tried a clean reinstall but still not working. Can you please take a look building for iOS? 

Avatar
Freya Holmér creator
Quote from Fan Applelin

Same problem for me.

Draw.Line works in Editor, but not working in Android.

And "clean reinstall" still not working.

does your target device support GPU instancing in Unity? and, are you using the latest version of Shapes

Avatar
Fan Applelin
Quote from Fan Applelin

Same problem for me.

Draw.Line works in Editor, but not working in Android.

And "clean reinstall" still not working.

It works when I turn off GPU Instancing.

Avatar
Fan Applelin

Same problem for me.

Draw.Line works in Editor, but not working in Android.

And "clean reinstall" still not working.

Avatar
Freya Holmér creator

ah, glad it worked out!

Avatar
Anton Orlov

Hello,

yes, clean reinstall did help. My iPhone 7 is now able to draw line with GPU Instancing turned on. Thanks!

Avatar
Freya Holmér creator
  • Answer
  • Unity's Fault

can you try and do a clean reinstall and see if it helps? also, do the platforms you target support GPU instancing?