hammerspoon: How to handle `Warning: LuaSkin: hs.canvas:delete - explicit delete is no longer required for canvas objects; garbage collection occurs automatically`
Hi, with 0.9.93 I am getting warnings from some of my modules that use hs.canvas:
2021-12-13 11:49:05: 11:49:05 ** Warning: LuaSkin: hs.canvas:delete - explicit delete is no longer required for canvas objects; garbage collection occurs automatically
I’m not sure what the right way to deal with this is:
- ignore it?
- comment out the
hs.canvas:delete()lines? - change to
hs.canvasObj = nilor something?
What’s the preferred way for explicitly destroying a canvas object now?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 17 (16 by maintainers)
@cmsj I know this is closed (should it be?) but, I found the line that causes this to print: https://github.com/Hammerspoon/hammerspoon/blob/02f60327d753ccffe13fb4f7bf95492bdd66c60f/extensions/canvas/libcanvas.m#L3184 It looks like I was wrong about when this is printed to the console. Seems like it happens iff the
:delete()method actually gets called, and only if thewarnedAboutDeletecounter is< 10.I checked and re-checked my code, and I already removed all explicit references to
hs.canvas:delete(). But I’m still getting 6 of these in my console every time HS launches. Is it possibly being referenced somewhere else internally? Any way to find out what module or line is calling?edit: I found at least 2 internal references in
drawing_canvasWrapper.luaat line 168 & 216 e.g:changing to:
eliminated the warnings on startup for me. I am sure there are others, I believe
hs.alerthas some as well…Hmmm… the number of elements shouldn’t matter (the example code had 1 after all that we didn’t explicitly clear), but I’ll dig in to it deeper next week (I have a whole week with nothing else going on for once!)… and the callbacks… again, they should be cleared in the
__gcfunction for the object… unless one of them refers to the canvas as an up-value… I’ll give it some thought and see if there might be a work around I can implement… or at least update the documentation or wiki examples to explain best practices and what to do to avoid the problem.Try the following in the console:
First, type in the following:
After the red rectangle appears, next type in the following and it should disappear:
If that doesn’t work, then one or more of the recent updates has broken something; if it does, then your items are being held somewhere else, either as up-values or in other variables… I’d need to see your code to tell for certain.