KhronosGroup / UnityGLTF

Runtime glTF 2.0 Loader for Unity3D
MIT License
1.75k stars 480 forks source link

Model Loading time issue. #400

Closed AnandDixit27 closed 4 months ago

AnandDixit27 commented 5 years ago

I have integrated latest unity GLTF plugin with my project. The plugin seems to load the models really slowly. With current scenario model size 66 MB and it takes approx 30 to 31 sec to load in my android device having configuration Octa core Max 1.40GHz with 2GB RAM and Android Version 6.0.1.

Please see in screenshot. Screenshot_2019-04-09-19-16-19-119_com Mobiliya GLTFLoader

As you can see time to load a model is 30 secs.

is there any way by which the load times can be reduced? some help will be much appreciated.

Rathod1806 commented 5 years ago

Does anyone got through this? It takes painfully long to load relatively small models with not much geometry on them.

kunaldas103 commented 5 years ago

Facing a similar kind of issue, kindly help if someone can help with reduction of loading time.

blgrossMS commented 5 years ago

Hi Rathod!

A couple of things to check: 1) Are you on latest version? 2) Is multithreading enabled? 3) Try setting the BudgetPerFrameInSeconds in AsyncCoroutineHelper for your object to a higher amount, this will make it so it will not skip frames between loading components (this is to prevent hitches in real time loading)

AnandDixit27 commented 5 years ago

Hi, Thanks for your response. But unfortunately I already have done these steps and came to optimized it up to 30 sec loading time. But how can we get lower load time than this? Please help me figure this out.

boblaublaw commented 5 years ago

I'm also in the same boat. Very long model load times.

@AnandDixit27 how long does your model take using Don McCurdy's javascript gltf viewer?

blgrossMS commented 5 years ago

@AnandDixit27 if you can, can you share a model so that we can analyze it? Those speeds are much slower than expected and what I see in practice with the viewer.

AnandDixit27 commented 5 years ago

I'm also in the same boat. Very long model load times.

@AnandDixit27 how long does your model take using Don McCurdy's javascript gltf viewer?

I have tried to open my model on given link in mobile browser in chrome and also in MI browser but unable to open it.

Screenshot_2019-04-15-13-04-09-315_com android browser Screenshot_2019-04-15-13-06-25-854_com android chrome

AnandDixit27 commented 5 years ago

@AnandDixit27 if you can, can you share a model so that we can analyze it? Those speeds are much slower than expected and what I see in practice with the viewer.

I am attaching a test model. It takes a second to load it in unity editor. But on device it takes 30 sec to load.

https://drive.google.com/open?id=1zxj0GR92fi2C4AtuAWtqpJVc3W4d_ird

avpn989 commented 5 years ago

I am also facing the same issue.

AnandDixit27 commented 5 years ago

@blgrossMS Did you try with the model given to you? We need to optimize it for mobile devices.

tulika264 commented 5 years ago

I am also facing the same loading time issue while loading models.

icegibbon commented 5 years ago

Have you tried testing with reduced texture sizes. I mean, make them extremely small. Could be the downloading, or the texture upload to the GPU. Those 3000x3000 textures take up 300030004 bytes in memory, and that is is decompressed from the png, put in CPU memory, the uploaded to GPU memory.

AnandDixit27 commented 5 years ago

@blgrossMS Please help me how will i solve this. I already had shared model with you.

https://github.com/KhronosGroup/UnityGLTF/issues/400#issuecomment-483161795

blgrossMS commented 5 years ago

Hi Anand, will try to take a look this weekend. One regression we believe we have found is the new Asyncoroutinehelper is taking one more frame than it should to delay by.

Get Outlook for Androidhttps://aka.ms/ghei36


From: AnandDixit27 notifications@github.com Sent: Thursday, April 18, 2019 12:38:02 AM To: KhronosGroup/UnityGLTF Cc: Blake Gross; Mention Subject: Re: [KhronosGroup/UnityGLTF] Model Loading time issue. (#400)

@blgrossMShttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FblgrossMS&data=02%7C01%7Cblgross%40microsoft.com%7Ca74dcdbb61f0439c03a808d6c3d0ca8d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636911698868801701&sdata=zbz6i1jkhZWJAmAqJ77iQXQjnaZkqkY7KI9a6z2swVo%3D&reserved=0 Please help me how will i solve this. I already had shared model with you.

400 (comment)https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKhronosGroup%2FUnityGLTF%2Fissues%2F400%23issuecomment-483161795&data=02%7C01%7Cblgross%40microsoft.com%7Ca74dcdbb61f0439c03a808d6c3d0ca8d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636911698868801701&sdata=hlEFx62I7%2BO%2BN9nqti6tgwynhgDGg3j6SM4zKnPd40U%3D&reserved=0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKhronosGroup%2FUnityGLTF%2Fissues%2F400%23issuecomment-484390770&data=02%7C01%7Cblgross%40microsoft.com%7Ca74dcdbb61f0439c03a808d6c3d0ca8d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636911698868811695&sdata=xDPRQ8rwnd0dfcOtvidYGbPDCRHWunsF4PNIaA%2BcNRY%3D&reserved=0, or mute the threadhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAHNKSN2TPBI5IRB5EZ56OGTPRAQNVANCNFSM4HESJWZA&data=02%7C01%7Cblgross%40microsoft.com%7Ca74dcdbb61f0439c03a808d6c3d0ca8d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636911698868811695&sdata=cM%2FfZYNv%2FCShN4vhtKOjfFqV%2BrbH9CxdKoMOl%2FBPr9c%3D&reserved=0.

AnandDixit27 commented 5 years ago

Hi Anand, will try to take a look this weekend. One regression we believe we have found is the new Asyncoroutinehelper is taking one more frame than it should to delay by. Get Outlook for Androidhttps://aka.ms/ghei36

Hi @blgrossMS Could you worked on this weekend? I am waiting for your response. I need to complete it urgently, so please help me to solve it as soon as possible.

AdamMitchell-ms commented 5 years ago

Hey @AnandDixit27 ,

@rferrese has a proposed performance fix here. https://github.com/rferrese/UnityGLTF/commit/9b2e9633dbe1c336e03169947e49e87fc449d72b

I think it's a good fix. I'm testing it now with a few different models. If everything looks good, I'll send out a pull request today or tomorrow. You can use his fork to unblock yourself until then.

NoobCoder8080 commented 5 years ago

Hey @AdamMitchell-ms

I have read all the comments and just used the fix that you have provided. I am trying to load a 72mb model on iPhone 8s. It takes a lot of time to load (45s).

Any suggestions on how can I reduce it?

AdamMitchell-ms commented 5 years ago

@NoobCoder8080

Pull #414 just went in, and it does fix a loading time regression that was introduced a few weeks or months ago. It sounds like there may be an additional issue that is not addressed by that change.

You could try increasing the frame budget to improve the loading time. To do this, attach an AsyncCoroutineHelper component onto the same scene node that has the GLTFComponent attached and set the BudgetPerFrameInSeconds to something higher. For mobile, it's reasonable to set it to 0.03 or even higher values depending on what framerate you want to maintain during loading.

If you're still having problems, you could attach an example file to this thread so we can take a look.

AnandDixit27 commented 5 years ago

Hey @AdamMitchell-ms Thanks for helping me to reduce the model loading time issue. Sure after making changes in AsyncCoroutineHelper class as mentioned above the loading time is reduced upto half of the time. But i want to reduce it more upto few seconds. Because as per the industry needs i want to load the model of size 60 to 70MB in just max to max 6 to 8 sec.

So any suggestion how can i reduce it upto this.

AnandDixit27 commented 5 years ago

Hey @AdamMitchell-ms Thanks for helping me to reduce the model loading time issue. Sure after making changes in AsyncCoroutineHelper class as mentioned above the loading time is reduced upto half of the time. But i want to reduce it more upto few seconds. Because as per the industry needs i want to load the model of size 60 to 70MB in just max to max 6 to 8 sec.

So any suggestion how can i reduce it upto this.

I am waiting for your reply. Please help me to solve it.

rferrese commented 5 years ago

Hi @AnandDixit27 I saw that you mentioned that it only takes a second to load in editor, but takes a long time to load on device. Is this correct? How long does it load if you set the BudgetPerFrameInSeconds extremely high, like 1.0?

What is the baseline framerate of your app on mobile when you expect to load the model? (What is the framerate of your app when the model is not loading)

AnandDixit27 commented 5 years ago

Hi @AnandDixit27 I saw that you mentioned that it only takes a second to load in editor, but takes a long time to load on device. Is this correct? How long does it load if you set the BudgetPerFrameInSeconds extremely high, like 1.0?

What is the baseline framerate of your app on mobile when you expect to load the model? (What is the framerate of your app when the model is not loading)

Hey @rferrese Yes it is correct it takes only 0.5 to 1 sec to load in unity editor. App baseline framerate is 60fps. And i am approximately getting the same framerate while loading just on initial few frames it reduces to 1 or 2 fps otherwise on whole loading it matches to 60fps. But still it takes 20 to 25sec to load the model depend on device configuration.

AdamMitchell-ms commented 5 years ago

Yes, there is definitely still a big loading performance issue here. I've tracked it down to the fact that in AsyncCoroutineHelper, when we waitForEndOfFrame and set the new timeout, sometimes that timeout has already expired by the time YieldOnTimeout has completed its Task.Delay(1).

I have an experimental/hacky fix on my branch here. https://github.com/KhronosGroup/UnityGLTF/tree/u/adam/loading-perf

On some models on desktop, I'm seeing a ~5x reduction on loading time. This is not a proper fix though. I'm still investigating.

@AnandDixit27 , does my branch give you improved loading times?

AnandDixit27 commented 5 years ago

Yes, there is definitely still a big loading performance issue here. I've tracked it down to the fact that in AsyncCoroutineHelper, when we waitForEndOfFrame and set the new timeout, sometimes that timeout has already expired by the time YieldOnTimeout has completed its Task.Delay(1).

I have an experimental/hacky fix on my branch here. https://github.com/KhronosGroup/UnityGLTF/tree/u/adam/loading-perf

On some models on desktop, I'm seeing a ~5x reduction on loading time. This is not a proper fix though. I'm still investigating.

@AnandDixit27 , does my branch give you improved loading times?

Hey @AdamMitchell-ms, I had implemented code change done by you on AsyncCoroutineHelper and come up that loading time reduces to upto 20 to 23 seconds on both android and ios devices see the screenshot. You got time reduction on desktop but still have issue in devices. I want to reduce it to 5 to 7 secs in mobile device according to industry need.

Iphone 6 Loading time is 23sec IMG_0558

Iphone 8 Loading time is 20sec. IMG_0306

Android Samsung galaxy Note 5 loading time is 21sec. Screenshot_20190513-190940

rferrese commented 5 years ago

@AnandDixit27

I tested out Spreader.GLB on an iPhone 8 with the BudgetPerFrameInSeconds set to 0.04. I estimate that the load time was ~1 second (I didn't add a load time counter, just watched it). I loaded the model from the device (so no networking time).

In these tests what are your values for:

Also, how are you loading the stream? Is it from disk directly or using the WebServerComponent that is shipped with the GLTF addon?

If you want to post the pictured GLB, I can test it as well.

AnandDixit27 commented 5 years ago

@AnandDixit27

I tested out Spreader.GLB on an iPhone 8 with the BudgetPerFrameInSeconds set to 0.04. I estimate that the load time was ~1 second (I didn't add a load time counter, just watched it). I loaded the model from the device (so no networking time).

In these tests what are your values for:

  • BudgetPerFrameInSeconds
  • Multithreaded

Also, how are you loading the stream? Is it from disk directly or using the WebServerComponent that is shipped with the GLTF addon?

If you want to post the pictured GLB, I can test it as well.

@rferrese I had tested with .gltf files for loading a model locally from device. But since you are saying let me try with GLB format on devices.

waseemkhan1989 commented 3 years ago

@AnandDixit27 How did you record the loading time? I would like to estimate the loading time in two steps as follows:

  1. To downloading a glb file from remote server to a local location(on hard drive on a local computer)

  2. And the time it takes to import glb file from this local location into the scene

I would like to record these timings on Quest(Android). I would like to know the exact location where I should start and stop the timer. Could you please help?

pfcDorn commented 4 months ago

Please update to the latest version and open a new issue if the problem persists. Thanks!