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

Bug Small bug in ScrollRect.cs - please fix :)

Discussion in 'Scripting' started by realragnvaldr, Apr 24, 2022.

  1. realragnvaldr

    realragnvaldr

    Joined:
    Jul 21, 2019
    Posts:
    41
    @Unity staff:

    There's a small bug in ScrollRect.cs. The line
    Code (CSharp):
    1. float deltaTime = Time.unscaledDeltaTime;
    sometimes assigns 0 to the deltaTime variable (this happens occasionally on Android builds of my app).

    That's problematic, because it screw up the calculation of the scroll velocity (division-by-zero) which - in turn - causes a bad value (NaN) to be assigned to
    m_Content.anchoredPosition
    which - in turn - makes the entire scrollRect 'invisible'. Hence, the user experience is that the list you're scrolling suddenly disappears when the bug occurs, and the only way to get it back is to restart the app (no errors or crashes will occur).

    I solved the problem by simply replacing
    Code (CSharp):
    1. float deltaTime = Time.unscaledDeltaTime;
    at the beginning of LateUpdate() with
    Code (CSharp):
    1. float deltaTime = Mathf.Max(Time.unscaledDeltaTime, 0.15f);
    After this change, I haven't experienced the problem anymore.

    See this thread and this thread for more discussion on this bug.

    I didn't have this bug with Unity LTS verions up-to-and-including 2020.3.13f1. Any later version that I tried has the bug.
     
    Last edited: Apr 24, 2022
    Bunny83 likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    This bug report will never be acted upon in the above format.

    The correct way to report a bug is to:

    - create a small project with just enough to demo the bug

    - precisely enumerate the steps to reproduce (eg, think like you're explaining it to your dog, the way I am in my avatar photo)

    - file the bug directly from Unity (Help -> Report A Bug)
     
    Bunny83 likes this.
  3. realragnvaldr

    realragnvaldr

    Joined:
    Jul 21, 2019
    Posts:
    41
    Thanks for the info. Ugh, i already spent many hours tracking down and then solving this bug in their script. I saw the 'official' bug reporting option, but since it's such a simple one to both understand (yes, deltaTime can be 0 and, yes, division-by-zero is bad and should be avoided) and solve (avoid deltaTime to be 0), i hope they can deal with it without me having to go through all that. I might file a proper report if this is not being acted upon...
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Just understand that it WON'T be dealt with.

    The bug team starts with their ticketing system each morning.

    They do not wander around the forums hoping to find coherent reproducible bugs.

    Their first step is always going to be to evaluate the potential severity of a bug and arrange it in order of dealing with, which pushes it forward or back in their task / ticketing system.

    This is also the point where they decide "Hey, this bug should go to the UI team, not the physics team, not the rendering team, not the engine team, etc."

    That's how software development works.

    Trust me. I'm a software developer.
     
    Bunny83 likes this.