Skip to content

WASM: SynchronizationContext not set when processing input events #20627

@appel1

Description

@appel1

Describe the bug

When dispatching input events in BrowserInputHandler, Thread.SynchronizationContext is not set, it is null.

This makes binding to observables break.

System.InvalidOperationException: TaskScheduler_FromCurrentSynchronizationContext_NoCurrent
   at System.Threading.Tasks.SynchronizationContextTaskScheduler..ctor()
   at System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()
   at Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindings.TaskStreamPlugin`1[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start(WeakReference`1 reference)
   at Avalonia.Data.Core.ExpressionNodes.StreamNode.OnSourceChanged(Object source, Exception dataValidationError)
   at Avalonia.Data.Core.ExpressionNodes.ExpressionNode.SetSource(Object source, Exception dataValidationError)

To Reproduce

Create a browser app that binds to a task property and the property value is created as a response to input.

Expected behavior

The bound view is updated when the bound task or observable completes.

Avalonia version

11.3.9

OS

WebAssembly

Additional context

AvaloniaApplication1.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions