GLTFUtility icon indicating copy to clipboard operation
GLTFUtility copied to clipboard

Can not load .glb file on Android device.

Open wangyanmeego opened this issue 4 years ago • 16 comments

I put my .glb files on http server, and download on android's Application.persistentPath. the file can download and store successfully, but when l use GLTFComponent.load to load the glb file, but it doesn't show anything. I have testted it successfully in unity editor. I also switch to other plugins, GLTFUtility and glFast, it occur the same proplem. So, if any one can help me, I'll be very appreciae.

wangyanmeego avatar Nov 23 '20 10:11 wangyanmeego

are you sure the object is just not loading outside of camera view? have you tried attaching a debugger to the device and seeing if it outputs any errors?

Siccity avatar Nov 23 '20 15:11 Siccity

Thanks for your reply. After some tries with UnityGLTF, i have successed loading glb file on android device.

wangyanmeego avatar Nov 24 '20 07:11 wangyanmeego

Thanks for your reply. After some tries with UnityGLTF, i have successed loading glb file on android device.

@wangyanmeego : can you please share how you solved your issue? other people might have similar problem and need information on how to solve the issue

dblatner avatar Nov 26 '20 11:11 dblatner

I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity

This is the line I'm using to import the gltf bytes: _rootObj = Importer.LoadFromBytes(gltf, importOptions);

And this is the exception I get while debugging on Android:

System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+<CreateMaterial>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+<CreateMaterial>d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+<OnCoroutine>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+<ParseGltfUtilityFile>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0

And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI

kelyamany avatar Jan 26 '21 13:01 kelyamany

@kelyamany Try creating a folder in the Assets folder, drag 'n GLB/GLTF file in there, then drag it into your scene, disable mesh renderer, seems if you have no object/gltf/glb in the Scene with shaders you get that error, or this is what worked for us. We created an empty cube, added material and just disabled the renderer.

Wayne-nulitics avatar Jun 22 '21 13:06 Wayne-nulitics

i am facing the same problem I put my .glb files on http server, and download on android's Application.persistentPath. the file can download and store successfully, but when l use GLTFComponent.load to load the glb file, but it doesn't show anything. I have testted it successfully in unity editor. I also switch to other plugins, GLTFUtility and glFast, it occur the same proplem. So, if any one can help me, I'll be very appreciae.

burhanuddinlimdiwala avatar Jul 29 '21 09:07 burhanuddinlimdiwala

What the issue you all are facing ? its very simple. Step :1 Import plugin Step 2 : Download glb using UnityWebrequest Step 3 : Call method Importer.ImportGLBAsync(avatarBytes, new ImportSettings(), OnImportFinished);

Unity3D-Hardik avatar May 14 '22 18:05 Unity3D-Hardik

I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity

This is the line I'm using to import the gltf bytes: _rootObj = Importer.LoadFromBytes(gltf, importOptions);

And this is the exception I get while debugging on Android:

System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0

And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI

Hey did you find a solution to this this issue? I don't really understand the few solutions that have been suggested here so far.

chadlyalan avatar Jun 17 '22 17:06 chadlyalan

I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity This is the line I'm using to import the gltf bytes: _rootObj = Importer.LoadFromBytes(gltf, importOptions); And this is the exception I get while debugging on Android:

System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0

And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI

Hey did you find a solution to this this issue? I don't really understand the few solutions that have been suggested here so far.

Actually I have not facing this kind of issue. if you can share demo project I can fix for you. I have tested its work in Unity Editor as well as Android device , even on webGL its working

Unity3D-Hardik avatar Jun 20 '22 05:06 Unity3D-Hardik

I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity This is the line I'm using to import the gltf bytes: _rootObj = Importer.LoadFromBytes(gltf, importOptions); And this is the exception I get while debugging on Android:

System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0

And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI

Hey did you find a solution to this this issue? I don't really understand the few solutions that have been suggested here so far.

Actually I have not facing this kind of issue. if you can share demo project I can fix for you. I have tested its work in Unity Editor as well as Android device , even on webGL its working

I'm fairly new to Unity development. How can I share a demo project with you?

chadlyalan avatar Jun 23 '22 15:06 chadlyalan

I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity This is the line I'm using to import the gltf bytes: _rootObj = Importer.LoadFromBytes(gltf, importOptions);

OK, explain how you are downloading the data first, are you loading it from a URL or trying to load it from disk/storage?

Wayne-nulitics avatar Jun 23 '22 18:06 Wayne-nulitics

I personally am downloading a GTLF from the web using DownloadHandlerFile. Then using Importer.LoadFromFile I'm failing when on the device. When I click play in Unity my debugging works fine, but on the device I get a very similar error as described here.

chadlyalan avatar Jun 23 '22 21:06 chadlyalan

Same exact error here. Loading at runtime from a URL using ImportGLBAsync. Model loads fine in editor, but this is the error I get on device (Pixel 4a).

I don't think this is related, but for added context, I'm using ARFoundation and URP.

EDIT: SOLVED: This is unrelated to Android. Unrelated to URP or anything else. This is a classic RTFM (the shaders are lost during compile time) image

*Remember to add the URP shaders instead if you're building for URP

michaelybecker avatar Jun 29 '22 03:06 michaelybecker

Same exact error here. Loading at runtime from a URL using ImportGLBAsync. Model loads fine in editor, but this is the error I get on device (Pixel 4a).

I don't think this is related, but for added context, I'm using ARFoundation and URP.

EDIT: SOLVED: This is unrelated to Android. Unrelated to URP or anything else. This is a classic RTFM (the shaders are lost during compile time) image

*Remember to add the URP shaders instead if you're building for URP

After following the suggested solution I'm still getting a couple errors in my logcat.

The first two are as follows (not sure if it's a real problem or not): 2022/06/29 11:37:22.964 30440 30462 Error Unity A scripted object (probably UnityEngine.XR.MagicLeap.MagicLeapSettings?) has a different serialization layout when loading. (Read 52 bytes but expected 76 bytes) 2022/06/29 11:37:22.964 30440 30462 Error Unity Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

Then a moment later the classic: 2022/06/29 11:37:27.133 30440 30462 Error Unity ArgumentNullException: Value cannot be null. 2022/06/29 11:37:27.133 30440 30462 Error Unity Parameter name: shader followed by similar errors as previously mentioned: error at wrapper, unityengine.material..ctor, HTLFMaterial, GLTMMaterial.cs:309, you know the drill.

chadlyalan avatar Jun 29 '22 17:06 chadlyalan

ha, well, at least during my time at ML, the MLSDK was fraught with benign warnings and weird errors. The first one is definitely unrelated but I'd try removing and reinstalling the MLSDK.

Hmm, I'm not sure why that would happen - but I'd assume the core problem's the same. If your gltf is showing up in the editor and missing at runtime, with that error, it means some shaders are not being included when compiling. Are you sure you're adding the right variants (URP / standard)?

For reference, this is what my Quality settings look like after the fix: image

michaelybecker avatar Jun 29 '22 17:06 michaelybecker

Yeah that's exactly how mine looks other than the URP folder.

image

I guess the difference with the steps that I took though are the GTLFUtility folder that I got these from are in my assets folder as the docs just said to clone the master, unzip, and drop it in assets. So mine wasn't in Packages like stated above.

chadlyalan avatar Jun 29 '22 18:06 chadlyalan