FFImageLoading
FFImageLoading copied to clipboard
AsJPGStreamAsync() crashes on UWP
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
Noticed the same today when testing whether to update from 2.4.9 to 2.4.11.
I am also seeing a similar issue with AsPNGStreamAsync. @daniel-luberda Any ideas on this one? And possible ETA till we get a fix?
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.
Same error with both AsPNGStreamAsync and AsJPGStreamAsync. Thanks @Ruddy2007 , rolling back to 2.4.10.972 solved it.
Any update for this? I am running into the same issue again with AsPNGStreamAsync
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!
I had this same problem as well. Rolling back to 2.4.10.972 resolves the issue.