You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the GL backend, the python interpreter seems to crash/freeze once the GrDirectContext is deallocated. I noticed this happening in my own project, but it even happens in the GL backend example from the skia-python documentation. Therefore it doesn’t seem to be a problem on my end.
Running the sample from the command line causes the freeze. The Jupyter Notebook of this repo may have the problem too, but simply doesn’t cause the entire notebook to freeze. Would be interesting to see if this problem can be reproduced by others.
To Reproduce
Take the following sample from the docs, save it as a .py file, then run from the command line.
It draws and saves the circle properly, but then freezes the interpreter at the end of execution.
Additional context
I used a C application with an embedded python interpreter, then paused the debugger to see what happens. It seems to be repeatedly decreasing reference counts of some object. Odd, because I'd think this would cause a crash rather than a freeze. In case this problem is caused by glfw, I tried the same example with a context created using moderngl instead. The problem persists.
Python version is 3.10.
Library version of python-skia is 87.5, installed through pip.
Workaround / Temporary Solution
I tried increasing the reference count of the context using its ref() function:
surface.recordingContext().ref()
And the problem went away. To ensure this isn't leaking the context, I double checked in C. The reference count reaches 0 now and the context is still deallocated properly.
This makes me even more certain there is something fishy going on with the GrDirectContext refcount. Manually increasing reference counts doesn’t seem like intended behaviour.
The text was updated successfully, but these errors were encountered:
In m88, GrContext is gone - all its methods got merged into GrDirectContext. In my m116 fork I chose to keep the shorter name, and also add an alias so using either with any of their combined methods work. So there is probably some truth in your assessment, but the problem is upstream - and Google folks make it go away in m88.
Not sure what's going on, with m117, it does not like the last line image.save('output.png', skia.kPNG). If I comment it out the example finishes running. image.save() itself works elsewhere, so this appears to be a GPU-backed image/surface problem.
When using the GL backend, the python interpreter seems to crash/freeze once the GrDirectContext is deallocated. I noticed this happening in my own project, but it even happens in the GL backend example from the skia-python documentation. Therefore it doesn’t seem to be a problem on my end.
Running the sample from the command line causes the freeze. The Jupyter Notebook of this repo may have the problem too, but simply doesn’t cause the entire notebook to freeze. Would be interesting to see if this problem can be reproduced by others.
To Reproduce
Take the following sample from the docs, save it as a .py file, then run from the command line.
It draws and saves the circle properly, but then freezes the interpreter at the end of execution.
Additional context
I used a C application with an embedded python interpreter, then paused the debugger to see what happens. It seems to be repeatedly decreasing reference counts of some object. Odd, because I'd think this would cause a crash rather than a freeze. In case this problem is caused by glfw, I tried the same example with a context created using moderngl instead. The problem persists.
Python version is 3.10.
Library version of python-skia is 87.5, installed through pip.
Workaround / Temporary Solution
I tried increasing the reference count of the context using its ref() function:
And the problem went away. To ensure this isn't leaking the context, I double checked in C. The reference count reaches 0 now and the context is still deallocated properly.
This makes me even more certain there is something fishy going on with the GrDirectContext refcount. Manually increasing reference counts doesn’t seem like intended behaviour.
The text was updated successfully, but these errors were encountered: