FFImageLoading icon indicating copy to clipboard operation
FFImageLoading copied to clipboard

AsJPGStreamAsync() crashes on UWP

Open activa opened this issue 6 years ago • 7 comments

Description

Calling SaveAsJpegStream on UWP crashes the application.

Steps to Reproduce

Call await AsJPGStreamAsync() in any async method in a UWP application. The app will crash with exception "The application called an interface that was marshalled for a different thread"

The reason why this crashes is because WriteableBitmap.PixelBuffer is called on a different thread than the one where the WriteableBitmap was created on.

This can be fixed by removing .ConfigureAwait(false) in TaskParameterExtensions.AsJPGStreamAsync()

public static async Task<Stream> AsJPGStreamAsync(this TaskParameter parameters, int quality = 80)
        {
            var result = await AsWriteableBitmapAsync(parameters).ConfigureAwait(false); 
           // the line above should not have ConfigureAwait(false)
            var stream = await result.AsJpegStreamAsync(quality).ConfigureAwait(false);

            return stream;
        }

Basic Information

  • Version with issue: 2.4.11
  • Last known good version: ?
  • Platform: UWP

activa avatar Jul 03 '19 20:07 activa

Noticed the same today when testing whether to update from 2.4.9 to 2.4.11.

DennisWelu avatar Jul 26 '19 20:07 DennisWelu

I am also seeing a similar issue with AsPNGStreamAsync. @daniel-luberda Any ideas on this one? And possible ETA till we get a fix?

RuddyOne avatar Dec 02 '19 11:12 RuddyOne

FYI the change was made here: https://github.com/luberda-molinet/FFImageLoading/commit/03b6b64bda350731b9db1fc4ab5bbc59becb4235

Rolling back to version 2.4.10.972 is the last working version before this issue.

RuddyOne avatar Dec 02 '19 11:12 RuddyOne

Same error with both AsPNGStreamAsync and AsJPGStreamAsync. Thanks @Ruddy2007 , rolling back to 2.4.10.972 solved it.

ramiss avatar Dec 31 '19 15:12 ramiss

Any update for this? I am running into the same issue again with AsPNGStreamAsync

RuddyOne avatar Jan 28 '21 09:01 RuddyOne

I can confirm I'm getting this error with JPG and PNG on 2.4.11.982 and I can also confirm rolling back to 2.4.10.972 resolves.

Thanks for reporting this!...saved me from more headbanging!

bmacombe avatar Mar 10 '21 17:03 bmacombe

I had this same problem as well. Rolling back to 2.4.10.972 resolves the issue.

nickInMN avatar Mar 23 '21 03:03 nickInMN