Giter VIP home page Giter VIP logo

Comments (6)

andreasplesch avatar andreasplesch commented on May 27, 2024

node.dispose() seems to work fine in a regular script:

https://gist.github.com/andreasplesch/a70a5544ce291e1d2708d0a7ec52746c

https://gist.githack.com/andreasplesch/a70a5544ce291e1d2708d0a7ec52746c/raw/bff957ea823621b7782366f2e7383ff70d05a6f3/x_ite.html

It returns and nulls the node. (But the scenegraph may not be updated).

So something else, investigating.

Hm, in the gist script SFNode.dispose() and X3DChildObject.dispose() is used, which does not appear to do much.

Whereas dom .x3d .dispose() calls X3DBaseNode.dispose();

from x_ite.

andreasplesch avatar andreasplesch commented on May 27, 2024

This for of loop keeps sometimes looping forever:

for (var firstParent of firstParents .values ())

The .values() iterator just keeps generating next values. Perhaps it has to do how the Proxy is used.

from x_ite.

andreasplesch avatar andreasplesch commented on May 27, 2024

Apparently, the never ending iterator has to do how the map is modified while being iterated. When I copy the parents map first to a new Map, the loop finishes and the node is disposed:

var firstParents = new Map(this .getParents ());

But of course I am not sure if this is correct.

It is probably necessary to copy the modified parent map back after the for loop:

this._parents = firstParents;

from x_ite.

andreasplesch avatar andreasplesch commented on May 27, 2024

Ok, I found that this test example

https://github.com/create3000/Library/blob/master/Tests/Components/Scripting/BaseNodeDispose.x3d

has the same issue. Clicking on the dispose box results in the infinite loop. Here a live scene:

https://gist.githack.com/andreasplesch/a70a5544ce291e1d2708d0a7ec52746c/raw/69a202d334e7c4b149c717caa4ac7bdb271e9f68/x_ite.html

from x_ite.

create3000 avatar create3000 commented on May 27, 2024

Fixed this in latest release and 'parents' are now a Set. 'Remove Box' in now working.

from x_ite.

andreasplesch avatar andreasplesch commented on May 27, 2024

Thanks. I can confirm. Here is the test example updated to the latest release:

https://gist.githack.com/andreasplesch/a70a5544ce291e1d2708d0a7ec52746c/raw/cc52ea343e32dad8b18d23fd21940b6503d2ddfd/x_ite.html

[Since parents are objects, perhaps it is possible to use WeakSet for better garbage collection. Just an idea.]

from x_ite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.