We have javascript that loads images on demand. The script is the usual
form:
var image = new Image()
image.onload = myOnLoad
image.onerror = myOnError
image.src = imageUrl
(i.e. nothing exciting at all)
The problem is that the image, which is built on the fly, sometimes
fails (about 2%) to fire the onerror method, well after our packet
sniffer shows that all the bytes have arrived. We just never get an
onerror() call at all for these images.
Here are the headers for a request that fails:
null: HTTP/1.1 200 OK
Date: Sat, 08 Oct 2005 04:08:23 GMT
Server: Resin/3.0.14
Content-Type: image/gif
Transfer-Encoding: chunked
Via: 1.1 rl1 (Redline Networks Enterprise Application Processor - E|X
4.1.25 0)
Cache-Control: no-store
I am wondering if the problem is with "Transfer-Encoding: chunked", and
if we need to pad our generated image with some bytes to tell IE that
the image has finished!
roby2358@yahoo.com - 08 Oct 2005 05:37 GMT
Darn... typo... it never fires the "onload" method. Not firing
"onerror" is bad, but not firing "onload" is much, much worse.
Sorry about that.
roby2358@yahoo.com - 08 Oct 2005 15:23 GMT
...right now my favorite theory is that the "chunked" transfer encoding
is failing for certain magic numbers of bytes. One generated image that
fails is 114,683 bytes. If we use a different tool to generate the
image, the file size is different and the "onload" fires just fine.
I'll play with that... maybe specifying the Content-Length and getting
away from "chunked" will fix it. Otherwise, maybe we can identify some
of those "magic numbers" and pad the generated image with zeros to
avoid them.
roby2358@yahoo.com - 13 Oct 2005 01:08 GMT
(bump) sorry... anyone have any thoughts? We've been contemplating some
hideous work-arounds to try to reduce the problem, and I'd appreciate
any input.