setInterval delay seriously when the second parameter millisec < 1000 and the current window is minimized

OS : Windows 10
NW.js : 0.14.7 sdk

Below is the test code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Hello World!</title>
</head>
<body>
    <h1>Hello World!</h1>
    We are using node.js
    <script>
    document.write(process.version);
    // Create a tray icon
    var tray = new nw.Tray({ title: 'Tray', icon: 'img/icon.png' });

    // Give it a menu
    var menu = new nw.Menu();
    menu.append(new nw.MenuItem({ type: 'checkbox', label: 'box1' }));
    tray.menu = menu;

    var  intervalId;

    var blink = function() {
        var sign = 1;
        return function() {
            console.info(sign + ' -> ' + new Date());
            if(sign == 0) {
                if(tray.icon != 'img/icon.png') {
                    tray.icon = 'img/icon.png';
                }
                sign = 1;
            } else {
                tray.icon = 'img/1x1.png';
                sign = 0;
            }
        };
    }();

    intervalId = setInterval(blink, 400);

    </script>
</body>
</html>

The problem:
nwjs_setinterval_problem

Author: Fantashit

1 thought on “setInterval delay seriously when the second parameter millisec < 1000 and the current window is minimized

Comments are closed.