viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

Android crash while loading gltf #676

Open BMR11 opened 5 years ago

BMR11 commented 5 years ago

Environment

Please provide the following information about your environment:

  1. Development OS: Mac
  2. Device OS & Version: Android 9.0
  3. Version: ViroReact version: 2.14 and React Native version :0.59.3
  4. Device(s): Samsung Galaxy 9 edge

Description

I am trying to load a gltf animation using below code.

<Viro3DObject source={require("./res/gltf/mygltf.gltf")} resources={[ require("./res/gltf/mygltf.png"), require("./res/gltf/mygltf.bin"), ]} position={[12.2, -5.0, -2.1]} rotation={[0, -45, 0]} scale={[0.01, 0.01, 0.01]} type="GLTF" />

I verified gltf with https://github.khronos.org/glTF-Validator/ and https://gltf-viewer.donmccurdy.com/ and its working perfect there

But its crashing on android device with crash log https://gist.github.com/BMR11/487258f9a8f1df8c5384adf0e1cc101e

Reproducible Demo

Here is my gltf files https://drive.google.com/open?id=1DL1x12NHfuaeud1zteet69iZAUGysC9o to reproduce the issue

dthian commented 5 years ago

Hey @BMR11, we've identified the issue and patched a fix in the upcoming release.

BMR11 commented 5 years ago

Thank you for helping me

On Tuesday, July 30, 2019, Daniel Thian notifications@github.com wrote:

Hey @BMR11 https://github.com/BMR11, we've identified the issue and patched a fix in the upcoming release.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/viromedia/viro/issues/676?email_source=notifications&email_token=AAAYD6YEHGOBGS4ITIYRL5LQCC3HTA5CNFSM4IGALEHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3FONGI#issuecomment-516613785, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAYD64V3D3YTXQ3IWGXPPDQCC3HTANCNFSM4IGALEHA .

-- Thanks and regards, -BMR.

dthian commented 5 years ago

Hey @BMR11, this should've been fixed in the latest release of ViroReact. Please let us know if you have any issues with it.

BMR11 commented 5 years ago

Hey, Sorry for delay. I will give it a try and let you know. Thank you for fixing it :)

On Tue, Aug 20, 2019 at 1:30 PM Daniel Thian notifications@github.com wrote:

Hey @BMR11 https://github.com/BMR11, this should've been fixed in the latest release of ViroReact. Please let us know if you have any issues with it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/viromedia/viro/issues/676?email_source=notifications&email_token=AAAYD62RSWICJ7UDEODORF3QFRA45A5CNFSM4IGALEHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4XM6ZI#issuecomment-523161445, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAYD63W45N57HYPI3H3ST3QFRA45ANCNFSM4IGALEHA .

-- Thanks and regards, -BMR.

azhx commented 5 years ago

Hey @dthian I'm using the testbed app to load a glb file, and the same is happening.

<ViroARPlaneSelector>
    <Viro3DObject
        source={require('./res/mol.glb')}
        type="GLB"
        scale={[.1, .1, .1]}
        position={[0, -.1, 0]}/>
</ViroARPlaneSelector>
dthian commented 5 years ago

Interesting, is it a different model than the one provided above? if so, could you provide both the model, and the crash logs?

azhx commented 5 years ago

not sure how to access the logs, could you give some guidance on that? After selecting a plane, the screen freezes, then flashes white, and I'm back to the home screen of the testbed app.

Here's the glb model and the gltf model (with all necessary info) that it was converted from debug.zip

azhx commented 5 years ago

Worth noting, loading the model from #551 at the uri works fine, and that is a glb, this should be an issue with the model. However, this model loads fine on my viewer (Windows 3D Viewer) and is valid asset according to Khronos' validation tool.

dthian commented 5 years ago

So both the original 3D model in this issue, and the model at #551 are not the same model as you've provided (mol.glb).

It might be an issue with the model (sketch fab is not able to render it as well). Upon further inspection, it looks like there's no tangents specified in the model. And because the model has no texture data, we are not able to generate one (texture data is needed).

Is it possible to regenerate your model with tangential vertex data?

azhx commented 5 years ago

Hmm, I'm not an expert on 3D file formats. What would be an example of a model with tangential vertex data, and where would it be located in the gltf file?

This model was generated programmatically from a collada file (.dae). Is there an inherent problem here with missing information, or is there a potential workaround by inferring data, because the model is loadable on 3D model viewers after all. thanks for your help

azhx commented 5 years ago

Ok, here is another model I generated. This time, it doesn't crash: it just doesn't appear... mod.zip

dthian commented 5 years ago

There may be a potential workaround by inferring the data, but it probably depends on the renderers you are using. For example, the model doesn't seem to be rendering on SketchFab, while it is rendering on Windows 3D viewer.

The best bet would be to work with your modeler and generate the tangents on whatever 3D modeling tool used to create the model (it might be exporting the model without it). To verify, simply view the gltf file and it should have a "TANGENT" within the primitives of the model.

azhx commented 5 years ago

To be clear, is this in reference to mod.zip or debug.zip?

dthian commented 5 years ago

I believe that is in reference to both (as both will have issues rendering without tangential data).

The additional crashing behavior on debug.zip is worrisome, but i'm not sure if that's an issue that is compounded due to the missing tangents. Irregardless, I'll file a bug to take a look at the crash, separate from the tangent issues.

Ideally, you can test by generating the tangents for mod.zip, and once that works you can do so for debug.zip and see if the crash occurs (please provide us the debug.zip model once you have also generated tangents for that, as it would be useful).

azhx commented 5 years ago

I'm at a loss of how I would go about generating the tangential vertex data: the models i've provided were generated through the Collada2GLTF converter.

Even in the couch model in #511, there was no TANGENT field within the primitives, yet it loaded perfectly everywhere.

Attached dae below, which I believe does not contain the tangential vertex data either, but just to be sure. dae.zip

Thanks again

dthian commented 5 years ago

I'm at a loss of how I would go about generating the tangential vertex data: the models i've provided were generated through the Collada2GLTF converter.

As previously mentioned - have you tried working with your 3D modeler to see if there's an option to ensure your collada model contains the tangential data? For example, AutoDesk has options you can enable to pull these sets of data over.

Even in the couch model in #511, there was no TANGENT field within the primitives, yet it loaded perfectly everywhere.

There's no readable couch model (only a glb) in the link, or the 551 link. Did you mean the teabox model? As previously mentioned - we can attempt a re-generation of tangential data automatically if a texture is provided together with normal and positional data, but your model does not have one for us to use. However, in the TeaBox case, all the requirements are provided.

azhx commented 5 years ago

As previously mentioned - have you tried working with your 3D modeler to see if there's an option to ensure your collada model contains the tangential data? For example, AutoDesk has options you can enable to pull these sets of data over.

Alright, after importing into blender, i found that the scale on all of the objects was 0. After scaling them to 1, and exporting suddenly the object works properly. I haven't tried loading the model into viro yet, but here is the file, which now renders on sketchfab. I have no clue how this scale is defined in the gltf file, but I nowhere did i explicitly export 'tangential vertex data' FILE

There's no readable couch model (only a glb) in the link, or the 551 link.

Oh yeah, for that one I unpacked the glb myself and took a look, is what I meant.

BMR11 commented 5 years ago

Hey @BMR11, this should've been fixed in the latest release of ViroReact. Please let us know if you have any issues with it.

Hi @dthian , I just tried yesterday with updated 2.16.0 but still its crashing. Do I need to do anything special with new update?

dthian commented 5 years ago

Hey @BMR11, that's strange, I was able to verify that the TRex model does not crash with the updated Viro 2.16.0. Did you follow the update instructions when updating your ViroReact?

If it helps, I also noticed that both your .bin and .gltf files are have the same name. Try renaming your mytrex.gltf to something different. (This is because of a limitation within React Native).

BMR11 commented 5 years ago

Thanks dthian and really appreciate your efforts Then I think I need to recheck again. What I did to update to 2.16.0 were below steps

Update your react-viro package version to 2.16.0
Delete the node_modules.
Run npm install to install the updated versions.

Do I need to link again and install the app again in case 2.16.0 having native code changes.

Also I will try with diff names and let you know.

BMR11 commented 5 years ago

@dthian , Thanks as now I can see my 3D gltf model rendered properly. But its not animating even if adding animation={{ name: "Take 001", run: true, loop: true }}

dthian commented 5 years ago

Hey @BMR11, have you verified that your model contains the "Take 001" animation? If you are not sure, please work with your 3D modeler to confirm what animations exists for that model. Thanks!

BMR11 commented 5 years ago

Thanks @dthian, I will surely check for that. Earlier I was having vrx version of this model and it was working with animation={{ name: "Take 001", run: true, loop: true }} But the problem with that was that like it was not applying material/texture on it and so I switched to gltf one.

azhx commented 5 years ago

Hi @dthian, Now i have a working gltf file that has loaded, but loading it into viro, it is shown as fully white. However, every online viewer shows its colors. Is there something simple that I'm missing?