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

Fast UI testing Hot swapping #718

Closed
kianzarrin opened this issue Feb 19, 2020 · 13 comments
Closed

Fast UI testing Hot swapping #718

kianzarrin opened this issue Feb 19, 2020 · 13 comments
Assignees
Labels
adjustments required An issue require some adjustments in code code cleanup Refactor code, remove old code, improve maintainability performance Make it faster! technical Tasks that need to be performed in order to improve quality and maintainability

Comments

@kianzarrin
Copy link
Collaborator

kianzarrin commented Feb 19, 2020

Situation

When I want to design a UI feature (or modify an existing one) I like to play with it a lot and see how it looks in game. Every time I build TMPE it takes a long wile. The game also takes its sweet time to hot swap it. This severely slows me down.

Need

I need a fast - doesn't have to be functional - way to check how does my UI code modification look.

I have created small mods that I can test stuff with but I can only go so far with them without access to internal TMPE functions.

This might overlap with the concept of TMPE light ( light from user point of view ) but the objective here is to reduce loading time not to increase run time performance.

Action

most of the reload time is lost to Harmony patching. I don't know how much of build time is due to harmony.

I suggest to have a UI only build of TMPE that does not use Harmony patches. That should reduce hot swap to a fraction of a second.

I don't know how to reduce build time though. I am tempted to use dnSpy to modify TMPE DLL ... lol!

Plan

we are doing a lot of UI stuff recently so this could be very handy to us.

@kianzarrin kianzarrin added feature A new distinct feature triage Awaiting issue categorisation labels Feb 19, 2020
@originalfoo
Copy link
Member

Are you doing complete rebuild each time (including sub modules)? What shortcut are you using to compile?

@krzychu124
Copy link
Member

Game detects plugin(mod) change using file system watcher then plugin (mod) has to be replaced by PluginManager. We can't speed up this process.

Every time I build TMPE it takes a long wile.

For me it's <8-10 sec (full solution rebuild (with cleanup)). Not so bad, I think.

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Feb 19, 2020

@krzychu124 for me takes 10 seconds to build project without clean.
But when CS game is loaded it takes much longer than that.
I have the mod that pauses the simulation on no focus BTW.

EDIT:
I have 16GB ram. I disable all DLC and heavy mods.

After game is loaded it takes 25 sec first time. 10 sec if I build right after.

@kianzarrin
Copy link
Collaborator Author

Its also possible to enable TMPE in asset editor. its much less heavy that way.

My Hide TMPE mod does nothing in the assert editor in release build but hides all crossings in asset editor in debug build. saved me a lot of time :)

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Feb 21, 2020

Its crazy!
It reloads once if it is replaced fast enough!
it reloads once if it is in main menu.
it (and by it I mean TrafficManager.dll) hot reloads 2 times if it is replaced slowly and in game
I managed to find a work around.

Now that It reloads only once its much faster :)

12 sec reload time

@originalfoo
Copy link
Member

I think you included the fix as part of the mass edit PR? #631 (review)

If so it would be better as a separate PR so it's distinct from other tasks and we can get it merged in quick and it's easier to refer to in change notes.

kianzarrin added a commit that referenced this issue Feb 22, 2020
hot reload mini-boost:
boosts #718
prevent double hot reload. Hot reload time is 12 sec.
prevent disabling tool after hot reload.
prevent unintentional disabling of other tools.
@originalfoo originalfoo added adjustments required An issue require some adjustments in code code cleanup Refactor code, remove old code, improve maintainability performance Make it faster! technical Tasks that need to be performed in order to improve quality and maintainability and removed feature A new distinct feature triage Awaiting issue categorisation labels Feb 22, 2020
@originalfoo
Copy link
Member

@kianzarrin This might be interesting approach: #136 (comment)

@kianzarrin
Copy link
Collaborator Author

I tried excluding Custom AI to increase build speed but other files directly or indirectly require CustomPathManager.

I managed to exclude about 10 files without build errors but that did not improved build speed.

I also tried skipping detours but overlay would not work. To my disbelief it would work only if I performed in game hot swap. In any case It did not boost speed as much as I hoped. it reduced reloading time from 12s to 5s which is not bad but is it worth creating a new build config.

Having a new UI only build config might be good as in future we can gradually improve it to make it faster. but I don't think its going to happen as we have bigger fish to fry.

If I could surround all the code that is related to the CustomAI with #if !UIONLYBUILD ... #endif it might improve build/ reload speed a lot. The downside is that future code development would be difficult as we should always test if we don't break UIOnly build.

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Mar 17, 2020

I disabled unsubbed from all other mods and the Hot Reload is SOOO FAAAST!

@originalfoo
Copy link
Member

The speed increase will partly be due to not having to recreate all their settings screens.

Could you make a small mod that controls when IUserMod.OnSettingsUI() gets called?

So far I've identified these situations in which settings UI is updated:

  • Mod subscribed / unsubscribed
    • The newly subscribed mod would still need its OnSettingsUI() called.
  • Mod enabled / disabled
    • The enabled mod would still need its OnSettingsUI() called.
  • Mod hotloaded
    • The hotloaded mod would still need its OnSettingsUI() called.

Could save a ton of time and would make any activities in Content Manager > Mods much faster.

@originalfoo
Copy link
Member

originalfoo commented Mar 17, 2020

Better still, create settings screen on-demand. :)

EDIT: Acutally, don't do that as lots of mods use OnSettingsUI() to do other stuff such as initialise translations or detect game state changes.

@kianzarrin
Copy link
Collaborator Author

Could you make a small mod that controls when IUserMod.OnSettingsUI() gets called?

I have plans for a hot reload mod but I I have postponed that to later (maybe a month later) because I like to work on some of the works I have started. I Don't mind if anyone else does it.

@kianzarrin kianzarrin self-assigned this Jun 16, 2022
@kianzarrin
Copy link
Collaborator Author

I have already addressed this in Load Order mod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adjustments required An issue require some adjustments in code code cleanup Refactor code, remove old code, improve maintainability performance Make it faster! technical Tasks that need to be performed in order to improve quality and maintainability
Projects
None yet
Development

No branches or pull requests

3 participants