Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Very poor performance on Android after upgrading to Unity 5

Discussion in 'Android' started by digitalMUTANT, Mar 3, 2015.

  1. Shredov

    Shredov

    Joined:
    Mar 24, 2014
    Posts:
    14
    I can confirm I'm experiencing very similar issues. I just upgraded a project from unity 4.6.1 to 5.1 and am seeing a major drop in performance.

    Here are the highlights in context of this topic:
    - Device: moto e (first gen) android 4.4.4
    - I have a scene with an average of 20 draw calls, 2.1k tris and 2.2k verts.
    - I am NOT using a skybox cam,
    - no shadows in scene
    - no reflections in scene
    - all 2D objects
    - a combination of mobile and custom shaders
    - v-sync is on 'every VBlank'
    - I'm also using no canvas, but am using ngui

    When I disable shadows in 5.1 it seems to increase the performance dramatically, but it still doesn't run as smooth as 4.6 with shadows still on. Disabling reflections seemed to do nothing in my case.

    No, I have not submit a bug report but, before anyone get's riled up know that I'm working on one. I'm going to put together some more hard info before submitting the report and will update you guys, for now I'm just tired and calling it a night.

    The purpose of this post was to try and get others in the right direction in case it just so happens that this turns out to be what is causing the majority of the issues for people.... I'll be back

    ****
    Edit: grammar, added android OS version
     

    Attached Files:

    Last edited: Aug 19, 2015
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    Shadow performance on Android in Unity 5 is absolutely horrible. You'll need to resort to lightmapping and shadow projectors as a substitute.
     
    Shredov likes this.
  3. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I think the point may have been:

    "
    no shadows in scene"

    Yet :

    "
    disable shadows in 5.1 it seems to increase the performance dramatically" (well that's what stood out to me).

    Would that be expected? Am I missing something?
     
  4. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    I would expect that, as I'd assume the shadow casting camera would get created anyway as well as the additional code in the shaders to sample the shadows.
     
  5. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    I test on Unity 5.0, 5.1 and 5.2 too.

    My game is a 2D board game, very simple.

    It works great on iOS, and on web. But it's just HORRIBLE on Android.

    I can't explain why.

    I follow all your discussion, and in my case I don't have any physics, no collider, no shadow, no cam effect. Just Sprites and Canvases (for the menu and infos during the game).

    I have 10'000 FPS on my profiler (editor).


    I didn't see a word about Unity Team in this subject.

    But if all the users of Unity on Android have this issue, it should be a tsunami. So I think it's a very specific issue.

    What do you think?

    Thanks!
     
    MrEsquire likes this.
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    There are tons of Android devices, so the kind of device has certainly a huge impact. As it indeed seems to be for some specific devices or issues, those who experience the poor performance should submit bug reports.
     
  7. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    I have a Nexus 7, Android 5.1.1

    No reason to have a performance issue with that. :(
     
    MrEsquire likes this.
  8. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    So changes e.g. in the way Unity is using OpenGL which has proven to be very efficient on Unity's test devices can not have a bad impact and a high end device, with a graphics driver that for whatever reason doesn't like that change?
     
  9. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Sounds like a good idea.

    What can I do with open GL?
     
  10. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Ok when I disable OPENGLES3 the FPS is ok but... I have some problem with my screen. I can"t see all my screen : (
     
  11. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Submit a bug report containing the Unity project and be sure all the build options, Android SDK versions, ... is included and mention the actual device with which you have performance issues.
     
  12. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Ok I will do this right now.

    Thanks
     
  13. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    I changed the UI Default shader and create a material who I applied to all the UI Images and it works fine now !

    Shader "UI/Default-custom"
    {
    Properties
    {
    [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
    _Color ("Tint", Color) = (1,1,1,1)

    _StencilComp ("Stencil Comparison", Float) = 8
    _Stencil ("Stencil ID", Float) = 0
    _StencilOp ("Stencil Operation", Float) = 0
    _StencilWriteMask ("Stencil Write Mask", Float) = 255
    _StencilReadMask ("Stencil Read Mask", Float) = 255

    _ColorMask ("Color Mask", Float) = 15
    }

    SubShader
    {
    Tags
    {
    "Queue"="Transparent"
    "IgnoreProjector"="True"
    "RenderType"="Transparent"
    "PreviewType"="Plane"
    "CanUseSpriteAtlas"="True"
    "ForceNoShadowCasting"="True"
    }

    Stencil
    {
    Ref [_Stencil]
    Comp [_StencilComp]
    Pass [_StencilOp]
    ReadMask [_StencilReadMask]
    WriteMask [_StencilWriteMask]
    }

    Cull Off
    Lighting Off
    ZWrite Off
    ZTest Off
    //ZTest [unity_GUIZTestMode]
    Blend SrcAlpha OneMinusSrcAlpha
    ColorMask [_ColorMask]

    Pass
    {
    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag

    #include "UnityCG.cginc"
    #include "UnityUI.cginc"

    struct appdata_t
    {
    fixed4 vertex : POSITION;
    fixed4 color : COLOR;
    fixed2 texcoord : TEXCOORD0;
    };

    struct v2f
    {
    fixed4 vertex : SV_POSITION;
    fixed4 color : COLOR;
    fixed2 texcoord : TEXCOORD0;
    fixed4 worldPosition : TEXCOORD1;
    };

    fixed4 _Color;
    fixed4 _TextureSampleAdd;

    //bool _UseClipRect;
    //float4 _ClipRect;

    bool _UseAlphaClip;

    v2f vert(appdata_t IN)
    {
    v2f OUT;
    OUT.worldPosition = IN.vertex;
    OUT.vertex = mul(UNITY_MATRIX_MVP, OUT.worldPosition);

    OUT.texcoord = IN.texcoord;

    #ifdef UNITY_HALF_TEXEL_OFFSET
    //OUT.vertex.xy += (_ScreenParams.zw-1.0)*fixed2(-1,1);
    #endif

    OUT.color = IN.color * _Color;
    return OUT;
    }

    sampler2D _MainTex;

    fixed4 frag(v2f IN) : SV_Target
    {
    fixed4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;

    //if (_UseClipRect)
    // color *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);

    if (_UseAlphaClip)
    clip (color.a - 0.1);

    return color;
    }
    ENDCG
    }
    }
    }
     
  14. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    So what are you saying the issue is again to do with the Standard Shaders?
     
  15. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Yes....
     
  16. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thanks for the confirmation, well Unity should really work on this in the next release, not sure why its not a top priority, of course us mobile people going to worry and moan about it..we simple dont have space for fps loss.
     
  17. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    http://unity3d.com/unity/roadmap
     
    Last edited: Aug 25, 2015
  18. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    MrEsquire likes this.
  19. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If you just read the headlines, you could assume that only low-end devices will profit from it. If you check what will be done, it becomes easily visible that...
    As I have the impression that the goal is not to get actual constructive information, I think it is better to not further waste my time.
     
  20. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    Sorry if you understand that, it was not my goal.
     
  21. mdrotar

    mdrotar

    Joined:
    Aug 26, 2013
    Posts:
    377
    Your contributions to this thread have been very helpful and obviously constructive. Thanks!
     
    ababab5 likes this.
  22. Joskym

    Joskym

    Joined:
    Oct 2, 2013
    Posts:
    39
    We noticed something with 2D games.
    We had back plane using Sprite default shader(So it was basically covering all the screen)
    See the blue sprite covering almost all the screen:


    The default Sprite shader is handling Alpha, and you know that Alpha covering all the screen is really bad. So we duplicated this shader, removing the Alpha handling, we now have an opaque sprite shader:
    (Maybe we can optimize it more but I'm a real noob with shaders ahah)
    Code (CSharp):
    1. Shader "Sprites/Default-NoAlpha"
    2. {
    3.     Properties
    4.     {
    5.         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
    6.         _Color ("Tint", Color) = (1,1,1,1)
    7.         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
    8.     }
    9.  
    10.     SubShader
    11.     {
    12.         Tags
    13.         {
    14.             "Queue"="Geometry"
    15.             "IgnoreProjector"="True"
    16.             "RenderType"="Opaque"
    17.             "PreviewType"="Plane"
    18.             "CanUseSpriteAtlas"="True"
    19.         }
    20.  
    21.         Cull Off
    22.         Lighting Off
    23.         ZWrite Off
    24.  
    25.  
    26.         Pass
    27.         {
    28.         CGPROGRAM
    29.             #pragma vertex vert
    30.             #pragma fragment frag
    31.             #pragma multi_compile _ PIXELSNAP_ON
    32.             #include "UnityCG.cginc"
    33.            
    34.             struct appdata_t
    35.             {
    36.                 float4 vertex   : POSITION;
    37.                 float4 color    : COLOR;
    38.                 float2 texcoord : TEXCOORD0;
    39.             };
    40.  
    41.             struct v2f
    42.             {
    43.                 float4 vertex   : SV_POSITION;
    44.                 fixed4 color    : COLOR;
    45.                 half2 texcoord  : TEXCOORD0;
    46.             };
    47.            
    48.             fixed4 _Color;
    49.  
    50.             v2f vert(appdata_t IN)
    51.             {
    52.                 v2f OUT;
    53.                 OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
    54.                 OUT.texcoord = IN.texcoord;
    55.                 OUT.color = IN.color * _Color;
    56.                 #ifdef PIXELSNAP_ON
    57.                 OUT.vertex = UnityPixelSnap (OUT.vertex);
    58.                 #endif
    59.  
    60.                 return OUT;
    61.             }
    62.  
    63.             sampler2D _MainTex;
    64.  
    65.             fixed4 frag(v2f IN) : SV_Target
    66.             {
    67.                 fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
    68.                 return c;
    69.             }
    70.         ENDCG
    71.         }
    72.     }
    73. }
    74.  
    Before on a Moto G, the game was always switching from 60 to 30FPS every second, causing sluttering.
    Now we have stable 60FPS.
    (Please note that we also choosed to render the game 85% of every native phone resolution)
     
  23. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Yes this is a normal thing for mobiles, not specific to Unity 5.
     
  24. Joskym

    Joskym

    Joined:
    Oct 2, 2013
    Posts:
    39
    I didn't say it was specific. We had a performance issue, we solved it. Maybe it can help some people here solving their problems :) (Just trying to help dude)
     
    mdrotar and Jonny-Roy like this.
  25. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Sorry, I might be too sensitive in this thread, as the majority of users are complaining in here.
     
    ababab5 likes this.
  26. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    I can understand ;)
     
  27. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    I want to say that I also had a big performance drop upgrading my game OneBeer! from Unity 4.6.3 to 5.1.2.

    Before the upgrade it was running around 35fps on a Galaxy S Duos (GT-S7562), (this phone have 1 core@1Ghz).

    After the upgrade it runs at 21fps. Also I had to change the shader "mobile->unlit (supports lightmap)" because it looks all Black in the phone (it looks right in Unity editor).

    Regards.
     
  28. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    What's the number of the bug report?
     
  29. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    Did you do a fresh bake in Unity 5 with the mobile unlit shader?
    Note, that if you have shaders that change at run-time from the original baked shader, they will appear black.
     
    Dantus likes this.
  30. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    I didn´t sent a bug report because I saw a lot of people with this low performance, even in a empty scene (with regards to the Unity 4 version).
     
  31. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    Yes I rebaked the scene because it losed the lightmap after import in Unity 5. But, after rebake it shows the lightmap corretly in the Unity 5 Editor. But when I build to android these textures looks all black.

    I just try to reproduce the same problem in a simple scene, but now it show the base texture but don´t have lightmap (in this case the textures don´t looks black, they have the base texture, but no lightmap). But if I select the "mobile->diffuse" the lightmap works corretly.

    I will send a bug report about it, but I don´t know if they resolve it, the Black textures also will go away in my current proyect.
     
  32. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    I did sent the bug report (Case 723972).

    Tested on Android phones:
    Samsung Galaxy S Duos GT- S7562, Android 4.0.4 version.
    Samsung Galaxy S5 (SM-G900F), Android 5.0 version.

    Unity version:
    5.1.3p1, Personal Edition.

    Regards.
     
    Last edited: Aug 31, 2015
  33. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    There were a lot of people who e.g. used the procedural sky when they made the empty scene tests and got worse performance because of that, making it not an actual comparison anymore.
     
  34. Mihai77

    Mihai77

    Joined:
    Aug 7, 2013
    Posts:
    8
    @Dantus - Unfortunately - according with the roadmap, the "PBR Mobile Optimizations" are planned in the medium/long term.
    Having in mind the new Culling Groups, UI Batching and IL2CPP??, i hope that the new version 5.2 will bring a performance improvement :).
     
  35. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    I will try to remove almost all in my game to see if I can send the reduced proyect to bug report (black textures with "mobile->unlit (supports lightmap)" shader).
     
  36. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    with regards to use standard ilumination on Unity 5 (the equivalent for Unity 4), what is needed to do?:

    setting the "environment lighting" -> "Skybox" to "none".
    setting the "environment lighting" -> "Ambient source" to "color".
    setting the "environment lighting" -> "reflection source" to "custom" -> Cubemap: "None".
    Turning OFF "Precomputed realtime GI".
    Using "mobile "shaders instead of the new "Standard shader".

    Setting all of the above it should compare to Unity 4 performance?.
     
  37. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    Done.

    Case: 724226

    Regards.
     
  38. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    I got an answer from Unity:

    Case 723972.

    Hey,

    Thanks for reporting the issue.

    We have fixed this and problem will not appear in the Unity 5.2 release.
    If will are able to reproduce it on Unity 5.2, please respond to this email.
     
  39. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508

    Thanks for the feedback!

    But I don't see any release of Unity 5.2... and you ?
     
    www_3dart_es likes this.
  40. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It is not yet officially released, but there are release candidates:
    https://unity3d.com/unity/beta
     
  41. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    This RC was available before your post, and since few weeks... I don't think we can find the fix inside :(
     
  42. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    Maybe it is inside the new RC or the final release.


    More good news (about the Black textures in "mobile->unlit (supports lightmap)" shader). Answer from Unity team:

    Case 724226
    Hi again,

    Yes, that was the same issue and it will not be present in Unity 5.2 release.
     
  43. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
  44. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Anyone tried and upgraded to Unity 5.2 final?
    If so hows the performance and most importantly has anyone had replies to there bug reports?
     
  45. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    I did the upgrade.
    No change :( (tested on Nexus9)
     
    MrEsquire likes this.
  46. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    Case 724226 and Case 723972 was fixed.

    The performance was increased around 2-3fps using the "Mobile ->Unlit (supports lightmap)" shader, but it is still far away from Unity 4.x performance in my Android proyect.

    Regards.
     
    MrEsquire likes this.
  47. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    thanks for the advice.

    And what about the sprite renderer ?
     
  48. www_3dart_es

    www_3dart_es

    Joined:
    May 24, 2013
    Posts:
    219
    Sorry, what is new about sprite renderer?.
     
  49. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    I use the default sprite shader for it
     
  50. Marceta

    Marceta

    Joined:
    Aug 5, 2013
    Posts:
    177
    Is vsync bug fixed i lastest relase? Should i put it on or off?