KhronosGroup / KhronosGroup/UnityGLTF
Import progress doesn't count downloaded bytes
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 536
- PR merge metrics
- No merged PRs in 30d
Description
### **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 progressReporter = new Progress();
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 🩹**
- [x] I have [searched existing issues](https://github.com/KhronosGroup/UnityGLTF/issues): no issue already exist that reports the same problem.
- [x] I follow the [Code of Conduct](https://www.khronos.org/about/code-of-conduct)
- [x] provided a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), including files when necessary.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at GLTFSceneImporter.LoadSceneAsync and the ImportProgress and UnityWebRequestLoader entry points, then trace how web downloads report progress before buffer, node, and texture import begins. Done means ImportProgress reflects downloaded bytes during the web-model download so a loading bar advances throughout the operation; the issue names no files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100