Search Unity

[5.3] Elements in the UI flicker between different sprites

Discussion in 'UGUI & TextMesh Pro' started by CiroContns, Dec 10, 2015.

  1. Gizmmoo

    Gizmmoo

    Joined:
    Feb 4, 2015
    Posts:
    10
    a-dogg likes this.
  2. Rizzonian

    Rizzonian

    Joined:
    Nov 28, 2012
    Posts:
    29
    Would getting your hands on our project help out at all? We are willing to do whatever we can to help out.
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Dont think so atm, we have a pretty reliable repo case that we are using to track down where the issue is. We've found out that it has been present since 5.2 just with less reproducibility so we have a lot of code changes to work through :(.

    We will let you know and if we need a extra data set we will reach out.
     
    karl_jones likes this.
  4. Gizmmoo

    Gizmmoo

    Joined:
    Feb 4, 2015
    Posts:
    10
    [May Have a Potential Fix]

    So while I was following the steps to shrink the build so that you guys didn't have to get all my assets, at one point the flickering suddenly stopped. So I went through a process of elimination and found a single component that was causing my problem. Now I'm not sure if this is going to fix everyone else's problems, perhaps this is just a very similar bug I was having but I'll link a photo below.

    It was a reflection probe in type: Realtime that was causing our flickering.
    Pre-5.3 this probe didn't cause any errors and setting back to 5.2 fixed the problem. To fix the problem in 5.3, we have for now changed our reflection probe from type: Realtime to type: Baked, and the problem disappeared instantly. Now there may be more minor settings that allow you to keep realtime, I couldn't find it though. I tried other options like making sure the culling mask didn't include UI, and turning of Occlusion Culling, but the only one that worked other then deactivating it was changing it to type: Baked.

    The error we were having, just to make sure I'm in line with everyone here, was that our UI menu game objects would flicker with other random sprites we had in our UI whenever we moved our mouse over them. We didn't need to ever click anything, but we did have a slider component that when moved would REALLY cause flickering. Again no problem pre 5.3, just when we upgraded it started.

    Again, to fix our problem, we had a reflection probe in our scene that was in Realtime, and we changed it to baked, and the problem instantly went away. I tried disabling everything else in the scene and the problem would persist, but as soon as I disabled the reflection probe, the problem disappeared.

    [Edit]
    So everyone knows, this was the only reflection probe in this scene. Not sure what happens with multiple reflection probes

    Not sure if this is going to help anyone out, but if theres a chance it helps any projects out, give it a chance, or maybe it will help lead to the bug. Hope it helps everyone!!
    Screen Shot 2016-01-19 at 4.10.34 PM.png
     
    Last edited: Jan 19, 2016
    MrEsquire likes this.
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hey. Quick update.
    We have not yet identified the problem however we have stumbled upon a potential workaround that seems to work for us.
    Do let us know if it helps.

    Potential Workaround
    This workaround is not a gurantee, it may not work. Please let us know either way on here so we have an idea.
    Create a new material and assign the UI/Default shader to it, the other values can be left as default.
    Assign it to all your Images/Raw Images and Text components that do not already have a material assigned(by default they don't).

    E.G
    upload_2016-1-19_23-57-59.png

    upload_2016-1-19_23-58-33.png

    The flickering should be gone now.
    I have tested this on Windows and Android.
     
  6. MZaeemQ

    MZaeemQ

    Joined:
    Dec 31, 2015
    Posts:
    11
    Well I should've tried this earlier. I set canvas plane distance to about a 100 or more and flickering stops. I now am using screen space overlay and no flickering issue.
     
  7. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I can confirm, with certainty, that this workaround does not work for me. Here's a script so other's can try; it automatically assigns a material in the Materials folder to all graphic ui elements.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using UnityEditor;
    4.  
    5. public class FlickerFix
    6. {
    7.     [MenuItem("Edit/Fix UI Materials")]
    8.     public static void FixElements()
    9.     {
    10.         // load the material.
    11.         Material uiMaterial = AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI Material.mat");
    12.  
    13.         if (uiMaterial == null)
    14.         {
    15.             Debug.LogError("Cannot find UI material");
    16.             return;
    17.         }
    18.  
    19.         Graphic[] graphics = Object.FindObjectsOfType<Graphic>();
    20.         for (var i = 0; i < graphics.Length; i++)
    21.         {
    22.             if (graphics[i].material == Graphic.defaultGraphicMaterial)
    23.             {
    24.                 graphics[i].material = uiMaterial;
    25.             }
    26.         }
    27.     }
    28. }
    29.  
     
  8. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I switched Render Mode to Screen Space - Camera and it didn't make any difference whatsoever. Still flickers.
     
  9. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I don't have any reflection probes in my scene, and it still flickers.
     
  10. AverageProg

    AverageProg

    Joined:
    Jun 25, 2015
    Posts:
    38
    And this is why you don't want to be a render engineer, only the nastiest s**t gets thrown at you.

    This situation fits me wonderfully, at least I don't have to work on that ugly android project till this issue is fixed and our producer stopped complaining since we started blaming unity <.<

    I would suggest you let these poor dudes figure out what the problem is.
     
    phil-Unity and Gizmmoo like this.
  11. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I must've misread your post earlier, how can you set the plane distance in Screen Space - Overlay mode? That property is only in Screen Space - Camera...
     
  12. MZaeemQ

    MZaeemQ

    Joined:
    Dec 31, 2015
    Posts:
    11
    Sorry my bad, i did not mention it clearly. i said now i am using screen space overlay. i was using screen space camera earlier in which when i set plane distance to 100 flickering stops.
     
    Last edited: Jan 20, 2016
  13. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    So, to clarify, the flickering stopped in ScreenSpaceCamera mode? Then why did you switch back to ScreenSpaceOverlay mode?
     
  14. MZaeemQ

    MZaeemQ

    Joined:
    Dec 31, 2015
    Posts:
    11
    because a plane distance of a 100 is too big. objects can appear between the plane and camera(when in motion). and I'm not getting any UI flickering in overlay mode.
     
  15. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    It looks like mine started with the realtime reflections too!
     
    Gizmmoo likes this.
  16. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    We know that its caused when the FPS drops to low (from experiments < 5fps). So reflections could cause that sort of drop and i.e. the flickering.
     
    Gizmmoo likes this.
  17. Gizmmoo

    Gizmmoo

    Joined:
    Feb 4, 2015
    Posts:
    10
    You guys know best. I just wanted to say that I turned the reflections back to realtime (to get the flickering again) and I checked my frames per second and they were between 55-60 FPS when the flickering is going on. Not sure if I was just an exception, just wanted to say in case it helps you guys with debugging
     
  18. FlyAnvil

    FlyAnvil

    Joined:
    Aug 14, 2013
    Posts:
    9
    Please help, how to turn off reflection?
     
  19. maheroku

    maheroku

    Joined:
    Feb 13, 2015
    Posts:
    1
    I have tried everything in here and none of the workarounds fixed it. It also occurs on high FPS but what I noticed is that is happens to UI elements that have a little bit of animation such as flickering or moving or scaling.
     
  20. BruceSteele

    BruceSteele

    Joined:
    Nov 12, 2015
    Posts:
    3
    I don't think this is restricted to just < 5fps, I'm seeing flickering at 25 fps+ on Android - it seems to happen whenever sprites are moved or first appear. Not all sprites on the screen flicker every time - and it's not consistent (which sprites decide to flicker and which one don't will change over time).
     
  21. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    it happens on 60 fps on my machines!
     
  22. robertono

    robertono

    Joined:
    Jun 3, 2014
    Posts:
    23
    Talking about OS X build.
    It does not happens if fps is 60, but if it is 1 - 30, then I have a lot of UI flicker
     
  23. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Looks like I may have just found the fix for the issue. I need to verify it some more with another graphics programmer as it was a piece of code i'm not 100% sure on but if my fix proves to be valid we will get it out asap. I'll keep you posted.

    As a side note i'm sure i found other inconsistencies within the batching process that have been cleaned up in the process so "yay"?
     
    Gizmmoo, shkar-noori, rzubek and 3 others like this.
  24. sovida

    sovida

    Joined:
    Jun 9, 2014
    Posts:
    11
    sound like a good news.
     
  25. AverageProg

    AverageProg

    Joined:
    Jun 25, 2015
    Posts:
    38
    Doesn't speak good about unity, so maybe more like nay?
     
  26. Wtf555

    Wtf555

    Joined:
    Jan 9, 2014
    Posts:
    4
    I also have sprite flickering happen since Unity 5.3.1f1 and still persist in 5.3.1p3

    I'm not using the Unity UI though, just normal 2D sprite.

    Things I found
    - Remove the animation attach to sprites will fix the issue
    - It seems to only happen with animations made since Unity 5.3.1 not happen with animations made with Unity 5.2
    - convert mecanim animation back to legacy animation will fix the issue
     
    Last edited: Jan 22, 2016
  27. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    This will be an entirely different issue. Please file a bug report.
     
  28. Wtf555

    Wtf555

    Joined:
    Jan 9, 2014
    Posts:
    4
    Ok, I thought it somehow related to this UI bug because It looks like batching issue

    and flickering behaviour is very similar
     
    Last edited: Jan 22, 2016
  29. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    So the fix has been confirmed valid on Android and a few other devs. We are going to do our best to get it backported to the next patch release.
     
    rzubek and karl_jones like this.
  30. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hey. The fix will be in patch 5.3.2p1

    Note the p, that is the first patch release not the first 5.3.2 release.

    That's scheduled for mid next week but can sometimes slip to the Friday.
     
    Last edited: Jan 22, 2016
    rzubek likes this.
  31. Metastable

    Metastable

    Joined:
    Apr 10, 2013
    Posts:
    50
    Very good news. Thanks for keeping us informed!
     
  32. BruceSteele

    BruceSteele

    Joined:
    Nov 12, 2015
    Posts:
    3
    Hi Phil / Karl, that's great news!
    Many thanks for keeping us in the loop - it's great to have some idea how things are progressing even if it's "haven't found it yet but try this" or "it's not going to be this week".
    We often have others (managers, clients etc.) asking us what's going on with the project - so it's good to have some information to feed back.
     
    Last edited: Jan 22, 2016
    karl_jones likes this.
  33. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Is there any possibility of getting it earlier? Maybe a beta perhaps? We have a bunch of unhappy customers.
     
  34. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    No sorry the fix has gone into 5.3.2p1 only, its not even made it into 5.4 yet.
     
  35. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    I have to land a bunch of other fixes in 5.4 before i can start another PR to get this fix in. I'm working on it as fast as possible
     
    ZeraKoN, karl_jones and User340 like this.
  36. x70x

    x70x

    Joined:
    Aug 20, 2011
    Posts:
    49
    font_glitch_unity.gif
    font_glitch_unity1.png
    I believe that I am experiencing this same issue. Does this look similar to what others are seeing? I tried applying new materials to all my UI elements, but that did not appear to solve the issue.
     
  37. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Yep, same thing. Should be fixed on Wednesday as mentioned above.
     
    x70x and karl_jones like this.
  38. Gizmmoo

    Gizmmoo

    Joined:
    Feb 4, 2015
    Posts:
    10
    Hey by the way to both you guys, thanks for all your hard work towards getting a solution on this. I know this can be very non congratulatory work, but really, thanks for all the feedback and help!
     
  39. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
    Yeah! Totally. Thank you guys. (When I look at my code after a while its usually a wtf-moment :), so I'm the last one to judge - hihi). I'm totally glad that you are working on the UI to get it working again like in 5.1.
     
  40. FirePlantGames

    FirePlantGames

    Joined:
    Dec 11, 2012
    Posts:
    49
    So, just to clarify, this should be fixed on Wednesday??
     
  41. Metastable

    Metastable

    Joined:
    Apr 10, 2013
    Posts:
    50
    Possibly but it should be released by the end of this week according to @karl.jones
     
    karl_jones likes this.
  42. FirePlantGames

    FirePlantGames

    Joined:
    Dec 11, 2012
    Posts:
    49
    Awesome. That's great news, this bug has made everything awful and un-shippable. Can't wait till you guys get this patch released!
     
  43. rubenmueller

    rubenmueller

    Joined:
    Oct 15, 2015
    Posts:
    6
    I have to assign each Image/RawImage/Text a seperate material, otherwise the UI elements with the same material are flickering together.
     
  44. asimov99

    asimov99

    Joined:
    Mar 13, 2015
    Posts:
    57
    Same problem in Unity 5.3.1.f1 :(



    I have no image without source and i have put a Material UI with shader UI/Default on all my sprites, and the problem is always here...
     
  45. WagDan

    WagDan

    Joined:
    Nov 7, 2014
    Posts:
    37
    Hi, do you think the patch will still be released today? Was due to deliver a project today and this is the only thing remaining.
     
  46. rubenmueller

    rubenmueller

    Joined:
    Oct 15, 2015
    Posts:
    6
    You have to put different new materials for each UI element! If you have 20 UI elements, create 20 new materials and assign each material to only one UI element. This worked for me.
     
  47. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    I'd say wait for the patch to release, creating that many materials not only breaks batching but its a huge headache to undo once the fix has been published.

    As for getting the update out, looks like they hit a build failure (checking messages) that needed to be resolved first (looks like they were just now) So I can't comment on when it will release but they are getting closer.
     
    karl_jones likes this.
  48. asimov99

    asimov99

    Joined:
    Mar 13, 2015
    Posts:
    57
    Sorry, i dont want create x materials for x UI image for patch a bug, too many image...
    i will wait :)
     
  49. Searra

    Searra

    Joined:
    May 28, 2015
    Posts:
    1
    Hi Phil/Karl,

    I'm just looking to clarify. Is it the patch with the fix 5.3.2p1 that is due by the end of this week? Or the initial release 5.3.2 this week and then the patch with fix 5.3.2p1 at a later date?
     
  50. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    5.3.2p1 was due today but has been pushed back and so has 5.3.2f1. I believe they will both be out tomorrow which i can understand may be a little confusing. Just remember to grab the patch version, the other is a trap!
     
    shkar-noori and phil-Unity like this.