bluebooth

Veteran
Veteran
Joined
Nov 12, 2015
Messages
95
Reaction score
118
First Language
English
Primarily Uses
N/A
I wasn't sure where to post this, but I was advised this is a fix for a core file, so...

I noticed a tendency for MadeWithMv.js to run poorly during the last fadeout. For my test I was loading two custom images, one instead of the "Made With MV" splash, and a second custom screen. Both are pngs. With FPS display on, tests averaged ~50 FPS, during the fade out of the second image, it quickly drops to 11 FPS, then 8 FPS, then down to 3 FPS... obviously this delay is quite visually noticeable.

When I disabled the plugin, there was no delay between startup and loading the menu scene. This indicates that the performance issue was with MadeWithMV, and not with any loading of database and external files. It turns out that transitioning functions in Scene_Splash.prototype.gotoTitleOrTest() are called repeatedly, leading to subpar performance. This code is only called during the last fadeout, so logically, it is the source of the performance drop.

Attached is a simple fix for the lag. Performance is much better during fadeout with this applied, and I witnessed no change in functionality with the fix active.

Code:
/*:
 * NOTE: Images are stored in the img/system folder.
 *
 * @plugindesc v1.01 Show a Splash Screen "Made with MV" and/or a Custom Splash Screen before going to main screen.
 * @author Dan "Liquidize" Deptula
 *
 * Added hotfix that removes lag during transitioning out of Splash Screen. -Michael Morris @BBS 5/12/2017
 * 
 * @help This plugin does not provide plugin commands.
 *
 * @param Show Made With MV
 * @desc Enabled/Disables showing the "Made with MV" splash screen.
 * OFF - false     ON - true
 * Default: ON
 * @default true
 *
 * @param Made with MV Image
 * @desc The image to use when showing "Made with MV"
 * Default: MadeWithMv
 * @default MadeWithMv
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Show Custom Splash
 * @desc Enabled/Disables showing the "Made with MV" splash screen.
 * OFF - false     ON - true
 * Default: OFF
 * @default false
 *
 * @param Custom Image
 * @desc The image to use when showing "Made with MV"
 * Default: 
 * @default 
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Fade Out Time
 * @desc The time it takes to fade out, in frames.
 * Default: 120
 * @default 120
 *
 * @param Fade In Time
 * @desc The time it takes to fade in, in frames.
 * Default: 120
 * @default 120
 *
 * @param Wait Time
 * @desc The time between fading in and out, in frames.
 * Default: 160
 * @default 160
 *
 */
 /*:ja
* メモ: イメージはimg/systemフォルダ内に保存されます。
 *
 * @plugindesc メイン画面へ進む前に、"Made with MV"のスプラッシュ画面もしくはカスタマイズされたスプラッシュ画面を表示します。
 * @author Dan "Liquidize" Deptula
 *
 * @help  このプラグインにはプラグインコマンドはありません。
 *
 * @param Show Made With MV
 * @desc "Made with MV"のスプラッシュ画面を表示できる/できないようにします。 
 * OFF - false     ON - true
 * デフォルト: ON
 * @default true
 *
 * @param Made with MV Image
 * @desc "Made with MV"を表示する際に使用する画像
 * デフォルト: MadeWithMv
 * @default MadeWithMv
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Show Custom Splash
 * @desc "Made with MV"のスプラッシュ画面を表示できる/できないようにします。 
 * OFF - false     ON - true
 * デフォルト: OFF
 * @default false
 *
 * @param Custom Image
 * @desc "Made with MV"を表示する際に使用する画像
 * デフォルト: 
 * @default 
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param Fade Out Time
 * @desc フェードアウトに要する時間(フレーム数)
 * デフォルト: 120
 * @default 120
 *
 * @param Fade In Time
 * @desc フェードインに要する時間(フレーム数)
 * デフォルト: 120
 * @default 120
 *
 * @param Wait Time
 * @desc フェードインからフェードアウトまでに要する時間(フレーム数)
 * デフォルト: 160
 * @default 160
 *
 */

var Liquidize = Liquidize || {};
Liquidize.MadeWithMV = {};
Liquidize.MadeWithMV.Parameters = PluginManager.parameters('MadeWithMv');

Liquidize.MadeWithMV.ShowMV = JSON.parse(Liquidize.MadeWithMV.Parameters["Show Made With MV"]);
Liquidize.MadeWithMV.MVImage = String(Liquidize.MadeWithMV.Parameters["Made with MV Image"]);
Liquidize.MadeWithMV.ShowCustom = JSON.parse(Liquidize.MadeWithMV.Parameters["Show Custom Splash"]);
Liquidize.MadeWithMV.CustomImage = String(Liquidize.MadeWithMV.Parameters["Custom Image"]);
Liquidize.MadeWithMV.FadeOutTime = Number(Liquidize.MadeWithMV.Parameters["Fade Out Time"]) || 120;
Liquidize.MadeWithMV.FadeInTime = Number(Liquidize.MadeWithMV.Parameters["Fade In Time"]) || 120;
Liquidize.MadeWithMV.WaitTime = Number(Liquidize.MadeWithMV.Parameters["Wait Time"]) || 160;

(function() {

    //-----------------------------------------------------------------------------
    // Scene_Boot
    //
    // The scene class for dealing with the game boot.
    var _Scene_Boot_loadSystemImages = Scene_Boot.prototype.loadSystemImages;
    Scene_Boot.prototype.loadSystemImages = function() {
        _Scene_Boot_loadSystemImages.call(this);
        if (Liquidize.MadeWithMV.ShowMV) {
            ImageManager.loadSystem(Liquidize.MadeWithMV.MVImage);
        }
       if (Liquidize.MadeWithMV.ShowCustom) {
            ImageManager.loadSystem(Liquidize.MadeWithMV.CustomImage);
        }
    };

    var _Scene_Boot_start = Scene_Boot.prototype.start;
    Scene_Boot.prototype.start = function() {
       if ((Liquidize.MadeWithMV.ShowMV || Liquidize.MadeWithMV.ShowCustom) && !DataManager.isBattleTest() && !DataManager.isEventTest()) {
           SceneManager.goto(Scene_Splash);
       } else {
           _Scene_Boot_start.call(this);
       }
    };

    //-----------------------------------------------------------------------------
    // Scene_Splash
    //
    // The scene class for dealing with the splash screens.

    function Scene_Splash() {
        this.initialize.apply(this, arguments);
    }

    Scene_Splash.prototype = Object.create(Scene_Base.prototype);
    Scene_Splash.prototype.constructor = Scene_Splash;

    Scene_Splash.prototype.initialize = function() {
        Scene_Base.prototype.initialize.call(this);
        this._mvSplash = null;
        this._customSplash = null;
        this._mvWaitTime = Liquidize.MadeWithMV.WaitTime;
        this._customWaitTime = Liquidize.MadeWithMV.WaitTime;
        this._mvFadeOut = false;
        this._mvFadeIn = false;
        this._customFadeOut = false;
        this._customFadeIn = false;
        this._transitioning = false;
    };

    Scene_Splash.prototype.create = function() {
        Scene_Base.prototype.create.call(this);
        this.createSplashes();
    };

    Scene_Splash.prototype.start = function() {
        Scene_Base.prototype.start.call(this);
        SceneManager.clearStack();
        if (this._mvSplash != null) {
            this.centerSprite(this._mvSplash);
        }
        if (this._customSplash != null) {
            this.centerSprite(this._customSplash);
        }
    };

    Scene_Splash.prototype.update = function() {
        if (Liquidize.MadeWithMV.ShowMV) {
            if (!this._mvFadeIn) {
                this.startFadeIn(Liquidize.MadeWithMV.FadeInTime,false);
                this._mvFadeIn = true;
            } else {
                if (this._mvWaitTime > 0 && this._mvFadeOut == false) {
                    this._mvWaitTime--;
                } else {
                    if (this._mvFadeOut == false) {
                        this._mvFadeOut = true;
                        this.startFadeOut(Liquidize.MadeWithMV.FadeOutTime,false);
                    }
                }
            }
        }

        if (Liquidize.MadeWithMV.ShowCustom) {
            if (Liquidize.MadeWithMV.ShowMV && this._mvFadeOut == true) {
                if (!this._customFadeIn && this._fadeDuration == 0) {
                    this._customSplash.opacity = 255;
                    this._customWaitTime = Liquidize.MadeWithMV.WaitTime;
                    this.startFadeIn(Liquidize.MadeWithMV.FadeInTime, false);
                    this._customFadeIn = true;
                } else {
                    if (this._customWaitTime > 0 && this._customFadeOut == false) {
                        this._customWaitTime--;
                    } else {
                        if (this._customFadeOut == false) {
                            this._customFadeOut = true;
                            this.startFadeOut(Liquidize.MadeWithMV.FadeOutTime, false);
                        }
                    }
                }
            } else if (!Liquidize.MadeWithMV.ShowMV) {
                if (!this._customFadeIn) {
                    this._customSplash.opacity = 255;
                    this.startFadeIn(Liquidize.MadeWithMV.FadeInTime, false);
                    this._customFadeIn = true;
                } else {
                    if (this._customWaitTime > 0 && this._customFadeOut == false) {
                        this._customWaitTime--;
                    } else {
                        if (this._customFadeOut == false) {
                            this._customFadeOut = true;
                            this.startFadeOut(Liquidize.MadeWithMV.FadeOutTime, false);
                        }
                    }
                }
            }
        }

        if (Liquidize.MadeWithMV.ShowCustom) {
            if (Liquidize.MadeWithMV.ShowMV && this._mvFadeOut == true && this._customFadeOut == true) {
                this.gotoTitleOrTest();
            } else if (!Liquidize.MadeWithMV.ShowMV && this._customFadeOut == true) {
                this.gotoTitleOrTest();
            }
        } else {
            if (this._mvFadeOut == true) {
                this.gotoTitleOrTest();
            }
        }

        Scene_Base.prototype.update.call(this);
    };

    Scene_Splash.prototype.createSplashes = function() {
        if (Liquidize.MadeWithMV.ShowMV) {
            this._mvSplash = new Sprite(ImageManager.loadSystem(Liquidize.MadeWithMV.MVImage));
            this.addChild(this._mvSplash);
        }
        if (Liquidize.MadeWithMV.ShowCustom) {
            this._customSplash = new Sprite(ImageManager.loadSystem(Liquidize.MadeWithMV.CustomImage));
            this._customSplash.opacity = 0;
            this.addChild(this._customSplash);
        }
     };

    Scene_Splash.prototype.centerSprite = function(sprite) {
        sprite.x = Graphics.width / 2;
        sprite.y = Graphics.height / 2;
        sprite.anchor.x = 0.5;
        sprite.anchor.y = 0.5;
    };

    // Added in check for transitioning state.  If not, the transition code repeatedly executes (130 times in my game) until the
    // transition completes.  This can slow down larger projects, as setup takes longer to execute. -Michael Morris @BBS 5/14/17
    Scene_Splash.prototype.gotoTitleOrTest = function() {
        Scene_Base.prototype.start.call(this);
       
        if (this._transitioning === true) { return; }
       
        SoundManager.preloadImportantSounds();
        if (DataManager.isBattleTest()) {
            DataManager.setupBattleTest();
            SceneManager.goto(Scene_Battle);
        } else if (DataManager.isEventTest()) {
            DataManager.setupEventTest();
            SceneManager.goto(Scene_Map);
        } else {
            this.checkPlayerLocation();
            DataManager.setupNewGame();
            SceneManager.goto(Scene_Title);
            Window_TitleCommand.initCommandPosition();
        }
       
        this.updateDocumentTitle();
        this._transitioning = true;
    };

    Scene_Splash.prototype.updateDocumentTitle = function() {
        document.title = $dataSystem.gameTitle;
    };

    Scene_Splash.prototype.checkPlayerLocation = function() {
        if ($dataSystem.startMapId === 0) {
            throw new Error('Player\'s starting position is not set');
        }
    };

})();

I hope this helps.

*Update 5/14/2017: Cleaned up fix, reducing to one check, and made use of transitioning variable more clear*
 

Attachments

  • MadeWithMv.js
    10.9 KB · Views: 204
Last edited:

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
938
Reaction score
585
First Language
English
Primarily Uses
RMMV
Works as advertised. :)

Worth noting, I only ever saw the lag when I was using YEP_ItemCore. I thought it was some weird incompatibility between these two plugins, but it seems like ItemCore was just exacerbating it somehow.
 

Kaliya

// Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
506
Reaction score
567
First Language
English
Primarily Uses
RMMV
Hi,

Thanks for posting this fix. It was something I never noticed when developing it, but that might be because of my PC's specs, cause I don't notice any frame drop at all :kaoswt:. Regardless I will incorporate the fix into the next update to MV.

Thanks,
- Liquidize
 

bluebooth

Veteran
Veteran
Joined
Nov 12, 2015
Messages
95
Reaction score
118
First Language
English
Primarily Uses
N/A
Hi,

Thanks for posting this fix. It was something I never noticed when developing it, but that might be because of my PC's specs, cause I don't notice any frame drop at all :kaoswt:. Regardless I will incorporate the fix into the next update to MV.

Thanks,
- Liquidize

Hi Liquidize,

Thank you for posting, I'm glad to be able to help! Interesting that you didn't have the issue - this got me thinking; could there be some kind of difference between our setups causing the issue? Combined with Ramza's comment, I did some looking into YEP_ItemCore and some of my own scripts.

It occurs to me that Ramza and myself (among others I am sure) have large game databases, along with a number of additional data files. Some functions alias DataManager.setupNewGame(); Called on line 292. Is it possible that perhaps the larger database files combined with additional data files could extend the execution time of setupNewGame(); which, due to multiple calls, results in a performance drop that doesn't occur with smaller projects?
 

Kaliya

// Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
506
Reaction score
567
First Language
English
Primarily Uses
RMMV
@bluebooth It could be that. I don't particularly use a large test project to test the engine, at least no where near the size of most users games. I will give it a try using a larger test project a bit later to see if that could be the reason.
 

Tyruswoo

Game Designer
Veteran
Joined
Jul 13, 2014
Messages
96
Reaction score
68
First Language
English
Primarily Uses
RMMV
Thank you so much for this fix! I noticed that whenever I tried to save my game with the "MadeWithMV" plugin On, the game would throw an exception, listed on the console as follows:

MadeWithMV%20Fix.PNG


The fix you published corrected this "Object too deep" issue, so now my save files work again!

As a note: Another way to patch the "Object too deep" issue is to add the following .js script into your game:

Code:
//==============================================================
// JsonEx Static Class
//==============================================================

//Change maxDepth
JsonEx.maxDepth = 1000;

Using the above, you can increase the JsonEx.maxDepth value until the "Object too deep" error is not thrown. However, rather than that kind of patch, actually solving the problem is preferable.

For the "MadeWithMV" plugin, your fix solved this issue! Thank you!
 
Last edited:

sb~

Veteran
Veteran
Joined
Aug 2, 2016
Messages
41
Reaction score
28
First Language
English
Primarily Uses
Thank you for the fix! I posted about this issue last year and thought it was just me having the frame rate problem
.
 

Nanto

Warper
Member
Joined
Nov 18, 2015
Messages
4
Reaction score
0
First Language
French
Primarily Uses
Hi thank you for the fix ! work as intended :)
 

Rishi Raj Jain

Pokemon MV Maker
Veteran
Joined
Jul 2, 2017
Messages
204
Reaction score
50
First Language
English
Primarily Uses
RMMV
this Plugin isn't compatible with SRD_PKM_4MovesOnly
 

Latest Threads

Latest Posts

Latest Profile Posts

Phew! logged back. Seems I was too occupied with 3D learning (yeah for RPGM purposes) creating IRL space, trying to grow catnip, dealing with health and DC is good. (so MrC) ^^
Currently trying to add items in the same style as Kyrise's excellent icons. I like having a large variety of items :3 KyriseandMe.PNG
Create MiniMaps, Sprites for MV Enemies, & Aethereal Plane Battlebacks | RPG Maker News #74

Vtubers Vs MOTHER.png

This might be my next project. You like it?
I'm off to search the master script list for my skill issue. HOORAY! FUN!

Forum statistics

Threads
112,328
Messages
1,067,419
Members
145,966
Latest member
Ziaz82
Top