Skip to content

[Issue] Inspector lags severally  #133

Closed

Description

@rvv27

I use NaughtyAttributes for Small Repos and for Complex projects, I use Odin. I avoid Odin since it is too much for small projects.

Now I am using NaughtyAttributes for a class with around 25-30 variables serialized in Inspector. There are few sliders and few headers. I am using 2019.3.3. Now since I upgraded from 2019.2 to 2019.3 the editor lags severally if I select this object in scene which has this class with many exposed variables. To confirm the issue I removed NaughtyAttributes using in the class and commented the Attributes and speed is increased. I switched to Odin to avoid this lag and in Odin there is no lag and has natural speed.

I checked profiler when using NaughtyAttributes and is shows EditorLoop as 80% which is huge. To playtest I have to use Maximize On Play to avoid editor lag.

I am pretty sure that NaughtyAttributes is doing some stuff which is making Unity editor so laggy. I think I have never encountered such issues when using NA earlier and I think it has something to do with newer NA v.2.0+ paired with 2019.3 and a variable heavy class.

I hope you fix it soon.
Thank you

Activity

  1. dbrizov commented on Mar 4, 2020

    @dbrizov
    Owner

    Thanks, I'll look into it.

  2. snorrsi commented on Mar 18, 2020

    @snorrsi

    @dbrizov have you gotten to look into that issue ?

  3. dbrizov commented on Mar 19, 2020

    @dbrizov
    Owner

    @dbrizov have you gotten to look into that issue ?

    I haven't

  4. lmichaudel commented on Apr 26, 2020

    @lmichaudel

    Hi, same problem here, but it only happen with BoxGroups

  5. marwie commented on Jun 3, 2020

    @marwie

    I have a similar case in a project where everything is becoming extremely unresponsive. Looked into the profiler and noticed a couple of naughty attribute calls seemly causing a big junk of it... (been on 2019.3.13 and updated to 19.3.15 today)

  6. marwie commented on Jun 3, 2020

    @marwie

    Here's a screenshot using deep profiling with stack trace. I only clicked on an element in the scene hierarchy here.

    image

  7. snorrsi commented on Jun 3, 2020

    @snorrsi

    @marwie I was looking at this issue my self today and trying to find simple workaround in the editor. It seems there are many calls to fx ReflectionUtility.GetAttribute which in some cases (at least for ShowIfAttribute) are not needed and can be kept and then reused in the call. I also looked into creating delegates for the calls since they do not change between conditionName setting on the attribute. This sped things up. Some of the garbage collection seems to come from Unity propertdrawing itself, I have yet to look deeper into that

  8. NeatWolf commented on Jul 3, 2020

    @NeatWolf

    Hey,

    just wanted to say that I'm also testing NaughtyAttributes (v2 branch) on Unity 2019.4.2f1 (LTS) and experiencing severe slowdowns when using ShowIf+BoxAttribute

    BTW: I'd gladly pay for having full support on the Unity Asset Store - I wanted to use ODIN while working in my company, but apparently it costs 250 bucks - per seat - and there's only me actually accessing it!

    Any chance of using some caching system to speed up the rendering?

  9. dbrizov commented on Jul 3, 2020

    @dbrizov
    Owner

    Hey,

    just wanted to say that I'm also testing NaughtyAttributes (v2 branch) on Unity 2019.4.2f1 (LTS) and experiencing severe slowdowns when using ShowIf+BoxAttribute

    BTW: I'd gladly pay for having full support on the Unity Asset Store - I wanted to use ODIN while working in my company, but apparently it costs 250 bucks - per seat - and there's only me actually accessing it!

    Any chance of using some caching system to speed up the rendering?

    Hey mate, I am doing my best to update as frequently as I can. I'm pretty busy the last couple of months, and I am trying to chill in my free time. I am trying to address and fix the issues that people report every month or two. I have it planned to look at the slow down for the next release. Fortunately, the issue is related to the conditional attributes mostly (ShowIf, EnableIf), so it might not be that hard to fix. I have to cache things, because the reflection is heavy there.

  10. dbrizov commented on Aug 12, 2020

    @dbrizov
    Owner

    Also check ReadOnly attribute

  11. offchan42 commented on Sep 22, 2020

    @offchan42

    Confirm still happening. I have this issue also. It makes the game lag if I select the component with naughty attributes in the inspector. It seems any attribute causes this issue. For example if I enable InputAxis attribute then it will cause all fields to be laggy. Try typing random number in an int field and you will see the lag, the typed characters will slowly show up.

  12. snorrsi commented on Jan 12, 2021

    @snorrsi

    @dbrizov any update?

  13. dbrizov commented on Jan 12, 2021

    @dbrizov
    Owner

    @snorrsi No, I haven't done anything about this, it's not a priority at the moment. However, I tested some months ago with the current Unity version and with 2018.3. With 2018.3 there are no performance issues. The new UI system is heavier than the previous one, and the Unity docs state that the new UI Elements system is more optimized.

  14. nikodemgrz commented on Sep 6, 2021

    @nikodemgrz

    @snorrsi
    @dbrizov
    @marwie
    @NeatWolf
    @off99555

    Hey folks,
    I encountered similar issues and found a performance improvement!
    If you have a unity object with lots and lots of fields which can happen for settings files, the perf drops pretty fast.

    The main issue is getting attributes (expensive Reflection) per property on every on inspector gui call, aswell as fetching every serialized property in this call.

    Ill create a fork and test around a bit but the idea is to fetch all the required stuff after compilation (OnEnable) and not on every call and refactor the methods, that fetched the attributes like "IsVisible" and "IsEnabled" etc.
    image

    Its still not perfect and not every case is covered (since I was focusing on mine) and testing + refactoring needs to be done but thats a huge boost on my machine!

    So lets see how it goes...

  15. nikodemgrz commented on Sep 6, 2021

    @nikodemgrz

    Here is the result of my current attempts at:
    https://github.com/niggo1243/NaughtyAttributes/tree/issue/%23133-inspector-lag

    Old Issue:

    OldLagIssue_Cut

    Fix:

    FixLagIssue_Cut

    The downside to it is, that it caches all scripts in unity after compiling. I think a better attempt is to cache them on the current opened inspector and cleanup after leave...

  16. added 7 commits that reference this issue on Sep 6, 2021
  17. nikodemgrz commented on Sep 10, 2021

    @nikodemgrz

    Update:
    FixLagIssue_v2

    vs Initial issue:
    OldLagIssue

  18. added a commit that references this issue on Sep 10, 2021
  19. dbrizov commented on Nov 8, 2021

    @dbrizov
    Owner

    There is a pull request that caches a lot of things to minimize runtime reflection.
    #264

  20. snorrsi commented on Dec 3, 2021

    @snorrsi

    @dbrizov why is this closed if the pull hasn't been merged? .. Are you planning on merging that pull request at some time ?

  21. imniko commented on Feb 7, 2023

    @imniko

    bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions