NPAPI plugin making JavaScript calls causing spurious "Unresponsive Script" warnings

[email protected]
Newsgroups gmane.comp.mozilla.devel.dom
Organization http://groups.google.com
Message-ID <2a84c4cf-9dc4-4453-a1ba-0ae864400caf@m34g2000hsb.googlegroups.com>
Test environment: Windows XP SP2, FireFox 2.0.0.11

While implementing an NPAPI browser plugin, we have found something we
think is a bug with the way FireFox detects unresponsive scripts. We
started getting "Unresponsive Script" messages while the plugin was
regularly calling a very small JavaScript function on the page, which
is in charge of updating some kind of progress dialog.

That function is very small, the first thing I did was to add timing
around the call, and it never exceeded 30ms. However after the plugin
had been calling that function for about dom.max_script_run_time, we
were getting the warning.

After a few hours of experimentation, I realized that I could avoid
the warning to trigger if I was calling a different function on
regular intervals, and have it issue a setTimeout call like so:

function OnHeartbeatTimeout() {
    console.log( 'OnHeartbeatTimeout' );
}

function OnHeartbeat() {
    console.log( 'OnHeartbeat' );
    setTimeout( 'OnHeartbeatTimeout();', 10 );
}

Just calling OnHeartbeat and returning, or even waiting a bit didn't
fix the problem. It had to be a setTimeout call, my understanding is
that this is causing FireFox to issue a javascript call internally
rather than firing from the plugin, and this effectively resets the
timeout counter so it doesn't trigger.

If someone can give me a few directions, I'd happily report this to
the bug tracker.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.