cyberbotics / webots

Webots Robot Simulator
https://cyberbotics.com
Apache License 2.0
3.24k stars 1.7k forks source link

webotsjs freezes at load time if some node id is missing #4255

Closed omichel closed 2 years ago

omichel commented 2 years ago

No error is reported and the browser seems to freeze when attempting to load this simple x3d scene:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<x3d version="3.0" profile="Immersive" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.0.xsd">
<head>
<meta name="generator" content="Webots" />
</head>
<Scene>
<WorldInfo id='n1' docUrl='https://cyberbotics.com/doc/reference/worldinfo' title="" info='' basicTimeStep='32' coordinateSystem='ENU'></WorldInfo>
<Viewpoint id='n2' docUrl='https://cyberbotics.com/doc/reference/viewpoint' orientation='-0.23244937 -0.14943881 0.9610595 3.9676616' position='0.24667683 0.30063453 0.22481202' exposure='1' bloomThreshold='21' zNear='0.05' zFar='0' followSmoothness='0.5' ambientOcclusionRadius='2' followedId='n230'></Viewpoint>
<Background id='n3' docUrl='https://cyberbotics.com/doc/guide/object-backgrounds' rightUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_right.png"' rightIrradianceUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_right.hdr"' leftUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_left.png"' leftIrradianceUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_left.hdr"' topUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_top.png"' topIrradianceUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_top.hdr"' bottomUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_bottom.png"' bottomIrradianceUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_bottom.hdr"' frontUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_front.png"' frontIrradianceUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_front.hdr"' backUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_back.png"' backIrradianceUrl='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/default/worlds/textures/cubic/mountains_back.hdr"' ></Background>
<DirectionalLight id='n4' docUrl='https://cyberbotics.com/doc/guide/object-backgrounds' direction='0.55 -0.6 -1' intensity='2.7' ambientIntensity='1' castShadows='TRUE'></DirectionalLight>
<Transform id='n19' docUrl='https://cyberbotics.com/doc/guide/object-floors' name='floor' solid='true'>
<Shape id='n20' castShadows='true'>
<PBRAppearance roughness='1' metalness='0'>
<ImageTexture id='n118' url='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/appearances/protos/textures/parquetry/chequered_parquetry_base_color.jpg"' containerField='' origChannelCount='3' isTransparent='false' type='baseColor'>
<TextureProperties anisotropicDegree="8" generateMipMaps="true" minificationFilter="AVG_PIXEL" magnificationFilter="AVG_PIXEL"/>
</ImageTexture>
<ImageTexture id='n119' url='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/appearances/protos/textures/parquetry/chequered_parquetry_roughness.jpg"' containerField='' origChannelCount='3' isTransparent='false' type='roughness'><TextureProperties anisotropicDegree="8" generateMipMaps="true" minificationFilter="AVG_PIXEL" magnificationFilter="AVG_PIXEL"/>
</ImageTexture>
<ImageTexture id='n120' url='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/appearances/protos/textures/parquetry/chequered_parquetry_normal.jpg"' containerField='' origChannelCount='3' isTransparent='false' type='normal'><TextureProperties anisotropicDegree="8" generateMipMaps="true" minificationFilter="AVG_PIXEL" magnificationFilter="AVG_PIXEL"/>
</ImageTexture>
<ImageTexture id='n121' url='"https://raw.githubusercontent.com/cyberbotics/webots/R2022a/projects/appearances/protos/textures/parquetry/chequered_parquetry_occlusion.jpg"' containerField='' origChannelCount='3' isTransparent='false' type='occlusion'><TextureProperties anisotropicDegree="8" generateMipMaps="true" minificationFilter="AVG_PIXEL" magnificationFilter="AVG_PIXEL"/>
</ImageTexture>
</PBRAppearance>
<IndexedFaceSet id='n26' coordIndex='0 1 2 -1 1 0 3 -1' normalIndex='0 0 0 -1 0 0 0 -1' texCoordIndex='0 1 2 -1 1 0 3 -1'>
<Coordinate point='1.0000 -1.0000 0.0000, -1.0000 1.0000 0.0000, -1.0000 -1.0000 0.0000, 1.0000 1.0000 0.0000'></Coordinate>
<Normal vector='0.0000 0.0000 1.0000'></Normal>
<TextureCoordinate point='4.0000 0.0000, 0.0000 4.0000, 0.0000 0.0000, 4.0000 4.0000'></TextureCoordinate>
</IndexedFaceSet>
</Shape>
</Transform>
</Scene>
</x3d>

Adding id='n117' to the PBRAppearance node fixes the problem. The same problem happens when removing the id attribute from other nodes. If a id attribute is missing webotsjs should not freeze.

BenjaminDeleze commented 2 years ago

I think it is the same issue I had with tracks earlier this week, I will have a look at all node to fix it.