question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firefox fails to inflate gzipped resource for loader

See original GitHub issue

I am not sure if this is a bug in three.js or Firefox, but EXRLoader seems to fail under the following conditions. I have not been able to confirm if this happens with other loaders.

  • Firefox
  • EXRLoader
  • Firebase hosted resource served with Content-Encoding: gzip
Cannot parse value for unsupported type: �i"]���w���t ...

It seems like the gzipped content is never inflated/decoded by the browser, as this ugly workaround seems to do the trick:

import * as THREE from 'three';
import { EXRLoader as NativeEXRLoader } from 'three/examples/jsm/loaders/EXRLoader.js';
import pako from 'pako';

export class EXRLoader extends NativeEXRLoader {
	constructor(){
		super();
	}
	load(
		url: string,
		onLoad: ( dataTexture: THREE.DataTexture ) => void,
		onProgress?: ( event: ProgressEvent ) => void,
		onError?: ( event: ErrorEvent ) => void
	): void {
	    const loader = new THREE.FileLoader();
	    loader.setResponseType( 'arraybuffer' );
	    loader.load( url, ( arraybuffer ) => {
		    const fileReader = new FileReader();
		    fileReader.onload = (event) => {
				super.load((event as any).target.result, onLoad, onProgress, onError);
		    }
		    let blob: Blob;
		    try {
		    	blob = new Blob([pako.inflate(arraybuffer as any)]);
		    	console.log('Inflated blob size: '+blob.size);
		    } catch(error) {
		    	blob = new Blob([arraybuffer]);
		    }
		    fileReader.readAsDataURL(blob);
	    }, onProgress, onError );
	}
}

The ‘Accept-Encoding’ header is set automatically by the browser (and cannot be overridden in XMLHttpRequest nor in Axios), so I would assume it was the browsers job do decode it. But Firefox does not decode the content neither as an img.src (maybe because FF doesn’t know .exr) nor if responseType is set to blob or arraybuffer. Safari and Chrome are unaffected.

I’ve seen some old issues on the Firefox bugtracker, but I am unsure what is expected behavior.

EDIT: The XHR spec suggests setting Range: bytes=0 header should force Accept-Encoding: identity, but it seems to make no difference.

Three.js version
  • r107
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • macOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bovesancommented, Oct 1, 2019

We all believed this to be a pure browser issue, but I am having problem replicating this in an isolated test: https://bovesan.com/misc/content-encoding/

Unfortunately, my mac is in for service right now, so I am unable to run the test on the same machine as where I first encountered this. Due to this, I have not filed a Mozilla bug yet.

0reactions
mrdoobcommented, Oct 3, 2019

@tochoromero Could you please help us by filing a bug to Mozilla and sharing the link here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gzip-encoding does not work | Firefox Support Forum
For some reason there are some problems with the encoding of internet-files resulting in not loading the particular files.
Read more >
How do I fix "content encoding error" | Firefox Support Forum
Press and hold Shift and left-click the Reload button. · Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux) ·...
Read more >
152275 - [FIX]saved files with GZIP encoding are not ungziped ...
This is running under a personal webserver I wrote. I know it works mostly because WGET will not specify GZIP encoding and the...
Read more >
Certain Pages will not load (Amazon, Youtube etc,)
Hello, I am a new user of Firefox, I switched from Chrome. I am having problems loading certain pages that work on other...
Read more >
Accept-encoding: deflate unsupported, but requested
Tried with w3m everything worked fine. Mozilla worked only right with the gzip compressed version. You can see the problem on my testpage:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found