<p dir="auto">I'm developing a computationally intensive application using electron. I came to notice that when I drag the browser around, SOMETIMES the main Node.js thread is blocked, and it blocks the main thread for a while, or even completely by change.</p>
<p dir="auto">I first thought it might be the communication between IPCMain and IPCRender so I disconnect all of them in my code, but it doesn't help. This is like a reverse case of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="115670264" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/3363" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/3363/hovercard" href="https://github.com/electron/electron/issues/3363">#3363</a>, however as far as I know I can't workaround it not touching code in electron.</p>
<p dir="auto">To make a simple illustration, I use the electron quick start application and 15 lines additional code.</p>
<ul dir="auto">
<li>Electron version: 1.4.15</li>
<li>Operating system: Windows 10 Pro Version 10.0.14393 (Also reproduce-able on Ubuntu )</li>
</ul>
<h3 dir="auto">How to reproduce</h3>

<ol dir="auto">
<li>Download electron-quick-start<br>
<a href="https://github.com/electron/electron-quick-start">https://github.com/electron/electron-quick-start</a></li>
<li>In main.js add</li>
</ol>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var lastDate = new Date();

function printTime () {
  var d = new Date();
  var delta = d - lastDate;
  if(delta &gt; 20) {
    console.log(delta);
  }
  lastDate = d;
}"><pre class="notranslate">var lastDate = new <span class="pl-en">Date</span>();

<span class="pl-k">function</span> <span class="pl-en">printTime</span> () {
  var d = new <span class="pl-en">Date</span>();
  var delta = d - lastDate<span class="pl-k">;</span>
  if(delta <span class="pl-k">&gt;</span> 20) {
    console.log(delta)<span class="pl-k">;</span>
  }
  lastDate = d<span class="pl-k">;</span>
}</pre></div>
<p dir="auto">and modity app on ready</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="app.on('ready', () =&gt; {
  createWindow();

  setInterval(printTime, 10);
})"><pre class="notranslate"><span class="pl-en">app.on('ready',</span> () =<span class="pl-k">&gt;</span> {
  <span class="pl-en">createWindow</span>();

  setInterval(printTime, 10)<span class="pl-k">;</span>
})</pre></div>
<ol start="3" dir="auto">
<li>Run the app, and drag the title bar of the browser window around</li>
</ol>
<h3 dir="auto">Expected behavior</h3>

<p dir="auto">If the main thread keeps running, the interval calls printTime every 10ms and the threshold for the console.log is 20ms, so there should be no print out in the console.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">I get random numbers like</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="96
34
33
601
118
32"><pre class="notranslate">96
34
33
601
118
32</pre></div>
<ul dir="auto">
<li>Electron version: 1.3.5</li>
<li>Operating system: OS X</li>
</ul>
<p dir="auto">This is going to sound ridiculous, but setTimeout is not working for me in the main process. Consider this trivial application, no windows or anything:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var Electron = require( 'electron' );
var app = Electron.app;  // Module to control application life.

// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {

  var x = 0;
  var timeout_tester = function run_again(){

    console.log( x, x, x );
    x += 1;
    setTimeout( run_again, 30 );
  };

  timeout_tester();
});"><pre class="notranslate"><code class="notranslate">var Electron = require( 'electron' );
var app = Electron.app;  // Module to control application life.

// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {

  var x = 0;
  var timeout_tester = function run_again(){

    console.log( x, x, x );
    x += 1;
    setTimeout( run_again, 30 );
  };

  timeout_tester();
});
</code></pre></div>
<p dir="auto">When I run this, I see the counter increment on the console until ~900. From then on it very sporadically fires. I cannot tell you how long it took me to track an issue I was having down to this, and even then I did not believe it. Please tell me someone can reproduce this or point out the wildly stupid thing I am doing.</p>
<p dir="auto">Thanks in advance</p>