diff --git a/doc/ReleaseNotes/_ReleaseNotes.md b/doc/ReleaseNotes/_ReleaseNotes.md index 3bed5ccefc52..7d3a34cad517 100644 --- a/doc/ReleaseNotes/_ReleaseNotes.md +++ b/doc/ReleaseNotes/_ReleaseNotes.md @@ -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 diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index 31e6ad467434..5925459cf47d 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -2061,6 +2061,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -3494,6 +3498,7 @@ ImageBrushWithScaleTransform.xaml + ImageBrush_StreamSource.xaml diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/ImageBrushTests/ImageBrush_SameWithDelay.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/ImageBrushTests/ImageBrush_SameWithDelay.xaml new file mode 100644 index 000000000000..0c197053dbcc --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/ImageBrushTests/ImageBrush_SameWithDelay.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/ImageBrushTests/ImageBrush_SameWithDelay.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/ImageBrushTests/ImageBrush_SameWithDelay.xaml.cs new file mode 100644 index 000000000000..b6e51e3c632c --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/ImageBrushTests/ImageBrush_SameWithDelay.xaml.cs @@ -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; + } +} diff --git a/src/Uno.UI/UI/Xaml/Media/ImageBrush.Android.cs b/src/Uno.UI/UI/Xaml/Media/ImageBrush.Android.cs index c0c91a1202b9..a61d35f69d88 100644 --- a/src/Uno.UI/UI/Xaml/Media/ImageBrush.Android.cs +++ b/src/Uno.UI/UI/Xaml/Media/ImageBrush.Android.cs @@ -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); @@ -55,7 +57,6 @@ internal void ScheduleRefreshIfNeeded(Windows.Foundation.Rect drawRect, Action o { _refreshPaint.Disposable = null; } - _imageSourceChanged = false; _lastDrawRect = drawRect; } }