Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/ReleaseNotes/_ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
* [Pivot] Add support for non PivotItem items
* #1557 Fix local DataContext on ContentDialog is overwritten
* [WASM] Fix display for multiple popups (eg ComboBox inside of ContentDialog)
* [Android] Fix invalid ImageBrush stack overflow with delayed image reuse

## Release 1.45.0
### Features
Expand Down
5 changes: 5 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media\ImageBrushTests\ImageBrush_SameWithDelay.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media\ImageBrushTests\ImageBrush_StreamSource.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -3494,6 +3498,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media\ImageBrushTests\ImageBrushWithScaleTransform.xaml.cs">
<DependentUpon>ImageBrushWithScaleTransform.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media\ImageBrushTests\ImageBrush_SameWithDelay.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Media\ImageBrushTests\ImageBrush_StreamSource.xaml.cs">
<DependentUpon>ImageBrush_StreamSource.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<UserControl
x:Class="UITests.Shared.Windows_UI_Xaml_Media.ImageBrushTests.ImageBrush_SameWithDelay"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Shared.Windows_UI_Xaml_Media.ImageBrushTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<Grid>
<StackPanel>
<TextBlock Text="This should not crash the app, when the same URL is used twice with delays." />
<Ellipse Width="200"
Height="200">
<Ellipse.Fill>
<ImageBrush x:Name="imageBrush" ImageSource="{Binding ImgSource}" Stretch="UniformToFill"/>
</Ellipse.Fill>
</Ellipse>

<Ellipse Width="200"
Height="200">
<Ellipse.Fill>
<ImageBrush ImageSource="{Binding ImgSource2}" Stretch="UniformToFill"/>
</Ellipse.Fill>
</Ellipse>
</StackPanel>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Uno.UI.Samples.Controls;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace UITests.Shared.Windows_UI_Xaml_Media.ImageBrushTests
{
[SampleControlInfo("ImageBrushTestControl", "ImageBrush_SameWithDelay")]
public sealed partial class ImageBrush_SameWithDelay : UserControl
{
BrushContext _ctx = new BrushContext();

public ImageBrush_SameWithDelay()
{
this.InitializeComponent();

DataContext = _ctx;

Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => _ctx.ImgSource = "https://lh5.ggpht.com/lxBMauupBiLIpgOgu5apeiX_YStXeHRLK1oneS4NfwwNt7fGDKMP0KpQIMwfjfL9GdHRVEavmg7gOrj5RYC4qwrjh3Y0jCWFDj83jzg");

imageBrush.ImageOpened += (s, e) => {
_ctx.ImgSource2 = "https://lh5.ggpht.com/lxBMauupBiLIpgOgu5apeiX_YStXeHRLK1oneS4NfwwNt7fGDKMP0KpQIMwfjfL9GdHRVEavmg7gOrj5RYC4qwrjh3Y0jCWFDj83jzg";
};
}
}

public class BrushContext : INotifyPropertyChanged
{
private string _imageSource;
private string _imageSource2;

public string ImgSource
{
get { return _imageSource; }
set
{
_imageSource = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ImgSource)));
}
}

public string ImgSource2
{
get { return _imageSource2; }
set
{
_imageSource2 = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ImgSource2)));
}
}

public event PropertyChangedEventHandler PropertyChanged;
}
}
3 changes: 2 additions & 1 deletion src/Uno.UI/UI/Xaml/Media/ImageBrush.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ internal void ScheduleRefreshIfNeeded(Windows.Foundation.Rect drawRect, Action o
//TODO: should also check if Stretch has changed
if (_imageSourceChanged || !drawRect.Equals(_lastDrawRect))
{
_imageSourceChanged = false;

if (ImageSource != null)
{
RefreshImageAsync(drawRect);
Expand All @@ -55,7 +57,6 @@ internal void ScheduleRefreshIfNeeded(Windows.Foundation.Rect drawRect, Action o
{
_refreshPaint.Disposable = null;
}
_imageSourceChanged = false;
_lastDrawRect = drawRect;
}
}
Expand Down