This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1853 fixes #12080 * Remove all the semaphore workaround stuff and fix the extra GetCell calls that were messing up the internal UICollectionView bookkeeping; fixes #11853 * Include the unit test project in the filter * Prevent adds to uninitialized CollectionViews on iOS * Pull in initialization fixes from 5.0.0 * Remove scroll requirement for 11224 test
- Loading branch information
Showing
10 changed files
with
333 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue11853.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<controls:TestContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue11853"> | ||
<ContentPage.Content> | ||
<Grid RowDefinitions="Auto,320,*"> | ||
<StackLayout BackgroundColor="LightGoldenrodYellow"> | ||
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0"> | ||
<StackLayout> | ||
<Label Text="Repro CollectionView crash on iOS" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/> | ||
</StackLayout> | ||
</Frame> | ||
<Button Text="Run" AutomationId="Run" HorizontalOptions="Start" Command="{Binding TestCommand}" /> | ||
</StackLayout> | ||
|
||
<ScrollView Grid.Row="1"> | ||
<CollectionView | ||
HeightRequest="50" IsVisible="{Binding IsListVisible}" | ||
ItemsSource="{Binding Items}"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout Padding="20,30,20,0"> | ||
<Label Text="{Binding Text}" TextColor="DeepPink" FontSize="Body"/> | ||
<BoxView HeightRequest="1" BackgroundColor="LightPink" Margin="0,30,0,0" /> | ||
</StackLayout> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</ScrollView> | ||
|
||
</Grid> | ||
</ContentPage.Content> | ||
</controls:TestContentPage> |
116 changes: 116 additions & 0 deletions
116
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue11853.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
using System.Threading.Tasks; | ||
using Xamarin.Forms.Xaml; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Windows.Input; | ||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 11853, "[Bug][iOS] Concurrent issue leading to crash in SemaphoreSlim.Release in ObservableItemsSource", | ||
PlatformAffected.iOS)] | ||
#if UITEST | ||
[NUnit.Framework.Category(UITestCategories.CollectionView)] | ||
#endif | ||
public partial class Issue11853 : TestContentPage | ||
{ | ||
const string Run = "Run"; | ||
|
||
protected override void Init() { } | ||
|
||
public Issue11853() | ||
{ | ||
#if APP | ||
InitializeComponent(); | ||
#endif | ||
BindingContext = new _11853ViewModel(); | ||
} | ||
|
||
#if UITEST | ||
[Test] | ||
public void JustWhalingAwayOnTheCollectionViewWithAddsAndClearsShouldNotCrash() | ||
{ | ||
RunningApp.WaitForElement(Run); | ||
RunningApp.Tap(Run); | ||
Task.Delay(5000).Wait(); | ||
RunningApp.Tap(Run); | ||
Task.Delay(5000).Wait(); | ||
|
||
// If we can still find the button, then we didn't crash | ||
RunningApp.WaitForElement(Run); | ||
} | ||
#endif | ||
|
||
public class _11853Item | ||
{ | ||
public string Text { get; set; } | ||
} | ||
|
||
public class _11853ViewModel : INotifyPropertyChanged | ||
{ | ||
private bool isListVisible; | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public bool IsListVisible | ||
{ | ||
get => isListVisible; | ||
set | ||
{ | ||
isListVisible = value; | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsListVisible))); | ||
} | ||
} | ||
|
||
public ObservableCollection<_11853Item> Items { get; } | ||
public ICommand TestCommand { get; } | ||
|
||
public _11853ViewModel() | ||
{ | ||
Items = new ObservableCollection<_11853Item>(); | ||
TestCommand = new Command(async () => | ||
{ | ||
var items = CreateItems(10, 0).ToList().First(); | ||
var items2 = CreateItems(10, 0).ToList().Skip(1).First(); | ||
int iterations = 1000; //10000; | ||
for (var i = 0; i < iterations; i++) | ||
{ | ||
await Task.Delay(1); | ||
Items.Add(items); | ||
await Task.Delay(2); | ||
Items.Add(items2); | ||
await Task.Delay(2); | ||
Items.Clear(); | ||
await Task.Delay(2); | ||
Items.Add(items); | ||
Items.Add(items2); | ||
await Task.Delay(2); | ||
} | ||
}); | ||
} | ||
|
||
IEnumerable<_11853Item> CreateItems(int count, int batch) | ||
{ | ||
var i = 0; | ||
while (count-- > 0) | ||
yield return new _11853Item { Text = $"Item {i++} Batch {batch}" }; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.