Skip to content

[FEATURE] A SKPixmap from a disposed SKSurface should throw an exception on .GetPixels call #811

Open
@The-MAZZTer

Description

@The-MAZZTer

Is your feature request related to a problem? Please describe.

When learning Skia I did not realize the Surface was required to be live and undisposed to use the Pixmap. So I ended up with an AccessViolationException sometimes when using .GetPixels after disposing the Surface via a using block.

Describe the solution you'd like

It would be nice if the SKPixmap class could detect this condition and throw an exception instead of returning a pointer to freed memory.

Describe alternatives you've considered

Alternatively the Surface could wait until all Pixmaps created from it are disposed before disposing itself. This is more complex than necessary, though, and violates the contract of IDisposable.

Additional context
I am using SkiaSharp in Unity where the AccessViolationException causes Unity Editor to hard crash. Not fun!

Additional API calls on Pixmap besides GetPixels should also throw the Exception. Possibly all of them.

VS bug #820075

Metadata

Metadata

Assignees

Type

No type

Projects

Status

New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions