[RMMV BUG Report] FPSMeter.js cancels PIXI.ticker.shared's _tick callback.

● ARCHIVED · READ-ONLY
Started by zumikua 5 posts View original ↗
  1. I encountered this bug on RPG Maker MV 1.6.1. Without any plugins. You can create a default project and reproduce this behavior by execute the following code in console:

    PIXI.ticker.shared.add(()=>{console.log("test");});

    and you will see zero result, even if this shared ticker is already started.

    Since this bug can be reproduced with a fresh new project, I will not provide a sample project.

    This is a known bug which is already reported here : https://github.com/darsain/fpsmeter/issues/15

    But since the upstream project seems abandoned (last commit is five years ago), I think it should be the RMMV Dev's responsibility to fix this bug.

    The cause of this bug is that the pause function of fpsMeter called cancelAnimationFrame without checking is the frameId is created with requestAnimationFrame or setTimeout(it is determined by interval of fpsMeter), which cause it accidentally canceled request requested by others (PIXI.ticker.shared, in this case).

    I think the fix is very simple, just add a check in fpsMeter's pause function, but since fpsMeter is minified, It is not very easy to write a plugin to fix this behavior.

    PIXI.ticker.shared is useful since DragonBones Runtime use it to update it's animation.
  2. Just in case the instructions got confusing by Jonforum:
    1. Open Index.HTML and remove the following line:
    Code:
    <script type="text/javascript" src="js/libs/fpsmeter.js"></script>

    2. In RPG_CORE.js look for this and disable createFPSMeter:
    Code:
    Graphics._createAllElements = function() {
        this._createErrorPrinter();
        this._createCanvas();
        this._createVideo();
        this._createUpperCanvas();
        this._createRenderer();
        // this._createFPSMeter();
        this._createModeBox();
        this._createGameFontLoader();
    };

    3. In Package.json add this:
    Code:
    {
        "name": "",
        "main": "index.html",
        "js-flags": "--expose-gc ",
        "window": {
            "title": "",
            "toolbar": false,
            "width": 816,
            "height": 624,
            "icon": "icon/icon.png"
        },
        "chromium-args": "--show-fps-counter"
    }

    We are aware of the issue and looking into it.
  3. for chromium arg it not necessary but this will avoid you to setup it each time you boot your projet.
    Because chromium not seem save those option in profile.

    upload_2018-8-6_16-10-9.png
  4. Thanks for your kindly reply!
    It's good to know you are aware of this issue and I'm looking forward to the official fix!
    I come up with a fix plugins without disabling FPSMeter.
    This is not a perfect fix, but it works. In case someone needs this, I post it here.

    Code:
    (function(){
        const oldFPSMeter = FPSMeter;
        FPSMeter = function(){
            oldFPSMeter.apply(this);
            const FPSMeter_pause = this.pause;
            this.pause = function(){
                FPSMeter_pause.apply(this);
                //sadly, we can't get frameId because of the fpsmeter.js is minified
                //so, restart ticker in all case.
                PIXI.ticker.shared._requestId = null;
                PIXI.ticker.shared._requestIfNeeded();
            }
        }
    })();