ImportMeshAsync's onprogress percentage hits 100% several times

Good evening:

We’re experimenting some weird issues relatives to the use of SceneLoader.ImportMeshAsync.

The case is that apparently, the 100% of onprogress percentage is reached several times for a mesh (GLTF) file, loaded this way:

function onProgress(evt) {
  var percentage = evt.lengthComputable ? Math.floor(evt.loaded * 100 / evt.total) : Math.floor((evt.loaded / (1024 * 1024)) * 100.0) / 100.0;
	//vortice3d.Observer.fire(imor.EVENTS.VIEWPORT3D_LOADING_PROGRESS, percentage);
	//
	if (vortice3d.DEBUG) {
	  console.warn(_TAG + "Loading mesh file / Percentage:" + percentage + "%");
	}
}
...
BABYLON.SceneLoader.ImportMeshAsync("", filename, "", _scene, onProgress);
...

As we’re getting this kind of console output:

Of course the specific figures change for each execution, but always show two times that 100%

Is this the expected behavior? I can’t find it very clear in the documentation.

Thanks for your time.

You might have the event for dependent files as well ?

Hi there, @sebavan

Let me first thank you for your time.

Thinking about your reply, I thought you might be talking about the fact that, using a GLTF, we’re indeed have an inherent dependence to its BIN file, so using the GLB counterpart would fix the issue.

Sadly, I was wrong, as we’re getting the same two-time-100% reached behavior (as I’m using now a faster computer from yesterday, we don’t get intermediary percentages before hitting the 100%):

image

So what other kind of dependencies can we have involved here?

Best regards.

This is strange as it does not repro here https://playground.babylonjs.com/#WGZLGJ#7715 and the event is a 1 1 with the browser event so maybe a server thing or browser ?

What browser are you using ?

1 Like

Hi there @sebavan:

I’m using last version of FF Dev Ed. and Chrome over VSCodium’s Live Server extension. Same issue in both.

Anyway, please note that, instead of the ImportMesh you’re using in your PG:

ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<((event: ISceneLoaderProgressEvent) => void)>, onError?: Nullable<((scene: Scene, message: string, exception?: any) => void)>, pluginExtension?: Nullable): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>

…I’m using ImportMeshAsync:

ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<((event: ISceneLoaderProgressEvent) => void)>, pluginExtension?: Nullable): Promise<ISceneLoaderAsyncResult>

…so well, I don’t have the luxury of the onSuccess callback and must (I suppose) fake it, by checking the 100% completion in onProgress callback. Maybe I’m missing something here, as I find it a bit annoying not to have that onSuccess goodie. This said, perhaps I must consider forgetting the Async, changing for ImportMesh.

As I don´t see the issue running your PG or this other (ImporMeshAsync one) so I guess the issue comes from the local web server I’m using here. I’m going to check it with XAMPP and let you know.

Thanks for your time.

The entire point of ImportMeshAsync is to be promise based and not have any callback for onSuccess :slight_smile:

I do not repro here https://playground.babylonjs.com/#WGZLGJ#7734 does it for you ?

Just seen your message fully, disregard the part where I show that it works… stupid me :slight_smile: But curious of your servers tests results

Hi @sebavan:

I think I was editing my last entry while you were writing yours.

I get a clean console output from both PGs (ImportMesh and ImportMeshAync), so I think now as you, that in my case this is an issue from the local web server. As said, I’m using Live Server for VSCodium.

I’m going to check it all over XAMPP.

Hi there, @sebavan.

Ok, you’re right. I have to get used to promised (land).

Best regards.