Description
Hey there, I've upgraded to [email protected]. Really love the new changes! Only one thing I'm having an issue with. I have a pretty big site that registers quite a few states in the config phase. I've noticed that with the new router my state registration is really really slow. It's actually taking 3.5s on my computer just to register states. It's showing nothing while this happens since it can't even route until the states are registered.
You can see the code for my states/routes here: https://github.com/gamejolt/gamejolt/tree/master/src/app/views They're in the -state.js/ts files. Nothing too fancy, I think. Just URL-based states.
I profiled the code in Chrome to get a CPU profile of the start of the page. I noticed there were two methods that were taking most of the time. I was able to get it down to ~50ms from 3.5s by just commenting them out. You can see the two changes here: https://github.com/gamejolt/gamejolt/blob/cb8b65838f4f544f042c9c3df8385f5f29c8845f/src/lib/ui-router.js Just search for @MODIFY
.
I'm not very comfortable modifying the code, so I'm not totally sure what I'm changing here. The change here: https://github.com/gamejolt/gamejolt/blob/cb8b65838f4f544f042c9c3df8385f5f29c8845f/src/lib/ui-router.js#L4729 seems to be taking the majority of the time. I logged out the matches and it was always undefined
so I kept that commented out. Sadly the change at https://github.com/gamejolt/gamejolt/blob/cb8b65838f4f544f042c9c3df8385f5f29c8845f/src/lib/ui-router.js#L3737 broke my states so I had to revert it. The second change was still taking about 1-1.5s of the total time of the slow registration. It seems to be sorting the states so it can match on them properly? Is there a way to do this after the main states are registered for the app in the config phase instead of doing it every time a state is registered?
I'll be working on trying to figure out how to hack the perf for the second change I made, so the site may be changed once you get to this, but you can try to grab a profile here: https://gamejolt.com
Willing to help out in any way I can since it really affects the performance of the initial load of the site. Thanks!
Edit: To add a little more info, there is currently 120 states registered on start up.