MV Performance issue with event spawning

I feel like we're missing something very obvious, because I feel like we've considered every viable option at this point. All I can suggest now is to remove everything, then re-add them back in one at a time, testing everything individually.
I feel like we're missing something very obvious, because I feel like we've considered every viable option at this point. All I can suggest now is to remove everything, then re-add them back in one at a time, testing everything individually.
Again... I've done that. I removed ALL scripts from the arrows(except the self despawn), and ALL scripts from the tower(except the spawning) and the result was that picture in the first post.
Then we have to consider the possibility that the arrows and tower aren't the problem. Are there other scripts or events in that map?
Then we have to consider the possibility that the arrows and tower aren't the problem. Are there other scripts or events in that map?
yes, but without spawning a few thousand arrows, the game won't lag(it takes about...2ms to draw each frame?).

I'm pretty sure its a core MV issue. And although I know MV wasn't designed to handle thousands of events, since it doesnt come with a spawn event function by default, I really need to find where in the core files the issues are coming from
Hi there!

After reading the conversation, I have two observations to make:

1 - You activated the setInterval on event 28, then switch to page 2. Do you know that the setInterval function "needs" to be cleared out to stop working, right?
If you don't need whatever the setInterval is doing, you can call clearInterval(Interval_Id)

2 - Another thing is, a long time ago, when I was making an MV game, I had problems with both Galv and Yanfly event spawners plugins about performance and an error when deployed games to a single .exe file. So I switched to Triacontane one, and both problems were solved.
So maybe it's worth a try?
Hi there!

After reading the conversation, I have two observations to make:

1 - You activated the setInterval on event 28, then switch to page 2. Do you know that the setInterval function "needs" to be cleared out to stop working, right?
If you don't need whatever the setInterval is doing, you can call clearInterval(Interval_Id)

2 - Another thing is, a long time ago, when I was making an MV game, I had problems with both Galv and Yanfly event spawners plugins about performance and an error when deployed games to a single .exe file. So I switched to Triacontane one, and both problems were solved.
So maybe it's worth a try?
1- I know about that, but I built those events there as mere ways to make testing easier. I'll assign them to a variable then clear interval once needed.

2-I THINK I've solved the issue. I found the part of the core scripts which had a problem: Just like I suspected, the Tilemap children were not cleared when the event a sprite was assigned to was erased, resulting in it trying to update sprites that weren't in use. I've made the following change and now theres rarely a spike in FPS

Code:
Tilemap.prototype._sortChildren = function() {
    var currentchildren
    for(var i=this.children.length-1;i--;){
        currentchildren=this.children[i]._character
        if(currentchildren && currentchildren._eventId && currentchildren._erased==true) this.children.splice(i,1)
    }
    this.children.sort(this._compareChildOrder.bind(this));
};

Original thread: https://forums.rpgmakerweb.com/threads/performance-issue-with-event-spawning.141541/