Search Unity

Bug Android sudden Rendering issue after change of Unity Version

Discussion in 'Editor & General Support' started by FunCrafter_, Jan 24, 2023.

  1. FunCrafter_

    FunCrafter_

    Joined:
    Dec 18, 2016
    Posts:
    4
    Hello everyone,
    I have a very specific problem that I tried to ignore for a while because I could not find any Information on this.
    I am developing an App for Android and I got forced to Upgrade my Unity Version for this Project from 2019 something to 2020.3.40f1 because thats the earliest version that supported a specific package that was needed for a different bugfix.

    I sadly cant reproduce this issue myself because all phones I have access to dont face this issue at all.
    But I get daily people onto the community discord that show me the same problem.
    Screenshot_-.png

    I use a Camera with Background type Solid Color to have the Background color fixed.
    It seems like every moving object gets cloned every frame but somehow UI is not affected by this. The 4 Buttons on the bottom are being moved by DoTween everytime the Block in the middle is clicked.

    In some instances I have also seen that UI sorting order gets messed up because of this and somehow the Camera Background Color is just black. Screenshot_2-.png

    As I said I cant reproduce this problem on any phone I have and getting people from the community to show me their logs is also not that easy as they are all very young. But I know that its not any specific android Version or device it happens seemingly randomly.

    I really appreciate any help on this because I have been struggeling with this for a while now thanks!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    If it is a layering problem, keep this in mind:

    Three (3) primary ways that Unity draws / stacks / sorts / layers / overlays stuff:

    https://forum.unity.com/threads/orthographic-camera-rendering-order.1114078/#post-7167037

    In short,

    1. The default 3D Renderers draw stuff according to Z depth - distance from camera.

    2. SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties

    3. UI Canvas Renderers draw in linear transform sequence, like a stack of papers

    If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:

    - identify what you are using
    - search online for the combination of things you are doing and how to to achieve what you want.

    There may be more than one solution to try.

    Additional reading in the official docs:

    https://docs.unity3d.com/Manual/2DSorting.html

    And SortingGroups can also be extremely helpful in certain circumstances:

    https://docs.unity3d.com/Manual/class-SortingGroup.html
     
  3. FunCrafter_

    FunCrafter_

    Joined:
    Dec 18, 2016
    Posts:
    4
    Thank you for your reply I am just afraid that it has nothing to do with the layering itself it seems.
    If this was a sorting issue of the SpriteRenderers this issue should be reproduceable on any device or am I wrong? This only happens on random phones with random android versions.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    If you have two sprites on the same layer it is a 50/50 chance which will be in front.

    That chance may work perfectly for years and years and years until one day it doesn't for some reason.
     
  5. FunCrafter_

    FunCrafter_

    Joined:
    Dec 18, 2016
    Posts:
    4
    It doesnt matter if my sprites suddenly are drawn in a different order I have tons of sprites on screen where the order they are drawn doesnt matter.

    If you look at my screenshots you will see that my sprites get drawn properly but persist to the next frame and then they get drawn again. Suddenly I have 2 of the same gameobjects sprites drawn on the screen but of cause the old frame just didnt get cleared. I can show you a screenshot of how the game is supposed to look:
    unnamed.png

    Everything worked fine until I swapped to the newer Unity Version. The coins you see in the picture fall down and in the screenshot I showed first you can see those coins falling aswell but every frame they get redrawn and they also get redrawn on every previous position they were in for every frame before that.