-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of blob responseType in ImageLoader. #9826
Comments
Is the problem you are getting a Cross-Origin error? The Image/Texture loader works using a blob for onProgress events, as implemented here: |
It's not quite a cross-origin error, because loading an image from another domain works well. It is when I try to load the image from a script in the local filesystem I get that the onProgress event might not work if using Proposal is that this could be a configurable parameter of the |
Yes please! 😊 |
…der and TextureLoader. Added constants for ResponseType.Blob and ResponseType.ArrayBuffer. Implemented arraybuffer response parsing in ImageLoader.
I tried the |
Are you teaching the students to load chrome using |
Firing up a local web server is trivial: https://gist.github.com/willurd/5720255 |
No. Just open the HTML file in the browser. Yes, the
Not for everyone. |
Hmm... I worry that this workaround may stop working eventually. In my experience, is not good to "fight" around browsers... Also, Chrome's #2 starred bug is about this: https://bugs.chromium.org/p/chromium/issues/detail?id=47416 Until they address that, I think I would suggest using Firefox instead. |
Yeah, you are probably right that it won't last forever. But the Chrome's bug is not actually about this. I am not trying to load any local files, but cross-origin files from a web server and that works nicely with the What I ended up doing was I commented out the There is also that browser caching to check out. I saw that you closed the other issue. I was wondering about that, does the Three.js cache work after a texture has been loaded? So if one were to enable the cache and then load many big and same textures as blobs, then Chrome would still send many requests for them? |
Description of the problem
The
ImageLoader
sets the response type ofXHRLoader
toblob
. This causes a problem with Chrome (53.0.2785.116 m) and running the script from the local filesystem, while fetching textures from a web server. It seems to me that this is a security consideration of Chrome. The closest info I found is this, but that does not seem exactly about that. In Firefox (49.0.1) there is no issue.For me this functionality is important, because I'm using Three.js to teach CG and the students should not worry about web servers. Also I'd guess there are people, who want to prototype some things with Three.js and not set up a web server to do that.
I made the
responseType
to be a parameter of theImageLoader
(and theTextureLoader
) and witharraybuffer
type there is no problem: see image.The top row uses the r80 implementation with
blob
and the bottom row usesarraybuffer
response type. With thearraybuffer
I base64 encode it and set it as a data URL to the image.You can also see that actually the
arraybuffer
seems a lot faster then theblob
implementation. This seems to be that for some reason Chrome knows how to cache the former, but not the latter.If the script is in a web server: see image.
With no caching the
arraybuffer
seems marginally faster with the texture I used: see image.Live example (download the file, the modified lib and open it from the local filesystem to see errors):
http://tume-maailm.pri.ee/ylikool/ComputerGraphics-2015/other/uv-test/index-loadingTest.html
The no-cache version:
http://tume-maailm.pri.ee/ylikool/ComputerGraphics-2015/other/uv-test/index-loadingTest-noCache.html
I did this with r80, but r81 seems to have the same issue.
Should I create a fork and PR with the
responseType
as a configurable value of theTextureLoader
andImageLoader
?Might also be related to #9824, as, like I noticed, the request with
blob
response type does not cache the response in Chrome. So it will send new requests until the first one gets back and Three.js' own cache kicks in (maybe?).Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)
No special requirements.
The text was updated successfully, but these errors were encountered: