[Bug] Game freezes after window is left unfocused for a while

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
307
Reaction score
321
First Language
Croatian
Primarily Uses
RMMV
User: bblizzard
Bug: Game freezes after window is left unfocused for a while.

How to Replicate the Bug:
  • Start up a game.
  • Switch focus to something else and leave the game running in background for usually 20-30 minutes. (I am not 100% sure that a longer time frame is required or not. I provided more info below.)
  • The bug doesn't reproduce every time. I experienced it only a handful of times in hundreds of runs and switching the focused window.
Other: The last time this happened, I used to console to get some data. I noticed that Graphics._skipCount was negative. Looking at the implementation of Graphics.render(), I assume that the error lies in the first if condition that checks for:

Code:
if (this._skipCount === 0)
rather than:

Code:
if (this._skipCount <= 0)
As JavaScript uses double-precision floating point values internally, this leads me to believe that this bug might be caused by a floating point precision error after a while which is why the bug usually only happened after leaving the game running in background for a while. In any case, I am pretty confident that changing this if condition will fix the issue. I did a drop-in change of the method in the console and the game unfroze.
 

chinx

Warper
Member
Joined
Jun 2, 2019
Messages
4
Reaction score
2
First Language
English
Primarily Uses
RMMV
It's been bothering me for a long time. I hope this will fix it.

Thx a lot.
 

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
307
Reaction score
321
First Language
Croatian
Primarily Uses
RMMV
I've been using this fix since I discovered it and haven't had that issue anymore since then. Here, if you want it in plugin form:

Code:
//=============================================================================
// SkipCountFix
//=============================================================================

(function() {
   
//=============================================================================
// Graphics
//=============================================================================

var SkipCountFix_Graphics_render = Graphics.render;
Graphics.render = function(stage)
{
    if (this._skipCount <= 0)
    {
        this._skipCount = 0;
    }
    SkipCountFix_Graphics_render.call(this, stage);
};

//=============================================================================

})();
Once the MV team confirms this issue/fix and integrates it into the default code, you can simply remove the plugin.
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
168
Reaction score
117
First Language
English
Primarily Uses
RMMV
So glad that I discovered this thread and your fix for the bug! It helped with a graphics-freezing problem that one my playtesters had. Thanks!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I like Iron Maiden.
Benku wrote on Magnus0808's profile.
Hey man you helped me out a long time ago with a plugin i was wondering if you can help me out one more time since its literally the last thing i need help with if not is cool but id figured id ask you one more soild.
Stream will be live shortly with a guest stream! Tonight, a new guest joins~ Feel free to drop by!
Finally told my boss I need a day off. Tomorrow will be my first in 23 days.
Kind of a goofy question but has the pandemic inspired you in any way?

Forum statistics

Threads
95,421
Messages
929,039
Members
125,650
Latest member
Magidonsa
Top