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

Material caching is not working properly #163

Closed
kwasak opened this issue Apr 10, 2019 · 8 comments
Closed

Material caching is not working properly #163

kwasak opened this issue Apr 10, 2019 · 8 comments
Assignees
Labels
Milestone

Comments

@kwasak
Copy link

kwasak commented Apr 10, 2019

UIEffectBase.OnValidate() is increasing the amount of time it takes to enter playmode. In my project, UIEffectBase.OnValidate is adding an extra 2s.

Screen Shot 2019-04-09 at 10 01 03 PM

@mob-sakai
Copy link
Owner

Hi @kwasak
Thank you for reporting.

I would like to know more information on this issue.
Unity version, platform, more profiler infomation...

@mob-sakai mob-sakai self-assigned this Apr 10, 2019
@kwasak
Copy link
Author

kwasak commented Apr 10, 2019 via email

@mob-sakai
Copy link
Owner

Thank you, @kwasak !
Can you submit a reproducible project for this issue?
It helps me to resolve the issue.

@kwasak
Copy link
Author

kwasak commented May 24, 2019

Sorry, this took so long. I'm on a tight schedule with a project I'm working on.
It appears the issue stems from a call to MaterialResolver.GetOrGenerateMaterialVariant()from UIShiny.

MaterialResolver.GetOrGenerateMaterialVariant()calls GetMaterial() which makes an expensive call to AssetDatabase.FindAsset(). This call occurs for every UIShiny object in the scene.

As you can see from the attached image, in my case, this adds 3.7s to Assembly Reload Time.
AsGetOrGenerateMaterialVariant() is called from OnValidate().

From what I see, the solution would be cache the material received from GetMaterial().

Screen Shot 2019-05-24 at 1 20 50 PM

UISmartShiny is a class I inherited from UIShiny, for the purpose of this bug their identical, this occurs in both my version and the original UIShiny.

I hope this helps, I apologize again for the late reply.

@mob-sakai
Copy link
Owner

@kwasak
Oh, sorry.
I missed this issue.
I will fix it soon.

@mob-sakai
Copy link
Owner

mob-sakai commented May 25, 2019

WIP
image

GC: 41.4MB -> 232.5KB

Try it.
MaterialResolver.cs.zip

@kwasak
Copy link
Author

kwasak commented May 25, 2019 via email

@mob-sakai
Copy link
Owner

The cause of the problem is that the material cache was not working properly.
If there is no problem, it will be released.
Try it on your project. :)

@mob-sakai mob-sakai added bug and removed question labels May 27, 2019
@mob-sakai mob-sakai changed the title UIEffectBase.OnValidate() Increases Enter PlayMode time Material caching is not working properly May 27, 2019
@mob-sakai mob-sakai added this to the v3.2.0 milestone Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants