Skip to content

[BUG] ReactiveCommand throws exception in UWP app when activated through sharing #2034

@harvinders

Description

@harvinders

Describe the bug
In a UWP app, if the app is activated through receive data api the ReactiveCommand invocation raises exception

Steps To Reproduce
I am providing a bare minimum app that reproduces this problem.
ReactiveUITestApp1 code

  1. Start the Debugging the app in visual studio
  2. Using firefox or edge browser, click on the share menu
  3. Select ReactiveUITestApp1 from the list of apps
  4. From the new application window, click the Complete button
  5. After the command's Action is executed an exception is thrown

Expected behavior
There should not be an exception or there should be a way to safely invoke the command

Environment

  • OS: Windows 10
  • Version 1903

Additional context
The project target was set to 1903 with min target of 1809. The ReactiveUI package 9.15.1 was used.

If I remove the command creation in MainViewModel in the main UI of the app, I do not get the exception.

Others have faced similar exception whilst sharing/receiving in UWP, here are some links to provide some pointers why it might be happening

https://stackoverflow.com/a/18643977/1139856
luberda-molinet/FFImageLoading#166

Exception Stacktrace

  Name Value Type
Exception {System.Exception: A COM call to an ASTA was blocked because the call chain originated in or passed through another ASTA. This call pattern is deadlock-prone and disallowed by apartment call control. A COM call (IID: {C50898F6-C536-5F47-8583-8B2C2438A13B}, method index: 3) to an ASTA (thread 12132) was blocked because the call chain originated in or passed through another ASTA (thread 22768). This call pattern is deadlock-prone and disallowed by apartment call control. at System.Runtime.InteropServices.WindowsRuntime.ICommandAdapterHelpers.<>c__DisplayClass1_0.b__0(Object sender, EventArgs e) at ReactiveUI.ReactiveCommandBase2.OnCanExecuteChanged() in D:\a\1\s\src\ReactiveUI\ReactiveCommand\ReactiveCommandBase.cs:line 195 at ReactiveUI.ReactiveCommand2.<.ctor>b__9_6(Boolean ) in D:\a\1\s\src\ReactiveUI\ReactiveCommand\ReactiveCommand.cs:line 671 at System.Reactive.AnonymousSafeObserver1.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\AnonymousSafeObserver.cs:line 45 at System.Reactive.Linq.ObservableImpl.RefCount1..OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\RefCount.cs:line 65 at System.Reactive.Subjects.FastImmediateObserver1.EnsureActive(Int32 count) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 850 at System.Reactive.Subjects.FastImmediateObserver1.EnsureActive() in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 752 at System.Reactive.Subjects.ReplaySubject1.ReplayBase.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 271 at System.Reactive.Subjects.ReplaySubject1.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 167 at System.Reactive.Linq.ObservableImpl.AsObservable1._.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\AsObservable.cs:line 31 at System.Reactive.Linq.ObservableImpl.DistinctUntilChanged2..OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\DistinctUntilChanged.cs:line 77 at System.Reactive.Linq.ObservableImpl.CombineLatest3._.SecondObserver.OnNext(TSecond value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\CombineLatest.cs:line 180 at System.Reactive.Linq.ObservableImpl.RefCount1..OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\RefCount.cs:line 65 at System.Reactive.Subjects.FastImmediateObserver1.EnsureActive(Int32 count) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 850 at System.Reactive.Subjects.FastImmediateObserver1.EnsureActive() in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 752 at System.Reactive.Subjects.ReplaySubject1.ReplayBase.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 271 at System.Reactive.Subjects.ReplaySubject1.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\ReplaySubject.cs:line 167 at System.Reactive.Linq.ObservableImpl.AsObservable1._.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\AsObservable.cs:line 31 at System.Reactive.Linq.ObservableImpl.DistinctUntilChanged2..OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\DistinctUntilChanged.cs:line 77 at System.Reactive.Linq.ObservableImpl.Concat1._.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Concat.cs:line 33 at System.Reactive.Linq.ObservableImpl.Select2.Selector..OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Select.cs:line 48 at System.Reactive.Linq.ObservableImpl.Scan2._.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Scan.cs:line 49 at System.Reactive.SafeObserver1.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\SafeObserver.cs:line 40 at System.Reactive.ScheduledObserver1.Run(Object state, Action1 recurse) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\ScheduledObserver.cs:line 254 at System.Reactive.Concurrency.Scheduler.<>c__DisplayClass49_01.<InvokeRec1>b__0(TState state1) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\Scheduler.Recursive.cs:line 55 at System.Reactive.Concurrency.Scheduler.InvokeRec1[TState](IScheduler scheduler, Pair2 pair) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\Scheduler.Recursive.cs:line 55 at System.Reactive.Concurrency.CoreDispatcherScheduler.<>c__DisplayClass10_01.<Schedule>b__0() in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Platforms\UWP\Concurrency\CoreDispatcherScheduler.cs:line 99 --- End of stack trace from previous location where exception was thrown --- at System.Reactive.Concurrency.CoreDispatcherScheduler.<>c__DisplayClass10_21.b__1(Object o, Object e) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Platforms\UWP\Concurrency\CoreDispatcherScheduler.cs:line 119} System.Exception

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions