xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
74 stars 25 forks source link

adapterHandler.status of cached adapters for data nodes still NOT_FOUND after re-inserting node #50

Closed tospie closed 10 years ago

tospie commented 10 years ago

Re-Inserting a node to the DOM that was previously deleted does not change the adapter status to LOADING or READY and throws a "node not found" error if it is referenced by another node later

How to reproduce the error:

  1. Enter a node to the DOM via JavaScript
  2. Enter a node with a node that references this data node to the DOM
  3. Remove the node from the DOM via JavaScript
  4. Remove the node from the DOM via JavaScript
  5. Perform step 1 with same node ID.
  6. Perform step 2 with same reference.

Step 6 will fail with error message "Could not find element of url #dataID for src". The node will be present in the DOM, but still marked as NOT_FOUND in the adapter entry which is cached in _ccachedAdapterHandlers in ResourceManager.getAdapterHandle . Check for the adapter status then throws the error.

Expected behaviour : After re-inserting the data node, it is available to be referenced again.

lachsen commented 10 years ago

Sorry, I can't reproduce the problem.

Here the code that I used:

<!doctype html>
<html>
<head>
<title>XML3D Bug Test</title>
<script type="text/javascript" src="../../build/output/xml3d.js"></script>
<script type="text/javascript">

  function createData(){
    var newData = document.createElement("data");
    newData.id = "rectangle";
    newData.innerHTML = '<int id="indices" name="index">0 1 2 1 2 3</int>' +
            '<float3 id="positions" name="position">-1.0 -1.0 -10.0 1.0 -1.0 -10.0 -1.0 1.0 -10.0 1.0 1.0 -10.0</float3>' +
            '<float3 name="normal">0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0</float3>' +
            '<float2 id="texcoords" name="texcoord">0.0 1.0 1.0 1.0 0.0 0.0 1.0 0.0</float2>';
    document.querySelector("defs").appendChild(newData);
  }
  function createGroup(){
    var newGroup = document.createElement("group");
    newGroup.id = "meshGroup";
    var newMesh = document.createElement("mesh");
    newMesh.id = "myMesh02";
    newMesh.src = "#rectangle";
    newGroup.appendChild(newMesh);
    document.querySelector("xml3d").appendChild(newGroup);
  }

  function executeTest(){
      createData();
      createGroup();

      window.setTimeout(function(){
          var group = document.querySelector("#meshGroup");
          group.parentNode.removeChild(group);

          var data = document.querySelector("#rectangle");
          data.parentNode.removeChild(data);

          window.setTimeout(function(){
              createData();
              createGroup();
          }, 1000);
      },1000);
  }
</script>
</head>
<body style="background-color: #fff;width:500px" onload="executeTest()">
  <xml3d id="myXml3d" width="1000px" height="300px">
    <defs>
    </defs>
  </xml3d>
</body>
</html>

I don't get any error message and everything works as expected.

Further questions:

lachsen commented 10 years ago

This issue seems to be fixed, as it is not reproducible anymore.