-
Notifications
You must be signed in to change notification settings - Fork 334
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
[External] Decoding HDR AVIF image consumes huge amounts of RAM #4968
Comments
I have a repro but the image came from a user and I don't really want to make it public. Is there any way I can share it privately? I discovered that the decode actually fails entirely when compiled in x86 (32-bit) mode due to an out of memory exception! The code for the repro is very simple and looks like this. Probably don't even need the last few lines which are just to display the image. private async void runDecodeButton_Click(object sender, RoutedEventArgs e) {
var bitmapImage = new BitmapImage();
var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Test.avif"));
using (var fs = await file.OpenReadAsync()) {
await bitmapImage.SetSourceAsync(fs);
}
var rawPixelsPerViewPixel = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
image.Width = bitmapImage.PixelWidth / rawPixelsPerViewPixel;
image.Height = bitmapImage.PixelHeight / rawPixelsPerViewPixel;
image.Source = bitmapImage;
} |
@benstevens48 thanks for the report. Users can submit a repro image securely to Microsoft using the Feedback Hub. It should get to me if they 'Report a problem' with category 'Apps' 'Photos'. There is an option to 'Attach a file'. We'll also attempt a local repro once folks are back from US holidays in the new year. |
I got permission to share the image. A full repro project is here - HdrAvifTest.zip |
Describe the bug
Windows 11 24H2 added support in WIC for decoding HDR AVIF images, which decode to a 64bpp floating point pixel format. However, the decoding process seems to consume a huge amount of RAM. I tested a 20 mega-pixel HDR AVIF exported from Lightroom (which uses the PQ HDR curve I think) and decoding it (in a C++ component) consumes about 2.7GB of RAM (peak in the Visual Studio debugger). The decoded image itself should only consume about 160MB of RAM, and I would expect 2 times or maybe 3 times this at most to be used during decoding. Also, maybe this is inevitable, but it's quite slow. It's much quicker to take a 64bpp PNG with PQ transfer curve, decode that to WIC without color management then use Diret2D to apply the PQ transfer curve.
Steps to reproduce the bug
See description.
Expected behavior
At most ~500MB of RAM used for decoding a 20MP HDR AVIF image, not 2.7GB.
Screenshots
No response
NuGet package version
None
Packaging type
No response
Windows version
No response
IDE
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: