create3000 / x_ite

X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.
https://create3000.github.io/x_ite/
Other
67 stars 15 forks source link

toXMLString() breaks on empty script node #100

Closed fkievith closed 2 years ago

fkievith commented 2 years ago

Describe the bug toXMLString() breaks on empty script node.

To Reproduce Scene with some empty Script node causes the following JavaScript code to crash:

X3D.getBrowser().currentScene.toXMLString()

Web browser console Welcome to X_ITE X3D Browser 4.7.10: Current Graphics Renderer Name: Google Inc. (Intel) ANGLE (Intel, Intel(R) UHD Graphics 620 Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.100.9664) WebGL version: WebGL 2.0 (OpenGL ES 3.0 Chromium) Shading language: WebGL GLSL ES 3.00 (OpenGL ES GLSL ES 3.0 Chromium) Rendering Properties Antialiased: true Depth size: 24 bits Color depth: 32 bits Max clip planes: 6 Max global lights: 4 Max textures: 2 Texture units: 32 Max texture size: 16384 × 16384 pixel Texture memory: NaN Max vertex uniform vectors: 4096 Max fragment uniform vectors: 1024 Max vertex attribs: 16

x_ite.js:118004 initialize() CoordinateAxesSwitch x_ite.js:118004 CoordinateAxesSwitch set_visible called x_ite.js:118004 Hello World from the script inside the x3d file. x_ite.js:118004 CoordinateAxesController initialize() x_ite.js:118004 Browser.name: X_ITE x_ite.js:118004 Browser.version: 4.7.10 x_ite.js:118004 scene.specificationVersion: 4.0 X3D.getBrowser().currentScene.toXMLString() 2x_ite.js:31417 TypeError: Cannot read properties of undefined (reading 'generator') at Function.Generator.Get (x_ite.js:13887:17) at Object.toXMLStream (x_ite.js:32774:33) at X3DProtoDeclaration.toXMLStream (x_ite.js:35847:29) at x_ite.js:31411:13 at Array.forEach () at Proxy.toXMLStream (x_ite.js:31407:17) at Scene.toXMLStream (x_ite.js:32786:35) at Scene.toXMLStream (x_ite.js:33916:49) at Scene.toXMLString (x_ite.js:14051:10) at :1:31 x_ite.js:26062 Uncaught TypeError: Assignment to constant variable. at Script.toXMLStream (x_ite.js:26062:11) at Proxy.toXMLStream (x_ite.js:24561:12) at Scene.toXMLStream (x_ite.js:32794:16) at Scene.toXMLStream (x_ite.js:33916:49) at Scene.toXMLString (x_ite.js:14051:10) at :1:31

create3000 commented 2 years ago

Thank you for submitting this bug.

fkievith commented 2 years ago

But also here a problem happens in case an empty <Script></Script> tag is encountered as an assignment to a const fails at row 26062 in x_ite.js:

26059           const cdata = this .getSourceText ();
26060
26061           if (cdata && cdata .length === 0)
26062               cdata = null;
create3000 commented 2 years ago

Version 4.7.11 is now online.

fkievith commented 2 years ago

Thanks!