Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] Inspector lags severally #133

Closed
rvv27 opened this issue Mar 3, 2020 · 19 comments · May be fixed by #266
Closed

[Issue] Inspector lags severally #133

rvv27 opened this issue Mar 3, 2020 · 19 comments · May be fixed by #266

Comments

@rvv27
Copy link

rvv27 commented Mar 3, 2020

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

@dbrizov
Copy link
Owner

dbrizov commented Mar 4, 2020

Thanks, I'll look into it.

@snorrsi
Copy link

snorrsi commented Mar 18, 2020

@dbrizov have you gotten to look into that issue ?

@dbrizov
Copy link
Owner

dbrizov commented Mar 19, 2020

@dbrizov have you gotten to look into that issue ?

I haven't

@Carbone13
Copy link

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

@marwie
Copy link

marwie commented Jun 3, 2020

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)

@marwie
Copy link

marwie commented Jun 3, 2020

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

image

@snorrsi
Copy link

snorrsi commented Jun 3, 2020

@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

@NeatWolf
Copy link

NeatWolf commented Jul 3, 2020

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?

@dbrizov
Copy link
Owner

dbrizov commented Jul 3, 2020

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.

@dbrizov
Copy link
Owner

dbrizov commented Aug 12, 2020

Also check ReadOnly attribute

@offchan42
Copy link

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.

@snorrsi
Copy link

snorrsi commented Jan 12, 2021

@dbrizov any update?

@dbrizov
Copy link
Owner

dbrizov commented Jan 12, 2021

@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.

@niggo1243
Copy link

niggo1243 commented Sep 6, 2021

@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...

@niggo1243
Copy link

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...

niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 6, 2021
niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 6, 2021
niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 6, 2021
niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 6, 2021
…y improve the gathering of the required properties and attributes
niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 10, 2021
niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 10, 2021
niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 10, 2021
@niggo1243
Copy link

Update:
FixLagIssue_v2

vs Initial issue:
OldLagIssue

niggo1243 added a commit to niggo1243/NaughtyAttributes that referenced this issue Sep 10, 2021
@dbrizov
Copy link
Owner

dbrizov commented Nov 8, 2021

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

@snorrsi
Copy link

snorrsi commented Dec 3, 2021

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

@imniko
Copy link

imniko commented Feb 7, 2023

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants