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

fix: WASM deadlock on AdvancedXBind sample #549

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
113 changes: 76 additions & 37 deletions UI/AdvancedXBind/AdvancedXBind.Shared/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,77 @@
<Page
x:Class="AdvancedXBind.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:AdvancedXBind.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="using:System"
xmlns:vm="using:AdvancedXBind.ViewModel"
mc:Ignorable="d"
Background="White"
>
<Page.Resources>
<converters:DoubleToStringConverter x:Key="DoubleToStringConverter"/>
</Page.Resources>
<Grid DataContext="{x:Bind vm:PlanetViewModel.Create('Jupiter')}" Margin="40" RowSpacing="20" ColumnSpacing="10" HorizontalAlignment="Stretch" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Planet.Name}" Grid.ColumnSpan="2" HorizontalAlignment="Center" FontSize="32" Foreground="IndianRed" Margin="5,5,5,15"/>
<TextBlock Grid.Row="1" HorizontalAlignment="Right" TextWrapping="WrapWholeWords" FontWeight="Bold" >Enter your weight on Earth:</TextBlock>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="tb" />
<TextBlock Grid.Row="2" HorizontalAlignment="Right" TextWrapping="WrapWholeWords" FontWeight="Bold">Your weight on Jupiter:</TextBlock>
<TextBlock Text="{x:Bind ViewModel.WeightOnPlanet(tb.Text), Mode=OneWay}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"/>
<Button Grid.Row="3" HorizontalAlignment="Right" Content="Display Planet Information" Click="{x:Bind DisplayPlanetSync}"/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{x:Bind GetResultOfAsyncMethod()}"/>
<TextBlock Grid.Row="4" HorizontalAlignment="Right" FontWeight="Bold" TextWrapping="WrapWholeWords" Text="Approx Planet Density (KG/M3):"/>
<TextBlock Grid.Row="4" Grid.Column="1" Text="{x:Bind ViewModel.CalculateDensity(ViewModel.Planet.Mass, ViewModel.Planet.Diameter)}"/>
</Grid>
<Page x:Class="AdvancedXBind.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:AdvancedXBind.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="using:System"
xmlns:wasm="http://uno.ui/wasm"
xmlns:vm="using:AdvancedXBind.ViewModel"
mc:Ignorable="d wasm"
Background="White">

<Page.Resources>
<converters:DoubleToStringConverter x:Key="DoubleToStringConverter" />
</Page.Resources>
<Grid DataContext="{x:Bind vm:PlanetViewModel.Create('Jupiter')}"
Margin="40"
RowSpacing="20"
ColumnSpacing="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Planet.Name}"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
FontSize="32"
Foreground="IndianRed"
Margin="5,5,5,15" />
<TextBlock Grid.Row="1"
HorizontalAlignment="Right"
TextWrapping="WrapWholeWords"
FontWeight="Bold">
Enter your weight on Earth:
</TextBlock>
<TextBox Grid.Row="1"
Grid.Column="1"
x:Name="tb" />
<TextBlock Grid.Row="2"
HorizontalAlignment="Right"
TextWrapping="WrapWholeWords"
FontWeight="Bold">
Your weight on Jupiter:
</TextBlock>
<TextBlock Text="{x:Bind ViewModel.WeightOnPlanet(tb.Text), Mode=OneWay}"
Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="2" />

<!-- The button is disabled on WASM because of this issue: https://github.com/unoplatform/uno/issues/13370 -->
<Button Grid.Row="3"
HorizontalAlignment="Right"
Content="Display Planet Information"
wasm:IsEnabled="False"
Click="{x:Bind DisplayPlanetSync}" />
<TextBlock Grid.Row="3"
Grid.Column="1"
Text="{x:Bind GetResultOfAsyncMethod()}" />
<TextBlock Grid.Row="4"
HorizontalAlignment="Right"
FontWeight="Bold"
TextWrapping="WrapWholeWords"
Text="Approx Planet Density (KG/M3):" />
<TextBlock Grid.Row="4"
Grid.Column="1"
Text="{x:Bind ViewModel.CalculateDensity(ViewModel.Planet.Mass, ViewModel.Planet.Diameter)}" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ public async Task<string> SimulateLongRunningMethodAsync()
{
DateTimeOffset now = DateTimeOffset.Now;
Stopwatch sw = Stopwatch.StartNew();
await Task.Delay(50);
sw.Stop();
// We cannot use Delay on WASM because of this issue: https://github.com/unoplatform/uno/issues/13370
#if !__WASM__
await Task.Delay(50);
#endif
sw.Stop();
return $"Started {now} Elapsed: {sw.Elapsed}";
}
}
Expand Down