[x] I have written a descriptive pull-request title
[x] I have verified that there are no overlapping pull-requests open
[x] I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
[x] I have provided test coverage for my change (where applicable)
Description
Fixes #2696.
This is an alternative take for #2704. Differences:
The discontiguous limit is configurable in Megabytes on MemoryAllocatorOptions (together with the pool size).
On 64bit it defaults to 4GB, equivalent of 32k x 32k of Rgba32 which is more conservative than the limit in #2704. For me this feels somewhat safer while I don't see many downsides. Note that this is the absolute hardcoded limit in WIC, while newer skia builds have a hardcoded 2GB limit (this hasn't been merged to in SkiaSharp 2.* yet)
On 32bit it defaults to 1GB which is a significant portion of the overall virtual memory limit of 4GB. Maybe we can make it even lower.
Single contiguous buffers have a limit of 1GB (or the discontiguous limit, if it's lower). This limit is not configurable separately in order to make things simpler for users. I don't see any risks from that nor the need to make it as low as in #2704. The RLE path in BMP and TIFF decoders actually allocates temporary contiguous buffers of width * height sizes so a 64MB limit would be easy to exceed with sane images.
It also significantly reduces MaxAllocationAttempts so we don't block too long if an OOM is still being hit.
The PR is missing tests and PNG tweak from #2704. Will finalize it after agreeing on the direction.
Prerequisites
Description
Fixes #2696.
This is an alternative take for #2704. Differences:
MemoryAllocatorOptions
(together with the pool size).32k x 32k
ofRgba32
which is more conservative than the limit in #2704. For me this feels somewhat safer while I don't see many downsides. Note that this is the absolute hardcoded limit in WIC, while newer skia builds have a hardcoded 2GB limit (this hasn't been merged to in SkiaSharp 2.* yet)width * height
sizes so a 64MB limit would be easy to exceed with sane images.MaxAllocationAttempts
so we don't block too long if an OOM is still being hit.The PR is missing tests and PNG tweak from #2704. Will finalize it after agreeing on the direction.