Graphical Object Global Reference VX ACE
(game.exe crash debugger)
by Mithran
NOTICE: This is the VX ACE version of the script. For the VX Version go HERE
Introduction
Well, it looks like VX Ace isn't completely immune from this problem after all. The root cause appears to be the same, but there is at least one other factor in the ACE crash that is yet to be discovered. Fortunately, fixing the cause will stop the crash.
The root cause of this error is not properly disposing of Sprites/Windows/Planes associated with a disposed viewport. There is no RGSS Player error message for this practice, but it can lead to Game.exe crashes. Script creators, please do your part and ensure you properly dispose your graphics objects, before they become an issue. This script can help you locate sprites you may have missed.
You may be suffering from this error if you install a custom script then start getting intermittent crashes:
"Game.exe has encountered a problem and needs to close"
"RGSS3 Player has stopped working"
This is one of the most frustrating errors to deal with in RPG Maker VX as it seems to come and go at random, only affecting certain people or setups, and the actual cause of the error is hidden to you.
If your project is getting even occasional Game.exe crashes after installing a custom script, this may be worth a read. Please note that this script can only log and debug game.exe crashes having to do with a script problem. If you are crashing without custom scripts installed, the source of your crash is something else and this script will not help.
This script addresses one specific issue that can cause an unhandled exception leading to an eventual Game.exe crash. The error is much rarer and harder to expose in VX Ace than VX, but I finally have confirmation that it is happening. This error is caused by a simple scripting mistake that would otherwise throw no error message, so it is at least worth a look.
AUTHOR'S NOTE: The following description primarily describes the VX (RGSS2)
version of the crash. The VX ACE crash shares some circumstances with the VX
crash. This script and instructions were written to address the VX issue then
updated to work in VX ACE. This script itself may or may not stop crashes in ACE
as it did with VX, but it can be used to log undisposed sprites and stop the
error from happening in the first place.
The cause of a given Game.exe crash could be any number of things - anything that
doesn't create throw an error in Ruby, but causes an unhandled exception in one
of the 'hidden' classes.
After extensive testing, I was finally able to recreate the circumstances leading
up to one such exception that, if left unhandled, could lead to Game.exe crash.
1. A "GO" - Graphical Object (Sprite, Window, Plane, or Tilemap) is created
2. The Graphical Object is assigned a Viewport
3. The Viewport is disposed, but the sprite is not
?? - VX ACE Version. There is a yet unknown factor that also needs to happen.
4. The Graphical Object is claimed by GC (garbage disposal)*
* - Newly Discovered: attempting to dispose a sprite that has a disposed viewport
will occasionally also crash. (v 1.1)
Note that this particular crash only seems to occur if screen draws have taken
place (any of the Graphics methods) between the time the viewport is disposed
and the sprite disposal is attempted.
Due to the way GC is implemented, you are unlikely to see an immediate effect
when the situation comes up. It could be several scene changes down the line
before the crash finally happens. To make matters worse, following the exact
same course of action will yield completely different results, making it seem
as though the crashes are random. In addition, there is yet another circumstance
which I have still been unable to pinpoint, but I suspect has something to do
with the order in which assets associated with the Graphical Object are claimed
by the GC, or the amount of screen rewdraws that have taken place,
that allows the GO to be cliamed without causing an exception and
thus making it even harder to find.
In essence: you could be suffering from an unstable game and not even know it.
So that is where this little script comes in. This does the following:
1. Creates a global variable backreference to every Graphical Object created.
This prevents them from being marked by the GC so long as the reference exists,
circumventing the final condition to cause this version of the crash.
2. Removes reference to the Graphical Object once it has been disposed.
This reallows the object to be marked by GC for disposal (once all other
references are removed). Since the GO is disposed, condition 3 is no longer met
and the object is deemed 'safe'.
3. Report on potential issues to the user.
This allows the user (given limited scripting knowledge) to identify potential
errors and fix them outright.
4. Prevents further Game.exe crashes caused by this specific issue.
Includes a 'lazy' fix that cleans up offending Graphical Objects when the scene
changes.*
* v 1.1 'Lazy' fix has been superceeded to prevent crashes caused by disposal of
these errant sprites. Lazy fix only works if debug criticial disposal has
been disabled. Lazy mode is NOT recommended for ACE users.
Version History:
v 1.2 VX ACE
Discovered possibility of crash in RGSS3. Thanks to Galv for bringing the
problem to my attention and supplying a script to use as a test case.
Updated logging features to specificially work with VX ACE. RGSS Console must
be enabled to recieve live updates.
Added GOBJ_ABRIDGED_LOG option.
Altered some terms in the log. Specifically changed the term 'non-critical object'
to 'Memory Leak' so the term 'Critical Object' can be easily searched in the log.
Time in log now refers to creation time of the object, rather than time log was written.
v 1.1
Discovered a new condition for a Game.exe crash. Updated script to trap and log
this error also.
v 1.01-1.05
Minor bugfixes, improved logging, added consideration for Plane objects viewport method error
v 1.0
Initial Release
Features
- Identifies and reports a prevalent, and generally very easy to fix, cause of Game.exe crashes.
- Creates a global reference to every graphical object created until it is disposed to prevent the error from causing this specific Game.exe crash while it is running
Script
http://pastebin.com/DvuinNFU
How to Use
Install on its own script page in the materials section of the script editor above main and below default scripts. If using a script that creates sprites at startup (eg. Jets Mouse System), this script must come after it on the list.
FAQ
Q: Game.exe crashes for me constantly and this didn't help!
A: As explained, this only prevents Game.exe crashes caused by the specific set of circumstances outlined. Crashes caused by memory faults or other errors may still remain, but if there is an in-game reason for it (read: crashes happen after x set of actions are taken with a fair degree of consistency, or across several computers) feel free to leave a post here.
Q: I'm using a cracked version and..
A: Support will not be given for non-official versions. Using a cracked version is also against the forum rules, among other things, and will get you banned.
Q: I found another way to force a Game.exe crash in a seemingly stable game.
A: I'd love to hear about it. Drop a post with the details.
Credit and Thanks
- Mithran (author)
- Galv, for bringing this to my attention and being able to point me to an ACE script that can cause this crash
Author's Notes
For distribution, please link to this thread. May be used in any project, so long as the full header, credit, and instructions remains intact. As with all my debugging scripts, credit for the project as a whole is NOT required
Bug Reporting
If you encounter an error, please provide the complete error code as well as a short description on how to reproduce.
Need Help?
If you are logging errors in GOBJ.txt but unsure how to fix them, you may post here asking for help. In order for me to even look at your project, I will need at bare minimum a complete copy of your scripts.rvdata2 file (preferably the entire project) and the GOBJ.txt log file. I can't guarantee I will be able to look at every project immediately.
If you are not logging any errors and continue to crash with my script installed (or crash without custom scripts), please explore other possibilities of the crash before posting in this thread.