luberda-molinet/FFImageLoading

UWP marshall exception when calling DownSample

tualatin opened this issue · 2 comments

💬 Questions and Help

I have the following code in my controller:

            image = await ImageService.Instance.LoadFile(filePath)
                .WithCache(CacheType.All)
                .DownSample((int) width)
                .AsJPGStreamAsync(95).ConfigureAwait(false);

In Android and iOS all is fine, but in UWP I've got a marshall exception:

System.Exception: Eine Schnittstelle, die für einen anderen Thread marshalled war, wurde von der Anwendung aufgerufen. (Exception from HRESULT: 0x8001010E) at System.Runtime.InteropServices.McgMarshal.ThrowOnExternalCallFailed(Int32, RuntimeTypeHandle) + 0x4a at __Interop.ComCallHelpers.Call($__ComObject __this, RuntimeTypeHandle __typeHnd, Int32 __targetIndex, Void* arg0) in Call:line 15732480 at __Interop.ForwardComStubs.Stub_3<System.__Canon, System.__Canon>($__ComObject __this, Int32 __targetIndex) in Stub_3:line 16707566 at Windows.UI.Xaml.Media.Imaging.IWriteableBitmap__Impl.Stubs.get_PixelBuffer($__ComObject __this) in get_PixelBuffer:line 16707566 at Windows.UI.Xaml.Media.Imaging.WriteableBitmap.get_PixelBuffer() in get_PixelBuffer:line 16707566 at FFImageLoading.Extensions.WriteableBitmapExtensions.<AsJpegStreamAsync>d__1.MoveNext() in C:\projects\ffimageloading\source\FFImageLoading.Windows\Extensions\WriteableBitmapExtensions.cs:line 34 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() + 0x28
at FFImageLoading.TaskParameterPlatformExtensions.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() + 0x28 at TimeStudyApp.Common.Services.RestService.<DownSizeImageAsync>d__16.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() + 0x28
at Xamarin.Forms.Device.<>c__DisplayClass44_0$1<System.__Canon>.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() + 0x28 at TimeStudyApp.Common.Services.RestService.<CheckInDocumentsAsync>d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() + 0x1d at TimeStudyApp.Common.Business.CheckInHelper.<FinalCheckinAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() + 0x1d at TimeStudyApp.ViewModels.Utils.Services.CheckInService.<DoFinalCheckInAsync>d__24.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() + 0x1f
at Xamarin.Forms.Device.<>c__DisplayClass44_0$1<System.Boolean>.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x45
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xf4
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x9d
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task) + 0x36
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() + 0x1f at TimeStudyApp.ViewModels.Utils.Services.CheckInService.<<InitCheckInWorker>b__11_8>d.MoveNext()

I tried to surround this call with Device.InokeOnMainThreadAsync(() => ....), but always I got this exception. Do you have any hints for me, what's going wrong there?

Having the same error.

The application called an interface that was marshalled for a different thread.

   at Windows.UI.Xaml.Media.Imaging.WriteableBitmap.get_PixelBuffer()
   at FFImageLoading.Extensions.WriteableBitmapExtensions.<AsJpegStreamAsync>d__1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at FFImageLoading.TaskParameterPlatformExtensions.<AsJPGStreamAsync>d__1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at SampleApp.ViewModels.ImageEditorVM.<SaveImageAsync>d__6.MoveNext() in C:\__SRC\SampleApp\SampleApp\ViewModels\ImageEditor\ImageEditorVM.cs:line 32
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.CommunityToolkit.ObjectModel.Internals.BaseAsyncCommand`2.<ExecuteAsync>d__6.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.CommunityToolkit.Helpers.SafeFireAndForgetExtensions.<HandleSafeFireAndForget>d__5`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeCore()

Any news on this one? I'm having the same issue.