I need to use the Texture.ForceSerializeBuffers flag for serializing RawTextures and then want to use
SceneSerializer.SerializeAsync as it is recommended. However, for other, regular url textures I get the exception below in the console, probably because the texture is not ready, and texture.getSize() returns 0,0. Here is a PG:
SceneSerializer.Serialize generates the same error.
I actually would not need the base64 encoded texture for those but I do not know how to avoid generating those, per texture.
How would one use SerializeAsync properly ?
Thanks.
babylon.js:16 Uncaught (in promise) DOMException: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': The source width is zero or not a number.
at r (https://preview.babylonjs.com/babylon.js:16:942395)
at o (https://preview.babylonjs.com/babylon.js:16:942805)
at t.serialize (https://preview.babylonjs.com/babylon.js:16:107944)
at Function.e.Serialize (https://preview.babylonjs.com/babylon.js:16:5044)
at t.serialize (https://preview.babylonjs.com/babylon.js:16:495268)
at Function.e._Serialize (https://preview.babylonjs.com/babylon.js:16:3773858)
at Function.e.SerializeAsync (https://preview.babylonjs.com/babylon.js:16:3775326)
at createScene (<anonymous>:38:45)
at window.initFunction (<anonymous>:58:16)
Thanks for looking into this. It looks like the PG is using the latest preview ? The version is v5.0.0-alpha.63 but does not change for nightlies, I think.
I think I understand what I was missing. The SerializeAsync function is probably not intended to wait for the scene to become ready before serializing although I thought that would be the main reason why serializing should be done asynchronously. Is that about right ? I can use scene.whenReadyAsync() instead before serializing.
( What is the reasoning that _forceSerialize is marked with an underscore (‘private’) ? )
_forceSerialize is currently only internal as it has lots of gotchas depending on the texture type so to use with extra care
About the SerializeAsync it is async mainly for the read texture part which is async due to no sync way of doing so in WebGPU. It is definitely not intented to wait for readiness of the scene.