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

[Epic] Controls initialization sequence #3519

Open
1 of 9 tasks
carldebilly opened this issue Jul 10, 2020 · 0 comments
Open
1 of 9 tasks

[Epic] Controls initialization sequence #3519

carldebilly opened this issue Jul 10, 2020 · 0 comments
Labels
difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding epic kind/bug Something isn't working project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..) project/navigation-lifecycle 🧬 Categorizes an issue or PR as relevant to the navigation and lifecycle (NavigationView, AppBar, ...)

Comments

@carldebilly
Copy link
Member

carldebilly commented Jul 10, 2020

Epic issue - Controls initialization sequence

This issue will try to regroup the following ones:

Sequence of events on UWP

Lets suppose we have 2 controls in a direct parent/child relationship (on the logical tree) called outer and inner. Those 2 controls are created at the same time from the same XAML file like this:

<Grid DataContext="myContext">
    <OuterControl x:Name="outer" Style="{StaticResource OuterControlStyle}">
        <OuterControl.Content>
            <InnerControl x:name="inner" Style="{StaticResource InnerControlStyle}" />
        </OuterControl.Content>
    </OuterControl>
</Grid>

Here's the sequence of the initialization of those controls on UWP:

  1. outer receive DataContextChanged event
  2. outer gets assignments for all setters from OuterControlStyle -- note: templates are not materialized yet
  3. outer receive Loading event
  4. outer control template gets materialized
  5. outer gets called for ApplyTemplate()
  6. outer gets called for MeasureOverride(). Calling base.MeasureOverride() will call:
    a. inner receive DataContextChanged event
    b. inner gets assignments for all setters from InnerControlStyle
    c. inner receive Loading event
    d. inner control template gets materialized
    e. inner gets called for ApplyTemplate()
    f. inner gets called for MeasureOverride()
  7. outer gets called for ArrangeOverride(). Calling base.ArrangeOverride() will call:
    a. inner gets called for ArrangeOverride()
  8. outer receive the SizeChanged event
  9. inner receive the SizeChanged event
  10. outer receive the Loaded event
  11. inner received the Loaded event

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • macOS [not tested yet]

Problems

  1. On UWP, OnApplyTemplate() is called during the first measure phase (step 6). Currently on Uno (all platforms) it's called synchronously with the assignation to the Template (ControlTemplate) property (step 4)
  2. On Wasm, inner receives twice t he Loading event
  3. On Uno (all platforms), the DataContextChanged is raised synchronously with the assignation. Should be deferred to the first measure phase (6.a.)
  4. On Uno (all platforms), the control template gets materialized synchrnously during the Template assignation and ApplyTemplate is also called immediatly. They should be be deferred to the first measure phase. Or, at least, the call to ApplyTemplate should be deferred.
  5. On iOS, the inner gets unloaded + reloaded after its template has been materialized
  6. Loading should be raised on outer before inner (incorrect on iOS)
  7. SizeChanged should be raised on outer before inner (correct only on iOS)
  8. SizeChanged should be raised BEFORE the Loaded event for both inner & outer (all platforms)
  9. Loaded should be raison on outer before inner (correct only on Android)
@carldebilly carldebilly added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jul 10, 2020
@carldebilly carldebilly changed the title Controls initialization sequence [EPIC] Controls initialization sequence Jul 14, 2020
@francoistanguay francoistanguay added this to the 3.1 milestone Aug 29, 2020
@francoistanguay francoistanguay removed the triage/untriaged Indicates an issue requires triaging or verification label Aug 29, 2020
@francoistanguay francoistanguay removed this from the 3.1 milestone Aug 31, 2020
@agneszitte agneszitte added the project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..) label Sep 21, 2020
@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@MartinZikmund MartinZikmund added difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding epic kind/bug Something isn't working project/layout 🧱 Categorizes an issue or PR as relevant to layouting and containers (Measure/Arrange, Collections,..) project/navigation-lifecycle 🧬 Categorizes an issue or PR as relevant to the navigation and lifecycle (NavigationView, AppBar, ...)
Projects
None yet
Development

No branches or pull requests

6 participants