Loader.contentLoaderInfo not updating properly on cross-domain requests

This is a Flash problem that is incredibly frustrating – partly because it is completely undocumented in the AS documentation, and partly because once you know what the problem is, it is suddenly very easy to search for.

On cross-domain requests using flash.display.Loader, the contentLoaderInfo.bytesLoaded and contentLoaderInfo.bytesTotal were returning garbage, breaking my fancy loading progress bar. Completion events were firing correctly, so the app was still working, however we’re talking about 5-8 MB of data, and nobody wants to stare at a blank progress bar.

And, of course, it was only happening on the production platform – the one with the separate App, Static and DB servers.

After mucking around with SecurityDomains, crossdomain.xml tweaks and other things, it turns out that Flash (at least up to version 11) chokes completely when loading from external URLs, when the response is GZip encoded. Luckily, the code was loading already-compressed JPG, PNG and SWF files, for which the benefit of GZip is negligible at best.

A quick update to  our static media server’s httpd.conf to exclude .swf files from being deflated:

# Don't compress images or flash

SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|swf)$ no-gzip dont-vary

and all is right in the world.

The frustration is that searching for “cross domain contentLoader.bytesloaded fail” and various permutations retrieves zero relevant results. Once you suspect it’s GZip causing the problems the results come thick and fast.

Leave a Reply

Your email address will not be published. Required fields are marked *