You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dave Rolsky <au...@urth.org> on 2002/10/24 00:55:05 UTC

Random broken images when generating dynamic images

So here's the situation.

I have some code that generates images dynamically.  It works, mostly.

Sometimes the image will show up as a broken image in the browser.  If I
reload the page once or twice, the image comes up fine.

On a page with 5 different dynamic images (all generated by the same chunk
of code, it's a set of graphs), I'll often see 1 or 2 as a broken image,
but the rest work.  Sometimes all 5 are ok.

I tried out a scheme of writing them to disk with dynamically generated
files, but since I still need to do some auth checking, they end up being
served dynamically and I have the same problem.

To make it even weirder, I just took a look at one of the image files that
showed up as broken, and it's fine (I can't view it directly in my
browser).

I can't for the life of me figure out what the heck is going on.  It seems
that the image data is just fine.  Could the browser be timing out for
some reason?

This has been seen in multiple browsers too (Galeon and IE, at least) so
it's not browser-specific.

I'd love to fix the root cause, but a workaround would be fine too.  The
fundamental problem is that there's no way to not have some code involved
in this process because there needs to be some auth checking before the
image is served.

Any help would be much appreciated.


-dave

/*==================
www.urth.org
we await the New Sun
==================*/


Re: Random broken images when generating dynamic images

Posted by Dave Rolsky <au...@urth.org>.
On Thu, 24 Oct 2002, Paolo Campanella wrote:

> > On a page with 5 different dynamic images (all generated by the same
> > chunk of code, it's a set of graphs), I'll often see 1 or 2 as a broken
> > image, but the rest work.  Sometimes all 5 are ok.
>
> Unlikely to be your problem, but I had something similar once when
> running too few backend mod_perl httpds on a development box.

I don't think this is it because I've seen this when testing on a system
with plenty of backend httpds (MaxClients at 50 or so).


-dave

/*==================
www.urth.org
we await the New Sun
==================*/


Re: Random broken images when generating dynamic images

Posted by Paolo Campanella <pa...@mighty.co.za>.
On Wed, 23 Oct 2002 17:55:05 -0500 (CDT)
Dave Rolsky <au...@urth.org> wrote:

> On a page with 5 different dynamic images (all generated by the same
> chunk of code, it's a set of graphs), I'll often see 1 or 2 as a broken
> image, but the rest work.  Sometimes all 5 are ok.

Unlikely to be your problem, but I had something similar once when
running too few backend mod_perl httpds on a development box.


Bye

Paolo


Re: Random broken images when generating dynamic images

Posted by Ed <en...@fldna.net>.
On Wed, Oct 23, 2002 at 05:55:05PM -0500, Dave Rolsky wrote:
> So here's the situation.
> 
> I have some code that generates images dynamically.  It works, mostly.
> 
> Sometimes the image will show up as a broken image in the browser.  If I
> reload the page once or twice, the image comes up fine.
> 
> On a page with 5 different dynamic images (all generated by the same chunk
> of code, it's a set of graphs), I'll often see 1 or 2 as a broken image,
> but the rest work.  Sometimes all 5 are ok.
> 
> I tried out a scheme of writing them to disk with dynamically generated
> files, but since I still need to do some auth checking, they end up being
> served dynamically and I have the same problem.
> 
> To make it even weirder, I just took a look at one of the image files that
> showed up as broken, and it's fine (I can't view it directly in my
> browser).

I've seen the problem before.  My solution was to save the dynamic images
on disk and serve them just like plain 'ol static files from the front-end
server. This way everything is served from the same "Keep-Alive" request.
And apache does all the http/1.1 headers/chunked-encoding for me.

Your MaxKeepAliveRequests would then be the culprit on your end but not likely
unless its set really low.  I'm not sure how the browser determines the
equivalent limit. tcpdump showed that opera created a second keep-alive
request after 10 images for me (could be limiting on bytes rather than
requests ... don't know).

You can still serve dynamicly and handle the custom auth w/ the backend and
maintain the clients keep-alive.  The current mod_proxy will maintain the
clients keep-alive eventhough your backend has keepalive off.  Be sure
all the required http/1.1 components/headers are sent to maintain a
keep-alive.

I'm interested in what you finally work out.

thanks,
Ed

Re: Random broken images when generating dynamic images

Posted by Dave Rolsky <au...@urth.org>.
On Wed, 23 Oct 2002, Dave Rolsky wrote:

> I have some code that generates images dynamically.  It works, mostly.
>
> Sometimes the image will show up as a broken image in the browser.  If I
> reload the page once or twice, the image comes up fine.

I should mention that I'm using Mason, and I haven't yet tried playing
with a non-Mason based solution, but I am making sure to clear Mason's
buffers before serving the image, and I abort the (Mason) request
immediately after the image data is sent, so I don't think Mason is
causing the problem.


-dave

/*==================
www.urth.org
we await the New Sun
==================*/