Search Unity

Unity UI Problem with UI Mask on Android 5 since Unity 2018.3.x

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Riddik, Mar 7, 2019.

  1. Riddik

    Riddik

    Joined:
    Jun 16, 2017
    Posts:
    15
    Hi
    Since Unity 2018.3.x UI Mask doesn't work on Android 5.0.1.It doesn't draw itself and its children.
    Tested on Samsung Galaxy S4 GT-I9500 Android 5.0.1
    On Unity 2018.2.x and older everything's ok with mask. It has the issue only on Unity 2018.3.x and with Android 5

    How can reproduce the issue.

    1. Just create a new project in Unity 2018.3.x (we used 2018.3.6 and 2018.3.7)
    2. Switch target on Android
    3. In the new empty scene create Canvas, then create UI Mask into the Canvas.
    4. Create UI Image as a child object of Mask. Any combinations.
    5. Build the project for Android and test on Android version 5
     
  2. Riddik

    Riddik

    Joined:
    Jun 16, 2017
    Posts:
    15
    2018.3.8 has this issue too
     
  3. Rom4ikq

    Rom4ikq

    Joined:
    Sep 13, 2017
    Posts:
    3
    Hi. I've replaced clip function in all shaders and it seems working.
    From:
    Code (CSharp):
    1. clip(%value%);
    To:
    Code (CSharp):
    1. bool clip = (%value%) < 0.0f;
    2. clip = (int(clip) * int(0xffff))==0;
    3. if(!clip)
    4.    discard;
    It looks like a bug in unity.
     
    Riddik likes this.
  4. Riddik

    Riddik

    Joined:
    Jun 16, 2017
    Posts:
    15
    Hmm, I'll try it!
    Thanks a lot Rom4ikq
     
  5. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,263
    Could you please submit a bug-report as described in this document:
    https://unity3d.com/unity/qa/bug-reporting

    It's important that you report these issues together with a reproduction project if you want them to get fixed. If you don't do it, it might be a long time until someone else reports them or until Unity Technologies find them.

    After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. You can post this Case number here (in this forum thread) for Unity staff to pick up, in case they see it.
     
  6. Riddik

    Riddik

    Joined:
    Jun 16, 2017
    Posts:
    15
    I already done it: https://fogbugz.unity3d.com/default.asp?1134858_u5l2qgp9bepgsap3
    Is it needed to Rom4ikq done the same?
     
    unityeightingame likes this.
  7. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    63
    Same issue here since upgrading a project from 2018.2 to 2018.3. We experience a few Android devices not drawing scrollview content and other Mask clipped content anymore. OS version 4.4.2 - 5.x (not sure about newer versions). Looks like OpenGLES2 affected only, x86 and arm.

    Removing the mask component makes the scrollview render correctly on this affected devices
     
    Last edited: Mar 22, 2019
  8. sayiliromer

    sayiliromer

    Joined:
    May 30, 2017
    Posts:
    10
    I got same issue. Did they tell anything on fixing it ?
     
  9. dominykasm

    dominykasm

    Unity Technologies

    Joined:
    May 27, 2018
    Posts:
    52
    What was the version of 2018.2 that this didn't occur on? I reproduced the issue with your project on 2018.2.0
     
    Last edited: Mar 27, 2019
  10. dominykasm

    dominykasm

    Unity Technologies

    Joined:
    May 27, 2018
    Posts:
    52
    With which devices did you experience this issue? (Please note the GPU's of the devices)
     
  11. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    63
    Just reproduced on this devices:
    - Unity 2018.3.10f1, LENOVO Lenovo A3000-H, PowerVR SGX 544MP, Android 4.4.2
    - Unity 2018.3.9f1, ASUS ASUS_T00J, PowerVR SGX 544MP2, Android 4.4.1

    any many more PowerVR 544 MP devices...

    Just to note:
    - There was no problem with 2018.2.20f1
    - Everything renders correctly again with 2018.3.9 / 2018.3.10 as soon as we disable the Mask components
     
    Last edited: Mar 28, 2019
  12. sayiliromer

    sayiliromer

    Joined:
    May 30, 2017
    Posts:
    10
    We got 3 devices reported. All of them are using PowerVR 544
     
  13. Riddik

    Riddik

    Joined:
    Jun 16, 2017
    Posts:
    15
    2018.2.21 is ok on my tested device (Samsung Galaxy S4 GT-I9500 Android 5.0.1)
     
  14. Riddik

    Riddik

    Joined:
    Jun 16, 2017
    Posts:
    15
  15. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
    That's a major bug, and very hard to find the causing issue, or a term to search (simply my whole UI wouldnt draw with no log messages, I didnt know where to look, found this by luck), that's why this thread is not flooded with complains.

    Please Unity team prioritize this issue, it seems it is being ignored by you guys (20+ days since this thread started and it's a major bug!). I cant update my game in production due to this bug. If I knew about this bug last week I would annoy you guys at GDC to get this fixed.
     
  16. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    63
    Yes, also rather major for us. We restructure our project to make use of nested prefabs, so can't go back to 2018.2 and have a lot of users complaining with no chance to fix this by ourself...
     
  17. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
    I just noticed the issue is from DECEMBER... holy ****, we're screwed
     
  18. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
    @Rom4ikq can you explain a bit more how to do the solution? Im not familiar with shaders

    @Riddik have you tested the solution? Did it work?
     
  19. Riddik

    Riddik

    Joined:
    Jun 16, 2017
    Posts:
    15
    Not yet.
     
  20. Rom4ikq

    Rom4ikq

    Joined:
    Sep 13, 2017
    Posts:
    3
    Need to create material with this shader. Add material to the image component, the nearest mask component.
    Code (CSharp):
    1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
    2.  
    3. Shader "Custom/UI/Default"
    4. {
    5.     Properties
    6.     {
    7.         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
    8.         _Color ("Tint", Color) = (1,1,1,1)
    9.  
    10.         _StencilComp ("Stencil Comparison", Float) = 8
    11.         _Stencil ("Stencil ID", Float) = 0
    12.         _StencilOp ("Stencil Operation", Float) = 0
    13.         _StencilWriteMask ("Stencil Write Mask", Float) = 255
    14.         _StencilReadMask ("Stencil Read Mask", Float) = 255
    15.  
    16.         _ColorMask ("Color Mask", Float) = 15
    17.  
    18.         [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
    19.     }
    20.  
    21.     SubShader
    22.     {
    23.         Tags
    24.         {
    25.             "Queue"="Transparent"
    26.             "IgnoreProjector"="True"
    27.             "RenderType"="Transparent"
    28.             "PreviewType"="Plane"
    29.             "CanUseSpriteAtlas"="True"
    30.         }
    31.  
    32.         Stencil
    33.         {
    34.             Ref [_Stencil]
    35.             Comp [_StencilComp]
    36.             Pass [_StencilOp]
    37.             ReadMask [_StencilReadMask]
    38.             WriteMask [_StencilWriteMask]
    39.         }
    40.  
    41.         Cull Off
    42.         Lighting Off
    43.         ZWrite Off
    44.         ZTest [unity_GUIZTestMode]
    45.         Blend SrcAlpha OneMinusSrcAlpha
    46.         ColorMask [_ColorMask]
    47.  
    48.         Pass
    49.         {
    50.             Name "Default"
    51.         CGPROGRAM
    52.             #pragma vertex vert
    53.             #pragma fragment frag
    54.             #pragma target 2.0
    55.  
    56.             #include "UnityCG.cginc"
    57.             #include "UnityUI.cginc"
    58.  
    59.             #pragma multi_compile __ UNITY_UI_CLIP_RECT
    60.             #pragma multi_compile __ UNITY_UI_ALPHACLIP
    61.  
    62.             struct appdata_t
    63.             {
    64.                 float4 vertex   : POSITION;
    65.                 float4 color    : COLOR;
    66.                 float2 texcoord : TEXCOORD0;
    67.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    68.             };
    69.  
    70.             struct v2f
    71.             {
    72.                 float4 vertex   : SV_POSITION;
    73.                 fixed4 color    : COLOR;
    74.                 float2 texcoord  : TEXCOORD0;
    75.                 float4 worldPosition : TEXCOORD1;
    76.                 UNITY_VERTEX_OUTPUT_STEREO
    77.             };
    78.  
    79.             sampler2D _MainTex;
    80.             fixed4 _Color;
    81.             fixed4 _TextureSampleAdd;
    82.             float4 _ClipRect;
    83.             float4 _MainTex_ST;
    84.  
    85.             v2f vert(appdata_t v)
    86.             {
    87.                 v2f OUT;
    88.                 UNITY_SETUP_INSTANCE_ID(v);
    89.                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
    90.                 OUT.worldPosition = v.vertex;
    91.                 OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
    92.  
    93.                 OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
    94.  
    95.                 OUT.color = v.color * _Color;
    96.                 return OUT;
    97.             }
    98.  
    99.             fixed4 frag(v2f IN) : SV_Target
    100.             {
    101.                 half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
    102.  
    103.                 #ifdef UNITY_UI_CLIP_RECT
    104.                 color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
    105.                 #endif
    106.  
    107.                 #ifdef UNITY_UI_ALPHACLIP
    108.                
    109.                 bool a = color.a - 0.001 < 0.0f;
    110.                 a = (int(a) * int(0xffff))==0;
    111.                 if(!a)
    112.                     discard;
    113.              
    114.                 #endif
    115.  
    116.                 return color;
    117.             }
    118.         ENDCG
    119.         }
    120.     }
    121. }
    122.  
     
  21. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
    Last edited: Apr 4, 2019
  22. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
    I talked with Unity QA support and they said the vanishing issue was a problem caused by they trying to change the target version of the issue from 2019.2 to 2018.3, but the issue is still alive and fixed and should be rolled out in a future 2018.3 version (exactly which is not known yet).
    So, great news!
     
  23. Dust9999

    Dust9999

    Joined:
    Jan 10, 2014
    Posts:
    2
    Same bug (sprite mask just not works) at
    Samsung Galaxy Tab 2 ANDROID 4.2.2
    GPU PowerVR SGX540

    And can't reproduce at mobile device:
    HTC with TEGRA GPU and same ANDROID 4.2.2

    Please fix it. Bug start from 2018.3.x version at 2018.2.19 all works great
     
  24. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    63
    According to issue tracker fix will be in 2018.3.14
     
  25. sayiliromer

    sayiliromer

    Joined:
    May 30, 2017
    Posts:
    10
    They marked as Fixed in Unity 2018.3.9f1 but it says Fix will be in Unity 2018.3.14 . I am confused
     
  26. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
    Where did you see that?
     
  27. sayiliromer

    sayiliromer

    Joined:
    May 30, 2017
    Posts:
    10
  28. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
  29. pertz

    pertz

    Joined:
    Jan 8, 2015
    Posts:
    88
    Fix will be in Unity 2018.3.14, but they just forgot to tell when will that version be released :D:D

    According to Unity's weekly release schedule it should have been released 2 days ago, but for some undisclosed reason this week's release is delayed... again.
     
  30. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    136
    Still not working on 2019.2 and 2018.4.5f
    Samsung Galaxy J4+
     
  31. Vuda

    Vuda

    Joined:
    Sep 26, 2017
    Posts:
    4
    Still not working on 2019.1.5 and 2019.2.12.
    Samsung GalaxyTab A SM-T380 Android 9.