Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CairoScript should probably not use finalizers #215

Closed
andreasnoack opened this issue Feb 2, 2018 · 7 comments
Closed

CairoScript should probably not use finalizers #215

andreasnoack opened this issue Feb 2, 2018 · 7 comments

Comments

@andreasnoack
Copy link
Contributor

andreasnoack commented Feb 2, 2018

At least on macOS 10.13.3, it seems that CairoScript only writes to the files in this test when the finalizer is called. This might also what has caused the issues on Windows. My guess is that CairoScript shouldn't rely on finalizers but that the handle should be explicitly destroyed every time.

@lobingera
Copy link
Contributor

a) Could you please specify 'your Mac' further?
b) Did you see similar on travis?

libcairo documentation mentions anyway https://www.cairographics.org/manual/bindings-streams.html to use the stream implementation and do a language specific adaptation for files.
Strange here is, that e.g. SVG surface works and this uses almost the same c code in in libcairo

@andreasnoack
Copy link
Contributor Author

I've updated the comment to include the macOS version. The issue is that this might randomly work if the gc runs before the file is read. It is completely unpredictable but might happen on Travis but not locally or the opposite. Locally, I was watching the file and exactly I executed gc() the file was written to.

@andreasnoack
Copy link
Contributor Author

#200 is what I hit here.

@lobingera
Copy link
Contributor

I looked around a little bit and i agree with you, Script Surfaces should be explicitly destroyed.

@lobingera
Copy link
Contributor

@andreasnoack Sorry for the confusion, but you confirmed, that you saw this problem like in #200, the test for file existence is true, the check for length and content is failing? And you can confirm, that only the gc call writes the file, but not the destroy call?
Do you have any output/log available?

@andreasnoack
Copy link
Contributor Author

the test for file existence is true, the check for length and content is failing?

Yes

And you can confirm, that only the gc call writes the file, but not the destroy call?

Yes

Do you have any output/log available?

No and I'm not sure what you had in mind. The way I confirmed this was to tail -f a.cs in a separate window. This worked, i.e. the file had been created. Then I called destroy and nothing happened. Finally, the call to gc triggered the write.

@lobingera
Copy link
Contributor

With #251 CairoScript Surface feature is reduced to stream only, which is recommended by libcairo documentation anyway and seems to test fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants