Open Bug 707490 Opened 13 years ago Updated 2 years ago

Unresponsive script dialog pauses execution of slow script

Categories

(Core :: JavaScript Engine, defect)

x86_64
Windows 7
defect

Tracking

()

People

(Reporter: jaws, Unassigned)

References

()

Details

When the unresponsive script dialog appears, it doesn't seem to matter how long I leave the dialog open. I can wait 10 seconds or 1 minute and once I hit "continue", then the browser will come back to life about 5 seconds later.

This leads me to believe that the unresponsive script dialog is pausing the script. If this is the case, the unresponsive script dialog should disappear if the script is able to finish before the user makes a decision.

This bug is especially painful if a user opens a webpage, walks away from their computer, and comes back and the loading of said webpage stopped early and thus still won't have finished until the user intervenes.

To reproduce this, log in to irccloud.com (see bug 703455) and wait a period of time before telling the script to "continue".
>I can wait 10 seconds or 1 minute and once I hit "continue", then the browser will 
>come back to life about 5 seconds later.

I assume that this statement is based on your experience with the one single website irccloud.com ?
That the loop goes away seems to be a special case.
Maybe the loop goes away due to a timeout from the website or the script is just a little bit too slow and triggers the dialog just before it's finished.
In nearly all cases you have a real loop and the browser will hang if you hit continue.

>This leads me to believe that the unresponsive script dialog is pausing the script.
>If this is the case, the unresponsive script dialog should disappear if the script 
>is able to finish before the user makes a decision.

How should the script finish if it's paused ?
Note: The script have to be paused to show the dialog that can interact with the user.
(In reply to Matthias Versen (Matti - currently busy) from comment #1)
> >I can wait 10 seconds or 1 minute and once I hit "continue", then the browser will 
> >come back to life about 5 seconds later.
> 
> I assume that this statement is based on your experience with the one single
> website irccloud.com ?

Yes, this is true.

> >This leads me to believe that the unresponsive script dialog is pausing the script.
> >If this is the case, the unresponsive script dialog should disappear if the script 
> >is able to finish before the user makes a decision.
> 
> How should the script finish if it's paused ?
> Note: The script have to be paused to show the dialog that can interact with
> the user.

Yeah, I guess this is something that e10s could have fixed?
>> Note: The script have to be paused to show the dialog that can interact with
>> the user.
>
>Yeah, I guess this is something that e10s could have fixed?

Yes, I think this would be "fixable" by e10s but you would still have the problem that a loop often allocates a huge amount of memory.
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Whether we want to do this seems like a product question: which version would users prefer?

I don't know if this is really a JS engine issue: the JS engine just reports that a script has been running for 10 seconds. The browser decides what to do about that. I guess the browser could show a dialog and then let the JS continue to run, but that would be kind of weird because the dialog would be unresponsive while the JS continues to run. 

There was a bug recently about running JS on background threads that is related to this but I can't find it right now.
See Also: → js-unwind
> I guess the browser could show a dialog and then let the JS
> continue to run, but that would be kind of weird because the dialog would be
> unresponsive while the JS continues to run. 

The JS engine could terminate the script on its next "operation callback" after the user clicks "Stop", right?  That would be good enough, I think.
(In reply to Matthias Versen [:Matti] from comment #1)
> >I can wait 10 seconds or 1 minute and once I hit "continue", then the browser will 
> >come back to life about 5 seconds later.
> 
> I assume that this statement is based on your experience with the one single
> website irccloud.com ?

As the reporter of bug 858846, I can say it happens elsewhere too. For example, I have seen multiple times Firefox refer to resource://gre/modules/XPIProvider.jsm in the unresponsive script warning after I choose File > Exit.

> Note: The script have to be paused to show the dialog that can interact with
> the user.

That's too bad.

(In reply to David Mandelin [:dmandelin] from comment #4)
> 
> I don't know if this is really a JS engine issue: the JS engine just reports
> that a script has been running for 10 seconds. The browser decides what to
> do about that. I guess the browser could show a dialog and then let the JS
> continue to run, but that would be kind of weird because the dialog would be
> unresponsive while the JS continues to run. 

I guess you mean the JS engine is not preemptive; unless the engine pauses running and returns the control to the browser, the browser UI has no way to stop the engine.

Maybe a (dirty) workaround would be to dismiss the dialog automatically a few seconds after the dialog is displayed, and let the script run for another 10 seconds, and show the dialog again, and repeat this until the user finally intervenes or the script finishes. It may appear more confusing sometimes, but it can be more helpful in other cases.

> There was a bug recently about running JS on background threads that is
> related to this

That would be very helpful.
(In reply to Seungbeom Kim from comment #8)
> Maybe a (dirty) workaround would be to dismiss the dialog automatically a
> few seconds after the dialog is displayed, and let the script run for
> another 10 seconds, and show the dialog again, and repeat this until the
> user finally intervenes or the script finishes. It may appear more confusing
> sometimes, but it can be more helpful in other cases.

Additional ideas:
* Display a timer in the dialog ("Dismissing the dialog and continuing the script in ## seconds...").
* (Possibly) use exponential backoff, up to a certain limit, for the duration of script execution until the next dialog.

If the user doesn't respond to the dialog, it should be interpreted as having no intention to terminate the script, so the script execution should somehow make progress in the absence of user intervention; the script execution should not be left paused indefinitely.
On my system, shortly before the unresponsive script dialogue appears, the system starts slowing to a crawl, and nearly freezes by the time the dialogue appears. This state remains as long as the dialogue box is present. If I choose to terminate the script, few seconds after that the system jumps back to life. This happens irrespective of website. FB, Gmail, take your pick, whatever.

I wish until the root of the problem is fixed, there would be an option to always terminate the script.
Assignee: general → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.