Mark parseGlyfGlyph prototype as gcsafe#358
Conversation
|
Could you provide a short example of where this happens? I am not sure what the problem is. |
|
Sorry, the proc that needed to be marked was further down in The problem is that when a proc is declared without a body the compiler will assume that it is not |
|
What happens when you move gcsafe not further down, but up into your own code? |
|
If I put gcsafe high up in my code things work, but I'm rendering in nested callbacks, so the trace back to the original function takes some effort to follow. And if I mark something high up as gcsafe to silience an error then I might miss an actually gcunsafe proc later. |
|
So you have threads and callbacks, which requires gc safe? This feels like a nim issue not a pixie issue? Eventually all pixie methods would require gc safe, no? I don't think it's workable to mark only the methods you use as gc safe? Or do you think only some key methods need the gc safe tag for things to work? We need a simple test case of this before we merge. And a better explanation. I don't get why you need gc safe at all and can't have it in your user code. |
|
https://nim-lang.org/docs/manual.html#effect-system-gc-safety-effect Doesn't compile: Gcsafe is necessary for safe callbacks, and using callbacks is unavoidable in some cases. |
|
I think you have a bug in your code, waitFor needs an async proc not a gcsafe proc, it throws some strange error instead. I think the correct code is (compiles on my machine ™️): import std/asyncdispatch
import pixie
proc main() {.async.} =
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
var font = readFont("/p/pixie/examples/data/Roboto-Regular_1.ttf")
font.size = 20
let text = "Hello world"
image.fillText(font.typeset(text, vec2(180, 180)), translate(vec2(10, 10)))
image.writeFile("text.png")
waitFor main() |
|
I also don't get why it correctly infers that that:
What is that reason? |
|
It appears that Nim can't GC safe recursive proc calls. parseGlyfGlyph calls parseCompositeGlyph which can call parseGlyfGlyph It gets confused and marks whole tree not gc safe even though it is? |
|
I have filed a bug with Nim: nim-lang/Nim#19339 |
|
Hey @ehmry, you where right! It looks like we need to add gc safe to all forward declaration. |
This causes problems for procs that call
fillTextand need to be gcsafe.