Search Unity

Very poor performance on Android after upgrading to Unity 5

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

  1. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    I don't get the point of this endless discussion. The problem is easily reproducable. Start a new scene, add a cube and a directional light, build it and rund it on an android device. Do the same in Unity 4.6 and Unity 5 - result: the Unity 5 build is much slower for reasons we can't know, because Unity's a black box to that extend.

    What I don't understand is, how an issue like that - one that can cost developers a lot of time and money and postpone or even prevent releases - can persist for almost FOUR MONTHS now...
     
    Last edited: Jul 21, 2015
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    The problem is that people in this thread are talking about not just one, but several bugs.
    If it is so easy to create a reproduction, what prevents you from submitting a bug report? That's the main issue in this thread, lots of discussion, little productive steps.

    Keep in mind, if Unity can't reproduce it, it is unlikely to be resolved. It can also be related to certain devices, so don't forget to mention those. I still can't find this kind of report in the issue tracker.
     
  3. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    It's slower for the reasons already highlighted loads of times...

    Unity 4.6 is using a blank Skybox, and a simple shader
    Unity 5 is using a procedural Skybox and a PBR shader

    So Unity 5 is doing more...it will be slower, you want them to make it more complex yet just as fast?
     
  4. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    I don't want it to be more complex, the only reason, I'm using Unity 5 right now, is that the free version of it supports reflective and refractive shaders, which the free version of 4.6 didn't. Working without them is pretty cheap, if your scene consists mostly of water. Other than that Unity 5 hasn't given my any other reason to switch yet.

    I did both...

    Here's some update, I've checked the release notes for 5.2, which is currently in beta and to be released on Sept 8th. In there it says among other things:
    • Android: Added support to create a real 16bit RGB565 backbuffer. Deprecated Handheld.use32BitDisplayBuffer
    • Android: Fixed performance regression in Resource.Load when calling it multiple times for the same resource
    Did anyone with a pro license test if Android builds perform better with 5.2?
     
  5. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Yes I did, and yes it does...

    http://forum.unity3d.com/threads/il2cpp-android.339923/

    But, on the main Unity 5 in general is faster than Unity 4, in like for like tests, ie same shaders, etc
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If you submitted reports, do you have the links to the issue tracker? If you post them here in public, everyone who has the same issue can vote for it and as such give it a higher priority.
     
  7. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Plus as yet I haven't seen anyone submit a bug with a ticket...just complain...which generally means user error.
     
  8. andiB

    andiB

    Joined:
    Jan 13, 2013
    Posts:
    26
  9. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Your issue is unrelated to this thread, this is going from Unity 4.x to Unity 5.x, so as I said nothing seams to be being done but complaining...

    I have several bug reports open, they are also unrelated to this thread but do affect Android, I would suggest trying to reply to the Unity Dev who responded to your post and asking if they could see if there is a status update. I assume you included your project? If not, then it will be of no use.
     
  10. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    5.1.2p1 has these fixes:

    • (701873) - Android: Fixed performance regression in Resources.Load.
    • (703999) - Android: Fixed texture compression setting for RGBA textures.

    Has anyone checked again with this build if there performance is improved or not, by the sounds of it things are calming down abit...
     
  11. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    After testing if my issues were related to Resources.Load, which they were, I installed the patch and saw that the lag spike associated with Resources.Load was gone on Android.

    Thanks for pointing out the patch to me.
     
    MrEsquire likes this.
  12. Pharaoh

    Pharaoh

    Joined:
    Jan 8, 2014
    Posts:
    28
    I have just tested my scene in Unity 5.1.2p1.

    unity5.1.2p1.jpg

    unity5.1.2p1-image2.jpg

    Basically I've tried settings almost everything that was mentioned in this forum thread :
    1. Camera Clear Flags : Solid color
    2. Rendering path : Forward (with legacy game is rendered with black artifacts)
    3. Shadows : Disable shadows
    4. Precomputed realtime GI : disabled
    5. V-sync : every option (makes no difference)
    6. Shaders : mobile and legacy
    7. Open GL ES 2 : is only selected
    Phone is LG Nexus 4.
    Sometimes I get something like this posted in the image 1 which is terrible, other times I got something like in image 2.
    I don't have any physics in the scene. My camera just moves over a scene.
    Scene works in ~60fps in Unity 4.6.7.
    I would gladly attach issue but project contains paid asset from asset store. I don't know if I can then post issue like that.
     
    MrEsquire likes this.
  13. guzzo

    guzzo

    Joined:
    Feb 20, 2014
    Posts:
    79
    Well... I am having 60 fps with a Moto G device and 10 to 20 fps with an LG. The game is simple and take less than 3 ms on average (less than 1 ms most of the time) to complete each frame so I think there is a problem between Unity and some devices. I don't think submiting more bug reports would help in this scenaro.

    Unity should start testing games with LG devices and those which are known to have a bad performance in Unity 5, in order to find out what is the root of this problem.
     
    MrEsquire likes this.
  14. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Yes you can submit a bug report to Unity with paid assets.

    Well as no one has submitted one yet, just complained on this thread then yes submitting one would help, I can't recreate the issue myself, other people are not having any issues, so people posting they are having issues are doing something none of the rest of us are...so someone submit a bug then complain it's not been fixed....or don't and don't have it fixed...
     
    Dantus likes this.
  15. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Just got a reply to my bug report (case: 680397) and I could slap that person in the face with a smile :D
    The reply in short was: "The Standard Shader currently is quite unoptimized on mobile [but it's on the roadmap as] Graphics: PBR Mobile Optimizations".
    Okay, I can't say with 100% certainty that I did not use the standard shader in the submitted scene, It's been a long time ago (5 months since submitting). But It's clear that even legacy mobile shaders have the same bad performance in the simple cube test scene I have submitted.
    So their effort goes towards 0. They say the standard shader was the problem in my submitted case, but don't check if the alternatives change anything, wich they don't.
    They gave Adreno 305 as a baseline, not exactly sure how Tegra 3 compares to that (as it was one of my testdevices), I just know Tegra 3 has i higher cpu clock speed (1.200MHz vs 1.500MHz) and it performed just as awful there, even with legacy mobile shaders, I'm certain I tested that at least locally.
     
    MrEsquire likes this.
  16. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If the bug reports clearly state the problematic devices and contain projects that work on other devices, but hardly on the mentioned ones, it is valuable information!
     
  17. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Wow, Thanks for the feedback response -> nothing to see here people -> move along.
    Agree with your points, lets all blame it on the shaders now game..
     
  18. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Why did you pick the standard shader then? Or why didn't you create two scenes, one with the standard and one with the legacy (maybe mobile) to clearly demonstrate it?
     
  19. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Like I said it's been 5 months since then and I can't remember for sure what version i sent. I know for sure i tested mobile shaders on my pc though and it didn't help, it may even be that i sent that version with the report. But that means they did not test their advice for themselves if it's really the case that i've sent a standard shader version.
    Is there a way to re-download the package sent with a bug report?

    Just looked for the project again and at least the local version i still have is set to use Mobile/Diffuse with texture for the background on an inveted cube and for 4 cubes with color and without texture use Legacy/Diffuse.
    I also upgraded it to the latest version of Unity 5 but it still performs worse than Unity 4. The strange thing is that after upgrading from 5.0.x to 5.1.x the mobile/diffuse shader in the material with texture was replaced by standard shader without texture, I manually switched that back before testing of course.

    So it seems like you can't use U5 for a mobile audience as big as with U4 right now.
     
  20. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    In your case, you can't be sure what you submitted, I'd do a new report with the demo you currently have. Or seeing as it's a test scene you could also post it here so people can comment on how it performs for them. Take into account most of us are seeing better performance (I've seen some things that cause slow down and reported them, but that was back in Beta)
     
    Dantus and zyzyx like this.
  21. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Alright, prepared and uploaded a Unity4 and Unity5 version of my simple scene:
    4.6.7f1 version
    5.1.2f1 version
    U5 is bigger because of library files I didn't want to fiddle around with before uploading and potentially breaking something.

    My results with this were on Adreno 205 device:
    U4: (with profiler) 15ms cpu time, solid 60 fps / (without profiler) solid 60 fps
    U5: (with profiler) 19ms cpu time, wonky 44 fps / (without profiler) wonky 54 fps (even going down to 44 for moments)
    feels like 60fps limit is forced here.

    On Tegra 3:
    U4: (with profiler) 10-15ms cpu time, 65-68 fps / (without profiler) wonky 65-80 fps
    U5: (with profiler) 12-17ms cpu time ~64 fps / (without profiler) wonky 63~72 fps

    There's a target fps script on the main camera, but deactivated, this was for iOS devices.

    It seems for Tegra 3 it doesn't make that much of a difference anymore, but for older devices where, with unity 4 I could run whole game worlds at 60fps, 5 simple lightmapped cubes don't perform well anymore.

    Feel free to see how it works for you and post results, although this isn't really a benchmark and it would probably help more if someone made one. :p
     
  22. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Okay, so as a like for like comparison, using the Legacy Shaders/Diffuse still use PBR in Unity 5, which is much slower than Unity 4's ones, so that would explain the performance difference. These are really for Desktop use.
     
  23. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    This looks like a perfect project to compare Unity 4 and Unity5! I couldn't find any avoidable differences. I believe it would be beneficial to make another report, maybe with the Unity 5 version and link to the Unity 4 version and clearly state that there is a performance regression.
    In the project, neither the Standard shader, nor the procedural skybox are being used. The lightmap has the same size and no compression in both cases.
     
  24. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    But as I said it is using the desktop shaders, which are PBR based in Unity 5, and thus sample the reflection probes...which is slower, you have to compare like for like, so that means using shaders that do the same things.
     
  25. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Is Legacy/Diffuse really using PBR? wouldn't that kinda contradict the meaning of "diffuse"? Is there any source for that?
    Because it wouldn't be legacy if it used the new system if you ask me.
    Also the old diffuse in U4 didn't make such a difference either as it's used in the u4 version of the project, too.
     
  26. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Well the Source is the Shader Source files, the Legacy Diffuse has this in the generated code:

    Code (CSharp):
    1.   LightingLambert_GI(o, giInput, gi);
    2.  
    3. //Which calls:
    4.  
    5. inline void LightingLambert_GI (
    6.     SurfaceOutput s,
    7.     UnityGIInput data,
    8.     inout UnityGI gi)
    9. {
    10.     gi = UnityGlobalIllumination (data, 1.0, s.Normal);
    11. }
    12.  
    13. //Which calls a function which does this:
    14.  
    15. half3 env0 = Unity_GlossyEnvironment (UNITY_PASS_TEXCUBE(unity_SpecCube0), data.probeHDR[0], glossIn);
    16.     #if UNITY_SPECCUBE_BLENDING
    17.         const float kBlendFactor = 0.99999;
    18.         float blendLerp = data.boxMin[0].w;
    19.         UNITY_BRANCH
    20.         if (blendLerp < kBlendFactor)
    21.         {
    22.             #if UNITY_SPECCUBE_BOX_PROJECTION
    23.                 glossIn.reflUVW = BoxProjectedCubemapDirection (originalReflUVW, data.worldPos, data.probePosition[1], data.boxMin[1], data.boxMax[1]);
    24.             #endif
    25.  
    26.             half3 env1 = Unity_GlossyEnvironment (UNITY_PASS_TEXCUBE(unity_SpecCube1), data.probeHDR[1], glossIn);
    27.             specular = lerp(env1, env0, blendLerp);
    28.         }
    29.         else
    30.         {
    31.             specular = env0;
    32.         }
    33.     #else
    34.         specular = env0;
    35.     #endif
    36.  
    37.  
    Although, it looks like it's being updated in the newer shader source code, so might not be so much an issue soon.

    And you did explicitly set Reflection Probes to simple, so you could have turned them off which might have helped!

    But as these are for desktop use, why would you use them for an Android build?

    So, basically use the mobile shaders, its what they are for, or wait for the updated Desktop ones, but I still wouldn't use them.
     
  27. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    I just downloaded the unity shaders from 5.1.2 where it includes the shader name in the beginning of the source, as usual and that is:
    Code (CSharp):
    1. Shader "Legacy Shaders/Diffuse" {
    2. Properties {
    3.     _Color ("Main Color", Color) = (1,1,1,1)
    4.     _MainTex ("Base (RGB)", 2D) = "white" {}
    5. }
    6. SubShader {
    7.     Tags { "RenderType"="Opaque" }
    8.     LOD 200
    9.  
    10. CGPROGRAM
    11. #pragma surface surf Lambert
    12.  
    13. sampler2D _MainTex;
    14. fixed4 _Color;
    15.  
    16. struct Input {
    17.     float2 uv_MainTex;
    18. };
    19.  
    20. void surf (Input IN, inout SurfaceOutput o) {
    21.     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    22.     o.Albedo = c.rgb;
    23.     o.Alpha = c.a;
    24. }
    25. ENDCG
    26. }
    27.  
    28. Fallback "Legacy Shaders/VertexLit"
    29. }
    30.  
    Edit:
    Okay saw 'generated code' too late, will check that!
    Although this shader does not react to reflection probes or skybox, has no reflectivity values or anything that actually includes PBR effects.

    Edit2:
    Checked the compiled code of the shader (Legacy Shaders/Diffuse -> compile and show code)
    it starts with:
    Code (CSharp):
    1. // Compiled shader for Android, uncompressed size: 508.4KB
    2.  
    3. // Skipping shader variants that would not be included into build of current scene.
    4.  
    5. Shader "Legacy Shaders/Diffuse" {
    6. Properties {
    7. _Color ("Main Color", Color) = (1,1,1,1)
    8. _MainTex ("Base (RGB)", 2D) = "white" { }
    9. }
    10. SubShader {
    11. LOD 200
    12. Tags { "RenderType"="Opaque" }
    13. ...
    And serching for "LightingLambert_GI" in that whole 17439 lines long generated file gave me 0 results.
     
    Last edited: Aug 6, 2015
  28. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    At the end, the implementation doesn't matter. The legacy shader is supposed to behave as the old one and consequently it should have a comparable performance. If more computations are being done for no obvious reason, it is a performance regression from my point of view.
     
  29. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Your complaining that shaders designed for Desktop do not work as well on mobile when they are doing more, when you are using Reflection Probes as an extra feature that never existed in Unity 4.6... The mobile shaders are for mobile, compare those, then complain, don't go comparing things that are different and then complain, the Legacy shaders are not designed for Android, thats what the Mobile ones are for...

    But, in 5.2 I can confirm they do not sample the reflections on the Legacy Diffuse, so maybe that will allow those shaders to be used...I would advise people against it though...even in 4.6 it kills a Mali-400 chip, which is a pretty popular GPU.
     
  30. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Okay, I did a test just for you, switched the 4 Legacy Shaders/Diffuse (only colored) boxes to Mobile/Diffuse with 4 8x8 color textures, and it gives me the exact same FPS on my weaker device: ~54 FPS
     
  31. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    The platform doesn't matter in this discussion, because Legacy Diffuse in Unity 5 is supposed to be what the Diffuse shader was in Unity 4. If reflection computations were added, it is clearly a bug.
    Whether it is a good idea to use that shader on mobiles is a completely unrelated question. If that shader was not supposed to be used at all on mobiles, it wouldn't have worked in Unity 4.
     
  32. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    I'd set the reflection probes to off, then retest if you still get lower performance, submit a bug and reference this thread within the submission, and I'd include both projects.
     
  33. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Well like I said, it kills a Mali-400 even on Unity 4, things move on with the progress of technology so you can't just go we won't add any new features so we can support all the out of date stuff, those shaders are for desktop and still work on a very old PC, nowhere is it stated that the Legacy/Deferred are the exact same shaders, and the platform is relevent as this is a thread about Android.

    Whereas, it's always been said to use the Mobile Shaders for Mobile.
     
  34. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    there are no reflection probes in the scene to begin with, to be able to compare 4 & 5. I noticed the 4 small cubes mesh renderer components seem to still have had that set to simple, but running it again with "off" changed nothing, still the exact same 54 fps, probably because the shaders used don't make use of that at all for rendering and the mesh renderer component would just be looking up the necessary cubemap reference in case it was needed wich is a pretty simple process, especially without cubemaps in the scene.
     
  35. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    You had Reflection Probes set to Simple on each of the Cubes, and the Cubemap gets generated form the Lightmap panel. It might be still doing a lookup, I don't use the built-in shaders, but between 4 and 5, the mobile diffuse is using the same lighting function:

    #pragma surface surf Lambert noforwardadd

    Which, will of course call the same lighting and use the Cubemap sample, this looks wrong to me, and Cubemap sample is not exactly cheap, not when you are already sampling other textures too (lightmap and textures...)

    I wouldn't be surprised if you got better performance using Mobile/Bumped Specular, which should be more expensive, but looking through it's probably cheaper.
     
  36. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    This is not the point of the discussion! The point of legacy is that it doesn't move on and doesn't have considerable changes like considering reflections!
    There is technology progress and that is achieved with the new Standard shaders. They could have decided e.g. to remove the Diffuse shader, but if they keep it for compatibility reasons, it should be compatible also regarding the performance. If they can't provide a compatible version, they should remove it! The platform is still not relevant for this discussion.
     
  37. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Nope nope nope, there are no generated cubemap files from the lightmap (what position should it generate it from anyways?) anywhere, and the cubes do not have reflection probe components that would generate cubemaps.
    Lightmap would use the skybox as general reflection source if there are no other cubemaps, but there's not even a skybox in that scene.
    I even changed Reflection souce from skybox (where there's none set anyways) to custom - none, still 54fps.

    I would assume it's a result from the general new lighting backend (enlighten), even though there's no realtime lights going on, but who knows what that is costing on idle.
     
  38. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Reflection Source is set to Skybox, even though you don't have one, but the key thing is you have Reflection Probes set to Simple, it will still try and process them and sample them.
     
  39. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    And yet with that set to off it changes nothing not even 1fps difference.
     
  40. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    I see your point, but, do that and people will complain the reflection probes are not working with the Legacy Shaders... being a regular forum user, people complain about everything, no matter which way they do it....
     
  41. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Like I said though, in the source files it looks like they are sampling it regardless...

    But it would save on a little CPU, if you profile there is a bit where it calculates the reflection probes, turning these to off stops it doing it, in this situation it's probably making too small a difference.
     
  42. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    You saw my post where i said i checked the compiled legacy diffuse for android as target platform, too and couldn't find that, did you?
     
  43. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    I mean in the Unity Shader source files, not in yours, I'm saying it looks like a bug and I think you should submit it. It also looks like in the 5.2 ones they have changed them so...
     
  44. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    Yeah, I downloaded the ones from the website, there it's the first one i posted. Then i selected the material of a small cube with legacy diffuse as shader (built-in - not importet) for it's material clicked the small cogwheel -> select shader and then clicked on "Compile & Show Code". That gives whe what officially is currently built in and will be running.
    The generated file is 17439 lines long, is compiled for android, and does not contain LightingLambert_GI anywhere (ctrl+f).
     
  45. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    When compiled it doesn't show up, you have to look through the source instead.
     
  46. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    The source? The .shader file for legacy diffuse? or what source? I posted the whole legacy/diffuse shader a few posts ago and mentioned it in my post before yours again, there's nothing like that in it aswell.
     
  47. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    You have to go through all the source files, start by finding the lighting function it's using, if you're not familiar with Shader coding you will have no chance of finding it.
     
  48. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    I have my doubts about that right now, so I'd prefer waiting for another one to confirm that if it's true.
    To not argue about something I might be missing for some stupid reason, I'll wait for another person who feels knowledgable about this to say something.
     
  49. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Users complain about everything, that's for sure. But if you name something legacy, it is a clear statement that it is preserved for a certain amount of time, but not being extended. Complaining that something is not being extended, that is by definition not extended anymore is definitely not reasonable.
     
  50. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    1st thing I got rid of was the PBR shaders, they'll be nice when mobile devices can do the DirectX 12 / Vulkan graphics but for today's and yesterday's devices PBS is mostly too much.

    There is more going on but it is the standard skybox that causes that.