Weird FPS spikes...

Actually I have no idea which forum section would be good, so I think I post it in general support.
Okay, here is the thing... Occasionally while play-test and in deployed version my game recently has "spiked" FPS, what does that mean? It means while the player walks on map frame rate drops for 1~2 seconds from solid 60FPS to 30~40fps.

At first I thought it's because of parallel common events, but I reviewed them strictly and I found nothing which could cause that problem, because those parallel events are just HP/MP regeneration script calls and one pseudo-timer how long player's lantern will light the way...

Then the next step I took was to test game on different versions of nwjs and spiking FPS occured in all versions below 0.49.0, but in the latest releases everything was fine with FPS, but there were another issues you couldn't help me... So I've returned to version 0.40.0, because this one works the best in my case. I've also updated PIXI from default version to 4.8.9, because using higher than 5.x.x causes a game to crash with error "WebAudio.initialize is not a function".

Problem remains and I've run out of ideas what could cause a problem...

I'm giving my full PC specification I'm running issue:

CPU: AMD FX 8320 8-Core 3.5GHz
RAM: 8GB
OS: Windows 7 Home Edition 64bit
GPU: AMD Radeon R7 370 4GB VRAM
DirectX: 11
Storage: 120GB SSD Sillicon Power + Classic Toshiba 1TB HD

RPG Maker MV 1.6.2


And below is list of plugins in use, order list here is the same like in my Plugin Manager.

PS, if you need to make a list of your plugins without taking screenshots, you can use in console following scripcall:
JavaScript:
PluginManager._scripts.forEach(function(p){console.log(p);})

Spoiler
Code:
TerraxLighting
- TSR_SideStairs
- YEP_CoreEngine
- YEP_LoadCustomFonts
- YEP_MessageCore
- YEP_X_ExtMesPack1
- YEP_X_ExtMesPack2
- YEP_X_MessageSpeedOpt
- YEP_SaveCore
- YEP_BattleEngineCore
- YEP_X_ActSeqPack1
- YEP_X_ActSeqPack2
- YEP_X_ActSeqPack3
- YEP_X_AnimatedSVEnemies
- YEP_X_BattleSysSTB
- YEP_X_CounterControl
- YEP_X_VisualHpGauge
- YEP_BattleSelectCursor
- YEP_BuffsStatesCore
- YEP_X_VisualStateFX
- YEP_DamageCore
- YEP_ExtraEnemyDrops
- YEP_ExtraEnemyDrops_X_Quantities
- YEP_HitAccuracy
- YEP_TargetCore
- YEP_X_SelectionControl
- YEP_WeatherInBattle
- YEP_ItemCore
- YEP_X_ItemCategories
- YEP_ShopMenuCore
- YEP_X_MoreCurrencies
- YEP_SkillCore
- YEP_X_SkillCooldowns
- YEP_X_SkillCostItems
- YEP_EquipCore
- YEP_X_ChangeBattleEquip
- YEP_WeaponAnimation
- YEP_WeaponUnleash
- YEP_AutoPassiveStates
- YEP_X_PassiveAuras
- YEP_EnemyLevels
- YEP_X_EnemyBaseParam
- YEP_PartySystem
- YEP_MoveRouteCore
- YEP_OptionsCore
- YEP_AnimateTilesOption
- YEP_BattleAniSpeedOpt
- YEP_FpsSynchOption
- YEP_EventMiniLabel
- YEP_EventProxActivate
- YEP_BaseTroopEvents
- YEP_ButtonCommonEvents
- YEP_RegionRestrictions
- YEP_SaveEventLocations
- YEP_ScriptCallPluginCmd
- YEP_SlipperyTiles
- SOL_X_BattlersAlignment
- SOL_X_BattleShowFaces
- SOL_X_CustomTPAmount
- SOL_X_DateTime
- SOL_X_ChapterSelect
- SOL_X_CustomExpTable
- SOL_X_ColorItems
- SOL_X_DisableFunctionKeys
- SOL_X_EvalJS
- SOL_X_AddLoadCommand
- SOL_X_FloatPatch
- SOL_X_MapNameUpgrade
- SOL_X_MessageBg
- SOL_X_ReadFromTextFile
- SOL_X_RecoverAllFix
- SOL_X_GameRiddles
- SOL_X_WindowChoiceFix
- SOL_X_VictoryMessage
- SOL_X_SceneBiography
- SOL_X_ExitToWindowsMenuCommand
- SOL_X_GameHints
- SOL_X_SaveOnClose
- SOL_X_WhisperbladeNpcProto
- SOL_X_WhisperbladeNpcProcess
- SOL_X_FrameMotionUpgrade
- SOL_X_ManaDrainSkill
- SOL_X_PreventAltF4
- ShakeScreen
- ShakeScreen_Patch
- ARP_CommandIcons
- RS_MessageAlign
- HIME_ActorBattleCommands
- HIME_BattleCommandChangeEquip
- HIME_DisabledChoiceConditions
- HIME_LevelUpEvent
- HIME_CommonEventQueue
- SOL_X_SkipPartyMenu
- SRD_SuperToolsEngine
- SRD_HUDMaker
- SRD_CameraCore
- SRD_CEBattleIntro
- SRD_TimerUpgrade
- SRD_TitleCommandCustomizer
- SRD_TitlePictureChoices
- KhasCore
- KhasGraphics
- KhasAdvancedFog
- KhasUltraLighting
- MOG_BossHP
- MOG_TreasurePopup
- MOG_TreasurePopupFix
- MOG_CharParticles
- MOG_SkipWindowLog
- GALV_QuestLog
- GALV_TimedMessagePopups
- GALV_DisableDash
- GALV_EventSpawner
- Galv_ShadowDarken
- Galv_ImageCache
- GALV_ActionIndicators
- GALV_BasicEventShadows
- MrTS_SceneBackgrounds
- MrTS_EmptyMenu
- SimpleEventFade
- Cae_LineOfSight
- CAE_equipEval
- Cae_CustomEscCodes
- Cae_HelpWindowText
- Cae_NoZeroDmgPop
- CaeX_FloatingStates
- DreamX_ChoiceHelp
- sal_core
- sal_routeMovement
- BBS_VersionDisplay
- GamepadConfig
- SOL_Cheats
- cae_fullScreenFix
- TDDP_MouseSystemEx
- DestinationSprite
- SpeedManager

Please note, plugins with prefix SOL_X_ are mine plugins, but most of them are just game strings storage and disabling them are not solving problem.

Edit:
Adding one of these plugins also not helps:
-KODERA_optimization.js
-Irina_PerformanceUpgrade.js
are you sure that the lag comes from inside the engine?
because my first guess after your description and how it happens would be a background antivirus check.
No file can be handled by more than one program at the same time - that is why cloudsync's create problems for the editor, but it also means that if a different background program opens a file for a check, the engine has to wait for that program to close the file before it can open it for itself.

and HTML/JS files are prime targets for AVPs, especially if they are active...
Hmm... I never thought about antivirus software... Give me some time to playtest game with disabled Antivirus software, actually You might be right @Andar, because I have a free AV - Panda Dome Antivirus.

Edit:
I did test run with disabled antivirus, "lags" occured several times, but not that often like with enabled Antivirus. I'm gonna check this matter tomorrow on my laptop with fresh OS installation and see the results, I'll make now small plugin to list FPS counter and on which action of player takes in game play:
example entry:
22:59, Player walks (FPS: 60)
could be multiple causes with one of them the AVP - I only gave the AVP as the most common example, but network security programs or parental guidance programs (if accidentally activated) are other possibilities.
I don't have any network security software, but I wrote that plugin, and here are the results:

This is result from medium map (city) - PDF document
Size 69x43, approx 50 interactive NPC's

And this documents show performance from small map - PDF document
Size 27x14, just one interactive NPC
A certain amount of resources are required per task (CPU, RAM, etc). Remember that a "lag spike" is only an indication that the game didn't get enough resources to handle that frame within the expected time interval. It might mean that that frame needed much more processing, or that some background app suddenly grabbed lots of resources, or both.

Like Andar suggested, Windows has a bunch of built-in security features besides anti-virus. It is likely not a single thing that's causing the problem. It might even be largely unrelated to your game...if you watch the Task Manager for a while do you notice any spikes?

The data you've provided, by itself, doesn't really help much. Were you just standing in place for the duration of each test, or walking around the map? Did the spikes coincide with the appearance of new elements on-screen: NPCs, lights, etc? What events were running/triggered during the test, and at what times? Do you have Parallel events running in the background? A video, with the framerate widget (F2) enabled, might be more informative...I get that that is a lot more effort, though. 😴


PS: I believe my Cae_LineOfSight plugin is, at best, unstable; I've had unverified reports of it "working" at 0 FoV, but the code is a mess. You may want to consider replacing it with something else, e.g. Galv's Event Detectors. At least try disabling it to see if that helps the performance. 😅
@caethyril - this whole spiking thing occurs only on Scene_Map, all other scenes works perfect and this lag occurs regardles if player is idle or walk and I've provided results with medium map size and small map:

medium map has around 50 interactive events (NPC) and 277 events acting just as decoration (signs, lights, doors etc) and on map are active: Fog Of war (TerraxLightning) and KHAS ultraLightning (Street Lights) and rainy weather. Small map don't uses none of these things and there are 4 events (2 interactive, 2 decorations), but I've disabled your plugin Line Of Sight and number of spikes drastically lowered (marginal number of lags, tolerable to play). And yeah, it might be just my PC issue, but to confirm it in late afternoon I'll run game on my laptop which has fresh windows instalation.

I've checked my task manager both in performance and processes tabs and nothing out of ordinary I found, like I said, I'll do tests late afternoon on laptop which is 4 worse in performance than my regular PC:

Laptop Spec:
2GB Ram
GeForce G 102M 512MB VRAM
Intel Pentium Dual Core T4200 2 x 2 GHz
Windows 7 Home 64bit
@Soulrender - without plugins, and when no events are running, I believe the battle scene is most demanding...so if you disable some of the plugins that add map effects then that may help. For example, lighting is usually pretty heavy, especially if it has dynamic shadows, so if you're only using Terrax for fog of war (?), perhaps you could replace that with something else.

Also, when you test on the laptop you may want to check the renderer type: press F2 to show the framerate widget, which will be labelled WebGL or Canvas. WebGL (default) is GPU-based and generally significantly faster than Canvas. Some plugins (e.g. Khas lighting?) might simply require WebGL support.

Good luck! 👋
@caethyril On laptop game runs at awesome 21 FPS rate in idle xD (but, keeps it solid, no spikes), so I can say now, there's something wrong with my windows... Well I'll just reinstall windows (in next year) 😀
Okay, after digging through all scripts and events I've found what's causing problem.
It's SRD's hud maker and my HUD. I've disabled this plugin and there were no single spikes.
(Looks like it's time to switch to MOG_ActorHud)

Original thread: https://forums.rpgmakerweb.com/threads/weird-fps-spikes.143392/