-
-
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
Loaders - ObjectLoaders and other example loaders giving TypeError in react-native #23015
Comments
See #23011 (comment). This is related to a regression made in r134. |
Like I mentioned in #22510 I'd think it should be possible to skip using the stream reader if it's not supported in the environment. Something like this at the beginning of the initial if ( typeof ReadableStream === 'undefined' || response.body.getReader === undefined ) {
// cannot support onProgress callbacks
return response;
}
// otherwise the readable streams and onProgress callbacks are supported It would be best if someone who's familiar with the environments where it's failing can make the PR and test to ensure the proposed solution works. |
Awesome. I'll dig around and see if I can get a PR up or at least a test case to work with. |
Seems this is a deeper issue -- }).then(stream => {
const response = new Response(stream);
switch (this.responseType) {
case 'arraybuffer':
return response.arrayBuffer();
case 'blob':
return response.blob(); Is there a way we could gracefully fallback to Maybe we should continue in another issue if this needs more eyes. |
Which fetch polyfill is being used? At this point I'd submit an issue / fix to the polyfill library. In the Github polyfill, for example, ReadableStreams are a lot newer but with the fetch API being stable for 6 years now I don't think I support addressing this in three.js. I feel if libraries are going to enable running browser code in non browser contexts then they need to support long stable and commonly used browser features. |
I tested on react-native to see if it would resolve this issue, and that uses the Github polyfill. I think that's something for react-native to fix themselves if they're going to try to support
I don't understand. Wasn't |
I'm just suggesting that I don't think it's reasonable to expect three to hold on to such long outdated APIs because react native doesn't support them but that's just my opinion. If even basic fetch features such as I don't know exactly how react native works but as a workaround I'd expect you can override the global fetch polyfill with your own that implements whats needed in the mean time. Or you could override |
Is react-native is just pertinent to this issue, but if there's no easy solution, then people can revert to r133. |
I feel what I've said is being twisted. I'm not advocating for alienating users... I'm advocating for this being fixed in the right location which I think is pretty clearly the polyfill or react-native. Can you help me understand why you're so resistent to getting it fixed there? The React Native docs even recommend referencing the MDN docs on fetch for how to use it so it seems like a clear bug if If XMLHttpRequest support is going to be readded then I'd think we should just revert the FileLoader fetch change and not maintain two code paths. |
I didn't mean to suggest that, but it doesn't feel right to send these people elsewhere without exhausting our options. I thought this was an unnecessary breaking change that was only causing problems for native and older platforms, so I wanted to inquire about the motivations for the change and if we could improve support. As for issues,
I was hoping this wouldn't be a hassle, but if it is, then I think this is something that can live in |
I think it's more accurate to say that three.js made a change that exposed a bug in react-native / the polyfill. In terms of the benefits of the change the fetch implementation simplified the handling of data URIs in the FileLoader, is easier to follow, and personally I'd like to see Loaders take a set of fetch options in the future considering how much more ergonomic they are.
Have you created an issue for react-native, then? Again this is clearly a shortcoming of these other packages and limits the broader js ecosystems ability to leverage stable, modern APIs. Asking libraries to stall modernization to support workarounds for issues in other packages with no plan or effort to alleviate it is hard to support.
What I'm really asking for is for some effort to be made to fix the fetch polyfill and react native here instead of expecting three.js to revert because it's the easy way out. I think instead this effort is best spent making a PR for github fetch to fix the And to be clear -- like I've said before -- this ultimately isn't up to me but these are my opinions. |
If I've already outlined WIP solutions and community implementations for react-native users to leverage For Node users, I'm unsure whether more work is needed than #23015 (comment) and if similar problems will arise there, so I'll have to leave this to someone more knowledgeable. If Node isn't a platform that three supports, then this can move to |
That said, we try make a node integration easier with PRs like #10732 or #14914 but only if the changes do not affect the code base too much. In this particular case, the issue needs to be solved elsewhere like mentioned in #23015 (comment). |
I use it in web, i don't use it in react-native.I personally think that it should be fixed and it is unreasonable for users to go back to the 133 version. |
@neciszhang What exactly doesn't work when using it in web? |
I'm unfamiliar with the Alipay web browser but is it possible that the response does not have a console.log( typeof ReadableStream, response.body ); #23032 would have fixed this for the case where |
[TypeError: undefined is not an object (evaluating ‘response.body.getReader’)]
Above error is produced when load function of any loader ( like GLTFLoader or ObjectLoader ) is called.
Platforms tested on:
Mobile - iPhone
OS: iOS, MacOS
Three.js version 0.135.0
expo-three version 6.0.1
expo-gl version 11.0.3
expo version 43.0.2
react version 17.0.1
react-native version 0.64.3
Sample Code:
Error : [TypeError: undefined is not an object (evaluating ‘response.body.getReader’)]
The text was updated successfully, but these errors were encountered: