-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
React Native - glb/gltf model works in emulator/usb connected device but fails in android apk #2577
Comments
Any information about this? :/ |
I get the same exact error. 'Could not load ...' > I think it has to do with an error with loading the glb models on native (obv)... Maybe it's an issue with react-native version, or another package version. Have you found a solution on your end? |
Hey! Unfortunately not yet, I have tried different approaches of loading the model but didnt work. If I find out a workaround or something else I'll write here. If you get this to work, please share aswell :( |
@CodyJasonBennett I saw that you added some tags to it! Thanks for noticing! :) |
I haven't looked much into this specific case, but having |
@CodyJasonBennett So instead of require we should use another way of importing the gltf file like 'expo-asset'? If not could you point me in the right direction? |
I have tried with import, require, expo-asset, .. but couldn't make it work :/ It seems that the apk itself can't find the model in its filesystem. Only when its running in debug mode via usb |
Same here, another alternative is to use Babylon JS Native, but that comes with it's own set of challenges. I'll try it this week |
I meant to move the require/import to top-level rather than function body. I'll have to take a closer look when I get the chance. As an aside, what challenges are you facing with Babylon Native? There is some overlap since a lot of issues depend on downstream fixes in react-native, some might be quicker to make use of there than here and vice versa. |
Came here from this discussion to say that I face the same issue with iOS: I get the model to render in development on device, and it crashes when push it to production (with eas update and Expo Go).
|
The main challenge is that in Babylon it forces you use a bare workflow vs a managed workflow. To integrate is a little different as the library uses different dependencies. It shouldn't be too bad and should be okay, but it's an inconvenience. I'll try to implement the 3d model with babylon this week |
So it works in production with the model from the example but fails when you change to another one? |
@dpsilvaa97 yes, exactly, and I could not find any other model that works, not even a simple cube exported from blended without textures, but I know nothing about 3D, maybe I'm missing something |
I tried the example with same package versions in Android and get error in apk file, still works in simulator/expo. |
@carmenchapa @dpsilvaa97 I actually found a workaround. I think there is a bug somewhere with the loading of the assets somehow @CodyJasonBennett, but I was able to load the model with a custom function. I found this custom function somewhere in another discussion. Here ->> expo/expo-three#273 This function will return your gltf model. You can use require('..path') for asset prop. I tested and works with expo & apk 😄
|
Awesome. We do a light progressive polyfill in react-three-fiber/packages/fiber/src/native/polyfills.ts Lines 1 to 141 in bf66f08
Perhaps there's something going wrong with our usage or in loaders' |
@asalaza6 how do you use the function? and what do you pass for onAssetRequested?
gives me an error |
@carmenchapa onAssetRequested is an optional field, just a callback function after. Your code looks fine to me. I am not sure what's causing your issue. I'll just send you this screenshot snippet. The file prop is a require('..path') |
Are you using |
Im using from this import: |
Hmm I'm not sure. It's really finnicky, I'm thinking maybe package versions, or implementation is a bit different. I'm not sure. How are you testing? Also make sure you're still using the native packages for other things like canvas, etc.. |
Can you try with |
@dpsilvaa97 hmmm i get you, your packages can start to add up, here are my package versions if that's helpful |
Alright!! The model appeared and it works in the apk aswell !! <3 Amazing guys thanks for the support and knowledge sharing! |
Awesome! That's good. |
Does anyone has a suggestion about this? In my previous solution that didnt work with the apk I was using useGLTF which returns "nodes". With that I could get access to the bones and the hand components. With this loader the "nodes" is undefined. So far I could get the bones with this approach. But How do I get the Hand's geometry and skeleton to use in the SkinnedMesh? |
hey, thanks all for your sharings.
edit: there was a mistake in my code, forgot to remove one type annotation (I'm testing with plain js), the promise was never called. My apologies This worked for me too! Uploaded the app with eas update and I can see the model in prod now 🎉 |
Hey @dpsilvaa97, did you find a solution for getting the nodes already? |
You can get nodes etc from |
Heyy! I solved by using the traverse function on the scene.
Hope it helps! :) |
This worked for me. Thanks! |
@CodyJasonBennett should this issue be closed? |
Brother can you provide the file decode function and resolve async i will be thankyou to you . I am not able to load the model in react native so that why i need your help. |
@farmketprocess you can take a look at the code posted by @carmenchapa's on this issue #2643 |
I've implemented patches for missing APIs in #2982 with fixes for Android APK. Codesandbox CI creates preview builds if you want to try ahead of release. I'll try to get this out shortly. // package.json
{
"dependencies": {
"@react-three/fiber": "https://pkg.csb.dev/pmndrs/react-three-fiber/commit/0772cfaa/@react-three/fiber"
}
} |
So my problem is when I try to run the app in my device using the apk without being connected via usb debugging. Im using android. It works fine when using emulators even with the same version of my android, etc.. but it fails outside this env.
This is the code sample:
This works pretty well in the emulator or when my device is connected via usb debugging. But when I unplug my phone or try to install and run the apk this is what happens:
I believe it could be happening due to the different file systems. I have seen that the models are stored in \android\app\src\main\res\raw with the correct extension, which is '.glb' in this case, when I run the commands to generate the apk. It seems ok but for some reason it cant be found I believe.
I tried to change the code in terms of how to get the image.
With this attempt, it stills works fine in the emulator/usb but it fails in the apk in my device. But the error is the following one:
Any suggestion?
The text was updated successfully, but these errors were encountered: