UnityGLTF icon indicating copy to clipboard operation
UnityGLTF copied to clipboard

Import progress doesn't count downloaded bytes

Open fra3point opened this issue 9 months ago • 4 comments

Describe the bug 💬

The implementation ImportProgress.Progress doesn't take into consideration the download bytes when importing models from the web.

This means that when importing a web model, the Progress value stays at 0 during all the download phase (which is generally the longest one), then it rapidly goes to 1 when importing buffers, nodes and textures.

In this way it is impossible to create a loading bar. The only alternative I found is to download the file separately and then import it as usual.

Steps to reproduce 🔢

Import a .glb from web url with LoadSceneAsync() like this

private CancellationTokenSource tokenSource;
string directory = Path.GetDirectoryName(someWebUrl);
string fileName  = Path.GetFileName(someWebUrl);

...

ImportOptions importOpt = new ImportOptions
{
    DataLoader   = new UnityWebRequestLoader(directory),
    CameraImport = CameraImportOption.None
};

GLTFSceneImporter importer = new GLTFSceneImporter(fileName, importOpt);
Progress<ImportProgress> progressReporter = new Progress<ImportProgress>();
progressReporter.ProgressChanged += OnImportProgress;
importCancellationTokenSource = new CancellationTokenSource();
await importer.LoadSceneAsync(-1, true, OnImportComplete, tokenSource.Token, progressReporter);

...

private void OnImportProgress(object sender, ImportProgress prog)
{
    Debug.Log(Time.realTimeSinceStartup + " - " prog.ToString());
}

Notice how the logs show almost no progress while downloading, and then abruptly increase when the GLB import phase begins.

Files to reproduce the issue ♻

No response

Editor Version 🎲

6000.0.37

Render Pipeline and version

Any

Operating System 👩‍💻

Windows

When does this problem happen?

  • [x] Editor Import
  • [x] Runtime Import
  • [ ] Editor Export
  • [ ] Runtime Export

Additional Info 📜

No response

Validations 🩹

fra3point avatar Apr 23 '25 10:04 fra3point

Please follow the bug report template, which contains info on which versions of Unity, UnityGLTF, etc you use, which platforms, and so on. Otherwise we'll have to close the report as non-actionable. Thanks!

hybridherbst avatar Apr 23 '25 12:04 hybridherbst

Hi,

this is not a bug, actually. It's more a feature request. Should I still use a bug template?

fra3point avatar Apr 23 '25 12:04 fra3point

If the progress value stays at 0 that's a bug – it should not stay at 0 if we can show meaningful progress. Please use the bug template :)

hybridherbst avatar Apr 23 '25 12:04 hybridherbst

Issue updated with bug template as requested!

fra3point avatar Apr 23 '25 14:04 fra3point