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

Throttle calls to RefreshAllTexturesCo() #26

Merged
merged 1 commit into from Feb 20, 2024

Conversation

takahiro0327
Copy link
Contributor

@takahiro0327 takahiro0327 commented Feb 19, 2024

RefreshAllTexturesCo() was sometimes called multiple times within a few frames for the same character during scene loading.
Added a delay frame and modified it so that it is called only once if another call comes in during that time.
Please merge if you don't mind.

When tested on a scene with 10 characters with and 10 without overlays, loading time was reduced by 4 seconds.

before average:43.18[s]

Scene loading completed: 43.9[s]
Scene loading completed: 43.3[s]
Scene loading completed: 42.8[s]
Scene loading completed: 42.4[s]
Scene loading completed: 43.5[s]

after average:38.86[s] -4.32[s]

Scene loading completed: 40.8[s]
Scene loading completed: 38.4[s]
Scene loading completed: 38.4[s]
Scene loading completed: 38.1[s]
Scene loading completed: 38.6[s]

The overlay was not directly heavy, but SetCoordinateInfo() was inducing a large amount of resource reloading internally, which was heavy.
For example, reloading asset bundles as shown below.

  at UnityEngine.AssetBundle.DMD<UnityEngine.AssetBundle::LoadAsset> (UnityEngine.AssetBundle , System.String , System.Type ) [0x00000] in <6ecf63bad40043cabba2a3f491a0e3df>:0 
  at AssetBundleManager.DMD<AssetBundleManager::LoadAsset> (System.String , System.String , System.Type , System.String ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at CommonLib.LoadAsset[T] (System.String assetBundleName, System.String assetName, System.Boolean clone, System.String manifestName, System.Boolean check) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.DMD<ChaControl::LoadCharaFbxDataNoAsync> (ChaControl , System.Action`1[T] , System.Action`1[T] , System.Boolean , System.Int32 , System.Int32 , System.String , System.Boolean , System.Byte , UnityEngine.Transform , System.Int32 , System.Boolean ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.LoadCharaFbxData (System.Action`1[T] actListInfo, System.Boolean _hiPoly, System.Int32 category, System.Int32 id, System.String createName, System.Boolean copyDynamicBone, System.Byte copyWeights, UnityEngine.Transform trfParent, System.Int32 defaultId, System.Boolean worldPositionStays) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.DMD<ChaControl::ChangeClothesShoesNoAsync> (ChaControl , System.Int32 , System.Int32 , System.Boolean ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.ChangeClothesShoes (System.Int32 type, System.Int32 id, System.Boolean forceChange) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.DMD<ChaControl::ChangeClothesNoAsync> (ChaControl , System.Int32 , System.Int32 , System.Int32 , System.Int32 , System.Int32 , System.Boolean , System.Boolean ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.ChangeClothes (System.Boolean forceChange, System.Boolean update) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.DMD<ChaControl::ReloadNoAsync> (ChaControl , System.Boolean , System.Boolean , System.Boolean , System.Boolean ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at ChaControl.DMD<ChaControl::Reload> (ChaControl , System.Boolean , System.Boolean , System.Boolean , System.Boolean ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at Studio.OCIChar.DMD<Studio.OCIChar::SetCoordinateInfo> (Studio.OCIChar , ChaFileDefine+CoordinateType , System.Boolean ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at Studio.OCICharMale.DMD<Studio.OCICharMale::SetCoordinateInfo> (Studio.OCICharMale , ChaFileDefine+CoordinateType , System.Boolean ) [0x00000] in <8b09ac0ba803494aafbed35d2609270f>:0 
  at KoiClothesOverlayX.KoiClothesOverlayController.RefreshAllTextures (System.Boolean onlyMasks) [0x00000] in <f0838d021e6c49bca8136074b7490f8e>:0 
  at KoiClothesOverlayX.KoiClothesOverlayController.RefreshAllTextures () [0x00000] in <f0838d021e6c49bca8136074b7490f8e>:0 
  at KoiClothesOverlayX.KoiClothesOverlayController+<RefreshAllTexturesCo>d__30.MoveNext () [0x00000] in <f0838d021e6c49bca8136074b7490f8e>:0 

Copy link
Owner

@ManlyMarco ManlyMarco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Is this not an issue with skin overlays?

@ManlyMarco ManlyMarco changed the title Summarize the call to RefreshAllTexturesCo() Throttle calls to RefreshAllTexturesCo() Feb 20, 2024
@ManlyMarco
Copy link
Owner

Appears to not be an issue with skin overlays. Thanks for the PR!

@ManlyMarco ManlyMarco merged commit a9675e9 into ManlyMarco:master Feb 20, 2024
@takahiro0327
Copy link
Contributor Author

Thanks for merge.

The issue is the frequency of calls to the system functions that the overlay is calling.

@takahiro0327 takahiro0327 deleted the delay_refresh branch February 21, 2024 02:23
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 this pull request may close these issues.

None yet

2 participants