Comments (6)
Similar to #7048, it will get garbage collected if you remove all lingering references to it. .remove()
removes all internal references (it will no longer appear in the page's DOM), and then the user needs to remove their own reference to pg
, so I think this is currently working as designed.
That said, we could remove the internal references to the HTML element and its context if we want to ensure the heavier bits can get GCed even if the user never removes their reference.
from p5.js.
Tidying up the heavier bits automatically would be nice! It'd also mirror p5.Framebuffer.remove()
a little better. Just updated the reference to reflect best practices.
from p5.js.
Sounds good! I think that would amount to setting elt
, canvas
, and _renderer
to undefined
in the remove
method. If anyone's interested in adding this, I think it would be a pretty straightforward change!
from p5.js.
I took a stab at this - however, when I set Graphics.canvas to undefined the image() call in the draw function throws an error.
As far as I understand, that image() call references a global renderer on the p5 instance (created by the createCanvas() call in setup I believe) and makes a renderer.image() call, which then errors out because of the undefined canvas
Thoughts?
the additions to the remove fn:
remove() {
...
this._renderer = null;
this.canvas = null;
this.elt = null;
}
from p5.js.
I have tried this
remove() {
...
this._renderer = null;
this.canvas = null;
this.elt = null;
}
works fine circle got removed but i am getting a typeError on doubleClick
Uncaught TypeError: u is null
So i tried this with undefined also but still getting the same thing.
Uncaught TypeError: u is undefined
from p5.js.
Hello, I'm keenly interested in this issue and would like to offer my assistance. I'm considering giving it a try with a boolean approach.
from p5.js.
Related Issues (20)
- getting wrong language in the console. HOT 9
- Hit detection on 2D Shapes HOT 1
- Docker implementation HOT 3
- Broken link to dev_notes.md in the documentation HOT 1
- "point" class documentation text misprint HOT 9
- p5.Vector reflect() unexpectedly modifies surface normal argument HOT 3
- [p5.js 2.0 RFC Proposal]: Pruning HOT 2
- orbitControl() customizability HOT 3
- clearDepth() example broken
- Add an easier way to disable right-click context menus on the canvas HOT 8
- [p5.js 2.0 RFC Proposal]: Promises HOT 4
- Clipping to multiline text only works with the final line
- a typo in createCanvas() reference? HOT 3
- Reference page of Quad (2D Primitives) HOT 6
- Broken link to contribution docs in the README.md HOT 1
- Slight mistake in description of scale() effect in reference HOT 3
- Broken links in README ('Learning' and 'Get Started' sections) HOT 1
- textWidth gives wrong value on setup function HOT 3
- Text-based canvas accessibility throws error on out-of-Y-bounds shapes HOT 6
- Inconsistent instance mode canvas sizing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p5.js.