ImportMeshAsync RuntimeError: Unable to load

Sometimes getting error while importing mesh by SceneLoader.ImportMeshAsync
ImportMeshAsync RuntimeError: Unable to load from /assets/babylon/models/airplanes/A320/A320.babylon: importMesh of A_320_CP.babylon from Autodesk Maya version: 2018.6, exporter version: 20220210.4
Material Name: A320_Mat1
Mesh Name: A320, isInstance: YES, # of submeshes: 1, n vertices: 3511, parent: NONE
at RuntimeError.BaseError [as constructor] (error.js:11:1)
at new RuntimeError (error.js:61:1)
at errorHandler (sceneLoader.js:352:46)
at Object.importMesh (babylonFileLoader.js:792:1)
at sceneLoader.js:391:35
at dataCallback (sceneLoader.js:193:13)
at fileTools.js:348:1
at XMLHttpRequest.onReadyStateChange (fileTools.js:462:1)
at push.23484._ZoneDelegate.invokeTask (zone.js:443:1)
at Object.onInvokeTask (core.mjs:25595:1)

Does it happen only with this model?
Does it happen when you import other models / from other server?

@labris
Thanks for quick response.
Its happening with different models irrespective from server or local. But it happens sometimes only, not everytime.
First I am loading the model from server, if that goes wrong then from local.

Below is the code:-
BABYLON.SceneLoader.ImportMeshAsync(
‘’,
${appConfig.unityAssetsUrl}model/plane/${aircraftModel}/,
${aircraftModel}.babylon,
this.engineService.scene
)
// If fails load from local
.catch((res) => {
return BABYLON.SceneLoader.ImportMeshAsync(
‘’,
/assets/babylon/models/airplanes/A320/,
A320.babylon,
this.engineService.scene
);
})
//Catch any other runtime error
.catch((res) => {
console.warn(
‘Unable to complete ImportMeshAsync for’,
flightData
);
return false; // Don’t create aircraft
})
.then((result: BABYLON.ISceneLoaderAsyncResult) => {
// process mesh
}

One more thing in case of runtime error is adding the corrupted model in the scene nodes which freezing the UI.

Any chance you can share a reproduction of your scene with the meshes?

Solved this by catching the runtime error and then finding the mesh from scene and then disposing it.

Code:-
BABYLON.SceneLoader.ImportMeshAsync()
.catch((res) => {
const aircraft =
this.engineService.scene.getMeshByName(‘A320’); // Check mesh name from babylon inspector
aircraft?.dispose();
return false;
})

1 Like