Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uno.Shared Page/UserControl Events Fired In Different Order ( UPW vs WASM ) #4072

Closed
21 tasks
ToddGlodek opened this issue Sep 18, 2020 · 1 comment
Closed
21 tasks
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@ToddGlodek
Copy link

ToddGlodek commented Sep 18, 2020

What I observe is the following: on UWP the logs indicate that the UserContol's Load event is fired first and the Page's Load event is fired second. On WASM the logs have the other way around (page first then the user control).

Page
x:Class="UnoTest2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoTest2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Loaded="OnLoad" <-THIS EVENT FIRES AFTER THE USER CONTOL'S ON UWP; BUT FIRST ON WASM ->

<Page.DataContext>
    <local:DrawingSurfaceViewModel />
</Page.DataContext>

Current behavior

I am using a XAML defined Load Event on a Page and a UserContol to provide initialization of a ViewModel.
Both use XAML to declare the respective DataContexts. There are then Notification event handles that listen for changes that occur. When the LOAD events sequence is fired in a different order, the event listeners are not initialized properly on WASM when they work properly on UWP.

Expected behavior

The sequence of events should be consistent between UWP & WASM.

How to reproduce it (as minimally and precisely as possible)

  1. Create project that has a Page and a User Control
    2, Use Xaml to create an event handler for the Loaded event on both the page and the user control (ex: Loaded="OnLoad" )
  2. In each of those events write something to the log / debug trace to show the order in which each happened
    4 Run the project on both UWP and WASM
  3. Observe that the logs are different

Workaround

I put in an await Task.Delay(1000); before the initialization of the event listeners. It was a total, hack, but it allowed both load events to be completed in whatever sequence they occurred, and the underlying DataContext to be initialized - then after the delay - the event listeners

await Task.Delay(1000); /* HORRIBLE HACK */ vuMod.Squares.CollectionChanged += this.Squares_CollectionChanged; vuMod.Circles.CollectionChanged += this.Cicrles_CollectionChanged;

Environment

Nuget Package:

  • Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
  • Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
  • Uno.SourceGenerationTasks
  • Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
  • Other:

Nuget Package Version(s):

Affected platform(s):

  • iOS
  • Android
  • [X ] WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Skia
    • WPF
    • GTK (Linux)
    • Tizen
  • [X ] Windows
  • Build tasks
  • Solution Templates

IDE:

  • Visual Studio 2017 (version: )
  • [ X] Visual Studio 2019 (version: )
  • Visual Studio for Mac (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )
  • Visual Studio Code (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

@ToddGlodek ToddGlodek added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Sep 18, 2020
@jeromelaban
Copy link
Member

jeromelaban commented Sep 21, 2020

Thanks for the report. This issue is a duplicate of #2895, you can subscribe to it for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

2 participants