

iOS6 breaks long polling - mmastrac
http://www.realsoftwareblog.com/2012/09/ios-6-mobile-safari-web-applications.html

======
pilif
I'm using long polling in our application and I don't see that one connection
per server restriction here.

I did however see that safari was not leaving the loading state (and thus not
firing any of the loaded events, nor hiding the URL bar) if I started the long
polling connection before the page was fully loaded.

Once I moved opening the connection to a setTimeout callback inside the onLoad
handler (so not DOM ready, but actual load), this went away and the page works
normally.

~~~
codeka
Now this makes sense. As I said below, it seems really strange that this would
go unnoticed, especially since one-connection-per-domain affects _all_ sites
and not just ones doing long polling.

Still a pretty bad bug, though.

------
saurik
Someone at Apple is going "we have had iOS 6 in beta for months now; is this
really the first time anyone noticed this issue?".

~~~
Joeri
Most web developers use a windows or linux machine to develop and a physical
device to test (myself included). That combination prevents you from running
the iOS 6 beta, because you need a mac for that. So, only a minority of web
developers (those with access to a mac) actually could have tested the iOS 6
beta.

Additionally, the first iOS 6 betas had the browser in such a bad shape that
it was obvious they were still working on it. I took one look at it and
figured "i'll test it when they're done". They need to have some sort of clear
indication of when it's actually ready for testing (and not just for testing
of the native SDK's).

~~~
taligent
>Most web developers use a windows or linux machine to develop and a physical
device to test.

Maybe I am living in a bubble but every single web developer I have ever met
used a Mac. Why ? Because it is the only platform that has Photoshop + a UNIX
shell.

~~~
Anderkent
Not every web developer is a designer.

Also, cygwin.

~~~
taligent
But most web designers would be slicing PSDs at some point, right ?

And Cygwin is a joke. Dealing with the page separator differences alone would
make it unbearable.

~~~
moreati
I believe Aderkent meant that many web developers who are not designers (e.g.
me) have no need of Photoshop - so we don't use a Mac.

~~~
esolyt
By the way, Gimp can open psd files. I'm not sure it works perfect though.

------
garindra
I might be wrong here, but if you're using long polling in your webapp,
shouldn't you be using a randomized wildcard subdomain anyways? For example,
Quora uses #.tch.quora.com as their long polling hostname, with the #-part
randomized for each of the browser tab, which effectively allows for an
unlimited number of concurrent connections to a single IP address.

I mean, even though Chrome allows 6+ concurrent connections to a single
hostname, nothing's stopping users from opening 10 tabs of your application.

~~~
dwj
I think you might be wrong here :)

I've no idea why Quora does that, but I'm pretty sure it's not a standard
thing. You really should only being doing one long poll at a time, so it
should never be an issue.

------
buddydvd
Another connection related issue is that iOS 6 cache responses of ajax POST
requests. <http://news.ycombinator.com/item?id=4550441>

~~~
steve8918
I submitted that post, so I have some vested interest in this. I came across
this bug because I was converting one of my web apps to use the new iOS 6
feature of being able to upload photos from your Camera Roll to a web site.

However, when you upload a picture, apparently, they are all called image.jpg.
Since the image name never changed, every time I uploaded a new pic, the first
pic was being returned. I couldn't understand why, and as usual, stackoverflow
had a good answer for me. I needed to add a timestamp option to my URL in
order to work around this behavior.

------
codeka
This is very strange...

If the browser only opens one connection to a domain at once, it should have
made so many sites much slower to load and it's hard to believe Apple don't
have automated tests to check for performance regressions like that.

~~~
bathat
> ... it's hard to believe Apple don't have automated tests to check for
> performance regressions like that.

Well, I mean, this is the same company that has received "some press" recently
regarding the latest version of its mapping application.

Edit: That was a low blow, wasn't it?

------
username
Time to break out the gifsockets.

<https://github.com/videlalvaro/gifsockets>

~~~
halter73
Funny, but a one connection at a time restriction would break gifsockets just
like long polling.

~~~
old_sound
Dude, the gifsockets example "uses one connection at a time" because I'm too
lazy to implement a server using Netty or Aleph in Clojure. The only important
part from the gifsockets concept is writing gif frames on demand. The rest is
up to you

~~~
shawnz
gifsockets is just a niche implementation of long polling. They work the same
way.

~~~
old_sound
Ups… I read the wrong thing then. I thought the guy was referring to the
sample gifsockets app that now supports only one connection at a time.
Cheerio!

------
atotic
I believe the restriction is "only single keep-alive connection". This makes
sense to me, no need for multiple overhead if one connection will saturate
your bandwidth. It will open multiple if the server does not support keep-
alive.

Workaround is easy: make sure your long-polling connection is not keep-alive
connection.

~~~
dwj
That doesn't seem like a sensible solution. You're basically hurting
performance on all other platforms just to work around one of Apple's bugs.

------
dudus
He claims that it doesn't happen on Chrome for iOS.

But isn't chrome for iOS just a "skin" with new features on top of the same
safari browser?

One issue like I would expect to affect Chrome as well.

~~~
tdrd
Chrome on iOS uses safari's layout engine (because Apple doesn't allow dynamic
code generation) but the network stack is Chrome's.

------
mh-
definitely a bug. most browsers, going back a decade, support 4-8+ concurrent
connections to a given host (hostname, really).

~~~
taligent
Not necessarily.

While your desktop can handle 8 connections the 3G connection can't.

~~~
gmaslov
A TCP connection costs nothing if it's merely open and waiting. OK, it costs a
few bytes of space in some tables somewhere, but no actual bandwidth.

------
laacz
I'm not sure, why should someone rely on long polling alone. Default fallback
mechanism is websockets (supported on iOS), long polling (not supported
anymore, obviously) and then follows separate ajax calls. It is not uncommon
that something in this sequence would break by design, unsupportedness or bad
data connection, so fallback should be used.

------
MatthewPhillips
iOS supports Server Sent Events, which is what should be used in this type of
situation:

<http://mobilehtml5.org/>

~~~
bobfunk
I have a small hosted service in beta, making it dead easy to push events via
Server Sent Events (with fallbacks).

<http://www.eventsourcehq.com/>

It's fully open source and can be self hosted as well:

<https://github.com/eshq/eventsource-broker>

------
TazeTSchnitzel
Well, iOS 6 has websocket. Visit <http://ajf.me/websocket> and see for
yourself.

Since everything will be moving to websocket eventually, might as well get a
head start on iOS.

~~~
pornel
Unfortunately, it won't solve the problem for all iOS users. For example the
WebSocket protocol is blocked on most UK 3G networks (e.g. O2's censorship
proxy only handles real HTTP traffic)

~~~
the_mitsuhiko
Just encrypt the traffic.

~~~
TazeTSchnitzel
Yeah. wss: is a thing.

------
Mythbusters
Quality control is for the wimps

