question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AsJPGStreamAsync() crashes on UWP

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

1reaction
ramisscommented, Dec 31, 2019

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

1reaction
Ruddy2007commented, Dec 2, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

App Center Crashes for UWP/WinUI - Visual Studio
App Center Crashes will automatically generate a crash log every time your app crashes. The log is first written to the device's storage...
Read more >
UWP App crash at different screens when using it for a long ...
In our UWP app we have XAML screens with ListView, Grid, ScrollView, ItemsControl like UWP elements. To show HTML content we use Web...
Read more >
UWP application crashes on file write
I try to write to file with UWP application running on Windows IoT 10 Core, but application closes unexpectedly. The code: private async...
Read more >
Roblox UWP crashes after 2-3 seconds of startup
I have a typical problem like everyone else - Roblox UWP refuses to work, ... Roblox UWP crashes after 2-3 seconds of startup....
Read more >
Windows Explorer crashes when opening folder with a ...
After installing VS17 Update 1, I can no longer open any folder with a Typescript file in it in Windows Explorer (Windows 10)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found