MV Advanced javascript question concerning YEP_BattleStatusWindow

Hello there,

I have a quite advanced js question:

I'm currently trying to fix the big slowdown that happens when I am navigating the skills/items windows in battle and there are a lot of options to choose from (at least enough to make the 8 spaces available not enough to display everything, see the linked video to see the slowdown in action).

I think I have found the cause of it: in YEP_BattleStatusWindow line 251 there is code added when an action is cleared or its skill/item/itemobject is set.

JavaScript:
//=============================================================================
// Game_Battler
//=============================================================================

Yanfly.BSW.Game_Action_clear = Game_Action.prototype.clear;
Game_Action.prototype.clear = function() {
    Yanfly.BSW.Game_Action_clear.call(this);
    this.subject().refresh();
};

Yanfly.BSW.Game_Action_setSkill = Game_Action.prototype.setSkill;
Game_Action.prototype.setSkill = function(skillId) {
    Yanfly.BSW.Game_Action_setSkill.call(this, skillId);
    this.subject().refresh();
};

Yanfly.BSW.Game_Action_setItem = Game_Action.prototype.setItem;
Game_Action.prototype.setItem = function(itemId) {
    Yanfly.BSW.Game_Action_setItem.call(this, itemId);
    this.subject().refresh();
};

Yanfly.BSW.Game_Action_setItemObject = Game_Action.prototype.setItemObject;
Game_Action.prototype.setItemObject = function(object) {
    Yanfly.BSW.Game_Action_setItemObject.call(this, object);
    this.subject().refresh();
};


This code causes the subject to refresh itself, which means the game has to recompute a lot of stuff needed for other plugins, in particular the target selection for YEP_X_SelectionControl. All of that adds up to cause a noticeable slowdown.

Making a refresh just for that seems quite excessive, I was thinking about replacing those 4 refresh by the following code:
JavaScript:
if (this.subject().isActor()) {
    this.subject().battleStatusWindowRefresh();
}

This modification indeed gets rid of the slowdown, but I am a bit worrying concerning potential unwanted side-effects.
Do you see any reason why a refresh is absolutely necessary rather than a simpler battleStatusWindowRefresh?
I think I have found the cause of it: in YEP_BattleStatusWindow line 251 there is code added when an action is cleared or its skill/item/itemobject is set.
I'm confused by you saying the modification solves your problem, because none of that should be happening during what you show in your clip.

The Game_Action is the skill actually resolving during the battler's turn. It doesn't exist yet when you're scrolling through the list - the window you show with the items listed there should have nothing to do with the data type you're looking at.
I'm currently trying to fix the big slowdown that happens when I am navigating the skills/items windows in battle and there are a lot of options to choose from (at least enough to make the 8 spaces available not enough to display everything, see the linked video to see the slowdown in action).
do you by chance have yanfly's selection control installed as well?
EDIT: I should have read a bit more more 🤣

Aloe Guvner made a patch for it for that reason as well. it might be worth checking out for you
Wow. I didn't realize the selection control created an action for every item on the screen to determine whether it's enabled.
do you by chance have yanfly's selection control installed as well?
EDIT: I should have read a bit more more 🤣

Aloe Guvner made a patch for it for that reason as well. it might be worth checking out for you
Seems like someone found the exact same problem and has a more elegant solution.
Funny enough, this patch actually doesn't get rid of all the lag, as Game_Action.clear (who is called when initializing the action) also trigger a refresh. I will edit that one as well.

Thanks for the help guys.

Original thread: https://forums.rpgmakerweb.com/threads/advanced-javascript-question-concerning-yep_battlestatuswindow.170232/