Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XHR Hangs in FF, multiple xmlHttpRequests.

36 views
Skip to first unread message

rib...@gmail.com

unread,
Oct 23, 2007, 3:16:51 PM10/23/07
to
Is the behavior of FireFox/Mozilla handling multiple xmlHttpRequests
documented? (if so, where?) My application keeps an XHR pending to
the server (a slow poll sort of thing) waiting for the server to send
it an update. In some situations FF hangs waiting for a response.

-- Each of my web pages maintains one XHR for getting notifications.
-- Another XHR may be used to send commands from FF to the server
(overlapping the pending notification XHR).
-- The user may have more than one such page open in different tabs
or
windows
-- These pages may be 'active' on 'hidden' tabs
-- The user may have navigated to a new page (and may later come
back).

The sort of information I'm locking for is:
-- When a page is in a hidden tab, will the XHR transactions and
javascript
contirue to run as through the page was visible? It won't get
an unload event.
-- When a page navigated away from, it is unloaded, and the JS stops
and
the XHR seem to end, and I seem to get the readystatechange
event.
When you press the back button, do you get an load event again?
-- How many simultaneous, independant, asynchronous XHRs can be
running
at a time? In one page/tab? In one FF window? On one
computer?


Who knew programming could be so complicated?

Anthony Jones

unread,
Oct 24, 2007, 6:49:53 AM10/24/07
to
<rib...@gmail.com> wrote in message
news:1193167011.9...@t8g2000prg.googlegroups.com...

> Is the behavior of FireFox/Mozilla handling multiple xmlHttpRequests
> documented? (if so, where?) My application keeps an XHR pending to
> the server (a slow poll sort of thing) waiting for the server to send
> it an update. In some situations FF hangs waiting for a response.
>
> -- Each of my web pages maintains one XHR for getting notifications.
> -- Another XHR may be used to send commands from FF to the server
> (overlapping the pending notification XHR).
> -- The user may have more than one such page open in different tabs
> or
> windows
> -- These pages may be 'active' on 'hidden' tabs
> -- The user may have navigated to a new page (and may later come
> back).
>
> The sort of information I'm locking for is:
> -- When a page is in a hidden tab, will the XHR transactions and
> javascript
> contirue to run as through the page was visible? It won't get
> an unload event.

True the page is still loaded and continues to run code when events occur.

> -- When a page navigated away from, it is unloaded, and the JS stops
> and
> the XHR seem to end, and I seem to get the readystatechange
> event.
> When you press the back button, do you get an load event again?

Yes

> -- How many simultaneous, independant, asynchronous XHRs can be
> running
> at a time? In one page/tab? In one FF window? On one
> computer?

You can have as many XHRs as you like in any of the scenarios. However by
default a single FF process will only open a maximum of 8 connections per
server.

Are you sure the problem isn't at the server end? What is the server?

>
> Who knew programming could be so complicated?
>

Babbage, Turing, Jackson, ... and anyone with formal training in computer
science.

--
Anthony Jones - MVP ASP/ASP.NET


Message has been deleted

rib...@gmail.com

unread,
Oct 24, 2007, 5:55:25 PM10/24/07
to
The number of simultaneous xmlHttpRequest (XHR) extant at one time is
controlled limited by the about:config preference: network.http.max-
persistent-connections-per-server (which is 2 by default). An
additional XHR can cause FireFox to hang (windows don't repaint, UI
buttons frozen) until one of the XHRs complete.

A long running XHR can occur when a web page is waiting for
notifications pushed from a server. Opening two or three such pages
from the same server can cause the browser to hang when the browser
attempts to load another page, image, script or CSS file.

I think that the limit of max-persistent-connections-per-server should
not apply to XHRs (which are under control of the web page creator);
that they should be limited by a separate count from connections
created by the browser while loading elements of a page; or, at least,
should not cause the browser display painting the UI function to hang.

Anthony Jones

unread,
Oct 24, 2007, 6:00:29 PM10/24/07
to
<rib...@gmail.com> wrote in message
news:1193241786.9...@i38g2000prf.googlegroups.com...
> Thanks Anthony. I don't think I'm using more than 8 connections to
> the same server. The server is something that I'm writing, but I
> don't think the problem is there ("that's what they all say).
>
> Each page from this server runs a JS that keeps an XHR pending with
> the server. To allow the server to notify the page of changes, the JS
> issues a request to the server which the server doesn't respond to
> until it has something to say. From the server, I can issue a command
> to send a 'response' to the browser page. The browser page gets that
> response, executes the command and sends a reply as part of the next
> 'poll' to the server. Doing this unblocks the browser (ie the window
> can repaint, buttons in the browser UI work) The browser may hang
> again. I think this indicates that the JS and the browser display
> repainting code is getting blocked.
>
> I see this when I have two of these pages (ie two pages with XHR
> requests pending to the server) and I start a third page in another
> tab. Therefore I think I only have at most three XHRs to that server.
>
> When you say 8 XHRs per server per FF process, is it true that all FF
> windows (and tabs within the windows) are running on one Windows
> process?
>

Yes. However I didn't say 8 XHRs I said 8 connections. You can have as
many XHRs as you like but only a maximum of 8 can get a connection to a
server. When a 9th XHR requests a connection where 8 currently have a
connection the 9th will block until a connection is free. I've not tested
it but one would expect send to return even if a connection hasn't yet been
acquired.

Note this pool of connections is shared by all parts of FF that request
resources from the server. Hence if you already have 8 XHRs with
outstanding connections that haven't completed yet the browser will be
unable to fetch HTML or images or other resources from the server.

I don't know whether it was you or someone else I discussed this with some
time ago but frankly I think the whole approach is flawed. HTTP is
essentially a connectionless, stateless protocol. You're architecture is
trying to use it in a way very different from what it was designed for.

My guess is that connections are not being freed perhaps due to not tearing
down the XHRs properly. It could be that a JS closure is maintaining an XHR
that the client no longer is using which in turn is maintaining an
unfullfilled connection to the server. When the code has done that a few
times the whole thing will appear to lock up.

Or it could simply be because you have 8 or more genuine XHRs gobbling up
all the available connections.

cbet...@gmail.com

unread,
Oct 28, 2007, 6:15:22 AM10/28/07
to
On 24 Ott, 23:00, "Anthony Jones" <A...@yadayadayada.com> wrote:
> <rib...@gmail.com> wrote in message
>
> news:1193241786.9...@i38g2000prf.googlegroups.com...

Hi,
we had the same exact problem with our applications, and not by
writing strange apps using HTTP in a "non intented" way, but using
widely used tools like AjaxPro.dll and MS AJAX.NET 1.0.
The whole user experience "slows down", sometimes the page hangs, and
so on.

All this NEVER happens with IE 7 or Opera 9.

We are very sad, because FF is superior in many other aspects (page
rendering, javascript compliance, etc),
but we can't use FF anymore for our AJAX applications if the beahviour
is this !

We think something is to be done to correct this aspect of FF, because
all future applications will be more and more based on AJAX /
XmlHttpRequest technology.

Thanks for the support,
Corrado
CIDITECH

Anthony Jones

unread,
Oct 28, 2007, 10:48:34 AM10/28/07
to
<cbet...@gmail.com> wrote in message
news:1193566522....@k79g2000hse.googlegroups.com...

I can't say that I've found XmlHttpRequest to be slow on FF. If anything
with IEs default 2 connections per server I would have though IE would
stuggle more.

0 new messages