Search code examples
c#windows-phone-8.1lumia-imaging-sdk

Lumia Imaging GifRenderer Never Returns


I'm calling the RenderAsync() function of the GifRenderer class but it never returns. I get no error, it just never comes back. I'm starting with some byte arrays containing JPEG images. I create a collection of BufferImageSource objects for sources.

var sources = new List<IImageProvider>();
sources.Add(new BufferImageSource(frame.Data.AsBuffer(), ImageFormat.Jpeg));

I've even taken it down to only a single source buffer, but it still doesn't help. I've tried the RenderAsync() call with and without the ConfigureAwait() and that doesn't matter either. Any other things I can check?

using (var gifRenderer = new GifRenderer(sources))
{
  gifRenderer.Duration = 1000 / App.AppSettings.FramesPerSecond;
  gifRenderer.UseGlobalPalette = true;
  gifRenderer.Size = new Size(320, 240);
  var gifbuf = await gifRenderer.RenderAsync().AsTask().ConfigureAwait(false);
  // ... and so on
}

Solution

  • Alright, I figured it out. It wasn't specifically something with the Lumia library. It was a deadlock caused by a Dispatch Timer. I'm really not sure what that mattered since shouldn't be on the UI thread when it's asynchronous, but it works if I stop the Dispatch Timer, run the encode, then start it up again.