2

Is a BitmapImage's source released automatically after it is shown in the UI?

I'm seeing that after a BitmapImage is shown once in an Image control, showing it again takes ~300ms. During that delay nothing is drawn on the screen. Profiling with XPerf shows a decode operation. The decode shouldn't be necessary because the image has already been displayed.

(BTW - I swear this didn't happen with Windows 8, but can't prove it)

Edit - More profiling...

In one run, the 250ms delay is split between 120ms for decoding, 100ms for filling a render target, and 30ms for the dwm to put it on the screen. Perhaps it's the render target's memory that is being released by the Image control?

Edit -

When an Image control's Source is given a newly created BitmapImage the image displays in the UI immediately. When given a BitmapImage that had been previously displayed, there is ~300ms where nothing is displayed. Profiling with XPerf shows that the major difference between these situations is that the latter requires a decode step.

I created a proxy for BitmapSource in the hopes that I could eavesdrop on what the Image control was doing with the bitmap. This didn't work. It would appear that the Image control accesses image data through an interface other than the one it asks you to give it (ImageSource).

Amy Peng - MSFT
  • 1,902
  • 11
  • 14
Tristan
  • 1,466
  • 1
  • 16
  • 24
  • Fang Peng, why was the 'windows store apps' tag removed? This takes place in an app published in the Windows Store. – Tristan Sep 13 '16 at 18:34
  • I am sorry, I think the UWP tag will be more suitable for your question, based on the tag description for the Windows Store app. And I have added the xperf tag for you. Thanks for your understanding. – Amy Peng - MSFT Sep 14 '16 at 04:59
  • 1
    For your question about the BitmapImage, I wonder if you have set the BitmapImage.CreateOptions property, the default value for the BitmapCreateOptions is None, then the BitmapImage uses cached content when it is available. But the other possible value for CreateOptions is BitmapCreateOptions.IgnoreImageCache. Setting CreateOptions to use BitmapCreateOptions.IgnoreImageCache causes all newly retrieved image sources to be decoded again, which can negatively impact performance. https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.imaging.bitmapimage.createoptions – Amy Peng - MSFT Sep 14 '16 at 05:01
  • BitmapCreateOptions is unchanged. – Tristan Oct 02 '16 at 19:09

0 Answers0