http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute
XHR2 introduces timeout attribute to client and several browsers already support it.
In order to support it in Chromium, we have two choices:
1. Implement it in WebKit use current network stack. Just like https://bugs.webkit.org/show_bug.cgi?id=103251
2. Add timeout support in chromium network stack.
Both implementation will follow the same process:
1. start a timer when sending request out.
2. cancel the request if timer fired and failed the request with timeout error.
Any idea for it?
Best Regards
James
Synchronous XHRs causing hangs is a very real problem for Chrome users: It is one of the top 10 causes of renderer crashes.(Scenario: webpage hangs due to sync xhr ==> user gets prompted with an unresponsive webpage dialog --> user kills renderer --> tears)
The worst offenders are Chrome extensions. Most hangs are coming from content scripts injected into facebook.com and youtube.com. For instance, the Avast extension.
Independent of whether or not we support timeouts for sync XHRs, we can dramatically improve the user experience by giving users the option to abort hung sync XHRs!
I have filed this as: https://code.google.com/p/chromium/issues/detail?id=164665Basically the proposal is for the hung webpage dialog to indicate when the page is hung due to a sync XHR, show what the URL being waited on is, and give the option to abort it. This lets users recover from what today is a very bad situation, and would put pressure on site/extension authors to fix their act (since we are now blaming them for the hang).
Unfortunately, extensions can inject stuff into the page, so in the
limit we can't disable sync XHR for extensions.
On Thu, Dec 6, 2012 at 1:25 PM, Scott Hess <sh...@chromium.org> wrote:
Unfortunately, extensions can inject stuff into the page, so in the
limit we can't disable sync XHR for extensions.I don't believe this is true. Extensions get injected into an isolated world. In theory, they could cause existing code on the page to do a sync XHR if such code existed, but I think we could otherwise disallow it, which certainly is good enough.
On Thu, Dec 6, 2012 at 1:28 PM, Ojan Vafai <oj...@google.com> wrote:That's right. We keep track of whether it's an extension XHR so that
> On Thu, Dec 6, 2012 at 1:25 PM, Scott Hess <sh...@chromium.org> wrote:
>> Unfortunately, extensions can inject stuff into the page, so in the
>> limit we can't disable sync XHR for extensions.
>
> I don't believe this is true. Extensions get injected into an isolated
> world. In theory, they could cause existing code on the page to do a sync
> XHR if such code existed, but I think we could otherwise disallow it, which
> certainly is good enough.
we can give it the extension's privileges. Blocking sync XHR in
content scripts would be easy from a technical point of view (putting
aside the compatibility issues).
On Thu, Dec 6, 2012 at 6:12 PM, Adam Barth <aba...@chromium.org> wrote:
On Thu, Dec 6, 2012 at 1:28 PM, Ojan Vafai <oj...@google.com> wrote:That's right. We keep track of whether it's an extension XHR so that
> On Thu, Dec 6, 2012 at 1:25 PM, Scott Hess <sh...@chromium.org> wrote:
>> Unfortunately, extensions can inject stuff into the page, so in the
>> limit we can't disable sync XHR for extensions.
>
> I don't believe this is true. Extensions get injected into an isolated
> world. In theory, they could cause existing code on the page to do a sync
> XHR if such code existed, but I think we could otherwise disallow it, which
> certainly is good enough.
we can give it the extension's privileges. Blocking sync XHR in
content scripts would be easy from a technical point of view (putting
aside the compatibility issues).
What compat issues? Can't we just dictate that the next extension version requires it? So if you want goodies from the new APIs in a new extension version, you have to clean up your code?Death to sync XHRs.
Thank you all for your comments.
So do you have any preference for implementing client side timeout in Chromium or WebKit?
If you think client side timeout is a useful feature for chromium, then I can implement it in chromium.
Best Regards
James
I don’t mean sync XHR. I am NOT going to implement sync XHR timeout.
But for Async request client side timeout, should it be implemented in chromium side or webkit side? do you have any comments? Thanks
AFAIK, firefox doesn’t support Sync XHR timeout, but it supports Async XHR timeout.
And Opera also supports async XHR timeout. So I just want to implement Async XHR timeout firstly.
But my question is that in order to support async XHR timeout, do we need to add the timeout feature to HTTP network stack in chromium and then implement async XHR timeout, or just implement it in WebKit using current network stack?
I implemented this feature in webkit https://bugs.webkit.org/show_bug.cgi?id=103251
And abarth thought this should be in network stack. So I bring this discussion here.
there was the same discussion when implementing XHR2 timeout with soup in GTK and EFL port and at last they decided to implement it in webkit and not change libsoup.
https://bugzilla.gnome.org/show_bug.cgi?id=682804
some feedback from the developer of libsoup:
Dan Winship [libsoup developer] 2012-08-28 13:12:24 UTC
so, note that this would essentially boil down to g_timeout_add() +
soup_session_cancel_message(), and there's no reason webkit couldn't just do
that itself instead...
Dan Winship [libsoup developer] 2012-08-30 12:27:00 UTC
I guess it boils down to whether or not other apps are likely to need
per-message as opposed to per-session timeouts. And that doesn't seem like a
very common use case. So maybe it's better to just do it in WebKit.
Best Regards
James
http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute
and W3C spec also indicates that we should only support async XHR client timeout. No Sync XHR timeout should be supported.
Best Regards
James
From: Wei, James
Sent: Tuesday, December 11, 2012 8:40 AM
To: 'William Chan (陈智昌)'
Cc: Adam Barth; Ojan Vafai; Scott Hess; ojan+...@google.com; Eric Roman; chromi...@chromium.org
Subject: RE: [chromium-dev] about adding timeout support in network stack for XMLHttpRequest Level 2 timeout attribute
I don’t mean sync XHR. I am NOT going to implement sync XHR timeout.
But for Async request client side timeout, should it be implemented in chromium side or webkit side? do you have any comments? Thanks
Best Regards
Willchan, darin,
Thank you for your suggestion. I will discuss with adam how to do it better in WebKit. Thanks.