joostn / OpenJsCad

3D solid CAD using only Javascript
315 stars 128 forks source link

parallel execution fails #37

Closed bebbi closed 10 years ago

bebbi commented 10 years ago

I've been trying to hunt that bug but no luck so far. When you add >1 gProcessors and viewers, the object rendering fails (though axes may still show). It can show a small garbled object. It does work however if you either run it all sync via the parseJsCadScriptSync variant, or if you time the web workers to ensure they execute in sequence.

Do you have any idea where to start looking?

To re-create (possibly have to use a non-trivial object, like intersection cube/sphere): Try to add 3 gProcessors in index.html:

var gProcessor=null; var gProcessor2=null; var gProcessor3=null;

...

function onload()
{
  gProcessor = new OpenJsCad.Processor(document.getElementById("viewer"), options);
  gProcessor2 = new OpenJsCad.Processor(document.getElementById("viewer2"), options);
  gProcessor3 = new OpenJsCad.Processor(document.getElementById("viewer3"), options);
}

...

function updateSolid()
    {
      gProcessor.clearViewer();
      gProcessor2.clearViewer();
      gProcessor3.clearViewer();

      gProcessor.setJsCad(document.getElementById('code').value);
      gProcessor2.setJsCad(document.getElementById('code').value);
      gProcessor3.setJsCad(document.getElementById('code').value);
    }

...

<div id="viewer"></div>
<div id="viewer2"></div>
<div id="viewer3"></div>
joostn commented 10 years ago

This is fixed by e7aeb6a3285ff7fc4020b4b6915155641c6b9922