Parallel Process Events Execution Bug Fix.

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
410
Primarily Uses
Parallel Process Events Execution Bug Fix.
 

There is a problem with the execution of Parallel Process events in RPG Maker VX Ace (at least at the time of writing). Unlike Autorun events, they are not executed every update cycle (frame) by default due to a misplaced line in Game_Interpreter. The execution of the Parallel Process events skips one frame after one successful execution, potentially causing serious synchronization problems for event based systems. 

 

That behavior is completely unexpected and counterintuitive, and has the potential of making your game feel unresponsive to your players if you rely on Parallel Process events for any system that requires player input (like mini games).

 

How to corroborate the problem?
 

The easier way is to make a Parallel Process event report the game's frame count. To do that, simply create a Parallel Process event and add a Call Script command on it with the following:

 

Code:
p Graphics.frame_count
 

Solistra was kind enough to provide a video showing the problem and comparing the execution with Autorun events (which works as expected):

 




 

What causes the bug?

 

Event "update" method setups the interpreter only if it is not "running":

 

Code:
 def update   super   check_event_trigger_auto   return unless @interpreter   @interpreter.setup(@list, @event.id) unless @interpreter.running?   @interpreter.update end
 

"running?" is defined as the following in Game_Interpreter:

Code:
 def running?   @fiber != nil end
and the "run" method for the interpreter is the following:

Code:
 def run   wait_for_message   while @list[@index] do     execute_command     @index += 1   end   Fiber.yield   @fiber = nil end
 

The problem is that the control is passed back to the caller before the "@fiber = nil" line is executed, so by the time of the next Event update cycle, the Interpreter is still "running" and won't setup again, making it skip one update cycle because when the Fiber gains back control, it will execute the pending "@fiber = nil" line, and the condition for the Interpreter update won't be met:

 

Code:
 def update   @fiber.resume if @fiber end
How to fix the problem?
 

The solution is simple:

 

Code:
# Parallel Process Events Execution Bug Fix.# Version 1.0.0# 09/02/15 - DD/MM/YY# www.rpgmakersource.com# forums.rpgmakersource.comclass Game_Interpreter  # Overwrites default method with the fixed version.  def run    wait_for_message    while @list[@index] do      execute_command      @index += 1    end    @fiber = nil    Fiber.yield  endend
Pasting the above code right below the default scripts, or anywhere below Game_Interpreter and above any custom script, will fix the problem.

 ​
Terms of Use
 

The code is free. You can use it in any commercial or non commercial game. Credits are appreciated but not necessary. Don't remove the original header.
 
Last edited by a moderator:

AeghtyAteKees

Nyctopheliac
Veteran
Joined
May 8, 2013
Messages
33
Reaction score
2
Primarily Uses
The text in the code boxes is not parsed correctly, and cannot be used. (And I'm not adept enough to know how to parse it myself :( .)
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,426
Reaction score
14,160
First Language
English
Primarily Uses
RMVXA
You may have to ask in script requests to get that fixed, as I haven't seen that person around in a really long time.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
I have never heard of this problem before, and I would suggest you confirm that it IS the cause of your problem before using this, but here is the reformatted code from above:

Code:
# Parallel Process Events Execution Bug Fix.
# Version 1.0.0
# 09/02/15 - DD/MM/YY
# www.rpgmakersource.com
# forums.rpgmakersource.com

class Game_Interpreter
# Overwrites default method with the fixed version.
  def run
    wait_for_message
    while @list[@index] do
      execute_command
      @index += 1
    end
    @fiber = nil
    Fiber.yield
  end
end
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,145
Reaction score
815
First Language
Hungarian
Primarily Uses
RMVXA
I can confirm that this IS a problem happening in all VX Ace projects without exception, so installing this fix can only benefit Ace users.
There are tons of problems without this fix, like Source mentioned in the OP.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,966
Reaction score
13,603
First Language
English
Primarily Uses
RMMV
I had never run into any problems with my project in Ace, but then most of my parallel process events were to initialize things on maps, followed by deleting themselves.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,498
First Language
Indonesian
Primarily Uses
RMVXA
Idk if I'm gonna get scolded for, well... necropost?
But I'd love if it's also listed in RGSS3 bugfix (or pinned) since I had a hard time finding this script, and almost making a request of finding this (also too lazy to find what's wrong in Game_Interpreter). Found it after a constant search using different keywords

I never thought I'd use parallel process for input handling, so in the past I never really bother to use it. But now, I do. Now it's actually not a game breaking bug, it just something annoying that renders the input sometimes not responsive
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
563
Reaction score
273
First Language
German
Primarily Uses
As mentioned, the default script practically adds an implicit 1-frame-wait to the end of each event.
I've not had problems with parallel process events (you can always "Jump to Label" to the beginning of the event when you need the extra frame), but common events called through "Call Common Event" getting extended were a bit annoying.

Probably not relevant to most, but without the implicit wait any autostart map event will not block player movement or menu calls if it can be instantly completed, because it will still only run once per frame.
(For example, if you use this fix, create an autostart event on your map that does nothing but increasing a variable, you can move freely while the event keeps counting up the variable).
 

EVXA

Villager
Member
Joined
Aug 20, 2020
Messages
24
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Lol, I want to add this but the very nature of the fix causes much lag enough to be counter weighted as a reason to keep the bug on my large map, I'm looking for ways to make my a game more fps friendly & smooth to play, its bad enough I'm already pushing 4.0ghz turbo boost just to run the game comfortably, I know its 2020 but 4.0GHz limits my target audience by quite alot, I fear I might require 5.0Ghz by the time I'm done building the game.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,565
Reaction score
541
First Language
English
Primarily Uses
RMVXA
Are you using any anti lag scripts. They are not the best but they do help in most cases.
Also is a framerate stabilizer by Mhinra. works for me.
Your cpu speed is not a good way to judge if the game is running smoothly. This engine was developed for Windows XP with an average 512MB of ram. at 2.0ghz cpu.
If you have sever lags then you probably have scripts that are memory hogs and are not running as well as they should.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,145
Reaction score
815
First Language
Hungarian
Primarily Uses
RMVXA
If you can't get stable 60 FPS with a 4.0 GHz CPU, it's most probably not the fault of the scripts, but your eventing, especially if you have that many events on a single map.
A pixel movement and an action system may lower FPS on the map, but with that CPU power, you should have no issues with those alone. Even my old 1.9 GHz CPU can run the scripts you use without any serious FPS drops.

You may want to reconsider your design choices there, because no matter how I look at it, it sounds really bad.
Check how you could lower the amount of events there, make smaller maps instead of one giant map, and most importantly, check your parallel process events. If you have a parallel event that, for example, modifies a variable without any wait frames in between (which is a bad thing to do right there, btw), it will 100% destroy your FPS with that many events on a giant map, with or without this fix.

Also, if you want to raise your FPS by a lot, and if you don't plan on using the default mapping system (if you use parallax mapping instead), consider disabling the default tilemap drawing code. It gives a major boost on the map.
 
Last edited:

EVXA

Villager
Member
Joined
Aug 20, 2020
Messages
24
Reaction score
0
First Language
English
Primarily Uses
RMVXA
I understand, it is indeed an eventing issue, which won't be fixable as I need every single event, I have about 900ish events & the last 99 as for npcs/doors/other enemies not added yet, most everything else is done, theres 2 or 3 small places I could turn into other maps but its not worth it mostly, I would still end up using the spare events if done for other stuff & just seems silly to have to cut off possible free map roaming into/out of those areas.

I'm running about 55/89frames, or 41 frames depending on the fps viewer script, I'm not sure what frame rate it is actually but more is always better.
I just want to get it down low enough for 3.3ghz to be a minimum recommendation & 4.4ghz+ as the recommended, which is alot but its single core game I believe so only 1 core needs to be running this high for just this game not sure if thats correct, don't know if that means I could load up 4 instants of the game without frame loss I'll go check that.

Worse case I have a 60fps quality mode & 44fps performance mode for the game.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I always told my DA fans how much I hate slot machines. They're fine in games as a risk-and-reward system. But when you're spending REAL MONEY in a Vegas casino to try and hit the jackpot (which very, very few people will), it can really hurt your budget. Gambling is a bad habit, and I don't like wasting my money on a slim chance. Go to Vegas for the experience, not the jackpot.
Took the kids to a corn maze. They gave us a map and had lights at certain points in the maze. Not overwhelming... or underwhelming... just... whelming.
Okay, vacuuming fruit flies out of the air is surprisingly effective.
Finally finished my menu redesign after like a month of coding! I hate designing menus... Good news though - I thought of a complete redesign for it now, so yay...
Still no scam calls all day... also I got a quick gig designing a mascot drawing for a small business, so I might actually make some green of my own after all. That would be a perfect job for me, since I love art and digital design.

Forum statistics

Threads
104,388
Messages
1,006,029
Members
135,917
Latest member
kingrifer
Top