Xamarin.forms: [Bug][iOS] Concurrent issue leading to crash in SemaphoreSlim.Release in ObservableItemsSource

Created on 19 Aug 2020  ·  27Comments  ·  Source: xamarin/Xamarin.Forms

Description

Calls to ObservableItemsSource.BatchUpdate should be synchronized to prevent a crash in _batchUpdating.Release(), because this last one can be called 2 times in a row and will fail the second time.

https://github.com/xamarin/Xamarin.Forms/blob/main/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs

Steps to Reproduce

I am able to reproduce this issue easily in my customer's app.
I've already checked that all calls are done on the main thread.

It happens nearly everytime when updating the bound ObservableCollection 3 times in a row:
1st deleting some items, 2nd inserting some new items, 3rd moving some existing items (it's an algorithm that compute the changes between an ObservableCollection and a "new" list, and apply the 3 above actions so after the ObservableCollection becomes equal to the list).

I've already checked that all 3 calls are done on the main thread.

Expected Behavior

don't crash

Actual Behavior

crash when releasing the SemaphoreSlim because its CurrentCount is already 1.

Stack trace:

SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.

  at System.Threading.SemaphoreSlim.Release (System.Int32 releaseCount) [0x0004c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/SemaphoreSlim.cs:795 
  at System.Threading.SemaphoreSlim.Release () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/SemaphoreSlim.cs:760 
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Reload () [0x00098] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:146 
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Add (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00037] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:165 
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00061] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:117 
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x000b7] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:108 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 
  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.20.2.2/src/Xamarin.iOS/Foundation/NSAction.cs:178 
--- End of stack trace from previous location where exception was thrown ---

Basic Information

  • Version with issue: 4.8
  • Last known good version: 4.5
  • IDE: VS Windows
  • Platform Target Frameworks:

    • iOS: latest stable

  • Affected Devices: iOS simulator

Screenshots

Reproduction Link

Repro app: https://github.com/softlion/ReproFormsCollectionViewBug
Run the app on an iOS simulator or device.

Tested on iOS 12.4 / iPhone 6 simulator.
But happens on all iOS OS and devices.

Does not happen on Android / UWP.

This app will trigger one of the 3 above crashes, which comes from different synchronization bugs.
The key is the change of the IsVisible property just before or after items have been added to the collectionviewsource.

Workaround

None

Other infos

I've checked the xamarin forms source code.

I'm pretty sure you can fix it easily by making BatchUpdate return a Task, then start BatchUpdate() with await _batchUpdating.WaitAsync(); instead of putting _batchUpdating.Wait() inside the PerformBatchUpdates action parameter.

collectionview 5 high iOS 🍎 bug

Most helpful comment

@softlion I built my own package including the fix, but that's actually pretty easy to do.

git clone https://github.com/bruzkovsky/Xamarin.Forms.git
cd Xamarin.Forms
git checkout fix-11853
./build.ps1 -Target NugetPack -ScriptArgs '-packageVersion="4.8.0-custom.1"'

Then use the package in a local nuget package source.

All 27 comments

@softlion Thanks for the feedback. Do you have a small example where reproduce the issue?.

This are the possible changes: https://gist.github.com/jsuarezruiz/341a2eea56dd9205729c317912b0bee5#file-gistfile1-txt-L362

I'm unable to reproduce the issue in a demo project.
So i'll double check that all calls are done on the main thread.

I can also confirm that I have days where it does not happen at all. But suddenly when my system is under load I sometimes get these exceptions in the iOS simulator.

I was using the ObservableRangeCollection by @jamesmontemagno and did add about 25 elements when the error occurs regularly.

It happens during the ItemThresholdCommand of a CollectionView, so my guess was that it's on the main thread anyway.

Ok I have a repro project ! I'll post it here.

Btw there are 3 different issues triggered by the same bug.
1

{System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index at System.Collections.Generic.List1[T].get_Item (System.Int32 index) [0x00009] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/List.cs:161 at System.Collections.ObjectModel.Collection1[T].System.Collections.IList.get_Item (System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:266 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.ElementAt (System.Int32 index) [0x0000f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:254 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.get_Item (System.Int32 index) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:40 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.get_Item (Foundation.NSIndexPath indexPath) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:96 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x00012] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:199 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath) [0x00033] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:84 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.20.2.2/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.20.2.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at ReproApp.iOS.Application.Main (System.String[] args) [0x00001] in D:\repos\ReproApp\ReproApp.iOS\Main.cs:17 }

2

[CollectionView] An attempt to prepare a layout while a prepareLayout call was already in progress (i.e. reentrant call) has been ignored. Please file a bug. UICollectionView instance is (; layer = ; contentOffset: {0, 0}; contentSize: {375, 0}; adjustedContentInset: {0, 0, 0, 0}> collection view layout: )

3

{System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count. at System.Threading.SemaphoreSlim.Release (System.Int32 releaseCount) [0x0004c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/SemaphoreSlim.cs:795 at System.Threading.SemaphoreSlim.Release () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/SemaphoreSlim.cs:760 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Reload () [0x00098] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:146 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Add (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00037] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:165 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00061] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:117 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x000b7] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:108 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.20.2.2/src/Xamarin.iOS/Foundation/NSAction.cs:178 --- End of stack trace from previous location where exception was thrown --- at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.20.2.2/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.20.2.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at ReproApp.iOS.Application.Main (System.String[] args) [0x00001] in D:\repos\ReproApp\ReproApp.iOS\Main.cs:17 } | System.Threading.SemaphoreFullException

Repro app: https://github.com/softlion/ReproFormsCollectionViewBug
Run the app on an iOS simulator or device.

Tested on iOS 12.4 / iPhone 6 simulator.
But happens on all iOS OS and devices.

Does not happen on Android / UWP.

This app will trigger one of the 3 above crashes, which comes from different synchronization bugs.
The key is the change of the IsVisible property just before or after items have been added to the collectionviewsource.

Please fix it fast as i gave you a 1 line change solution + a repro app.

I've PR only once in Forms and it's 4 years ago. I'm not sure how much time it will now require to: clone the repo / build a local nuget / add all forms projects to the repro app / make sure the issue still triggers / fix it / rebase the repo / create a fix branch / push / commit / pr / receive feedbacks / re-rebase / re-commit

image

image

@samhouts @hartez FWIW, we're seeing this error happen often in production as well on 4.7.0.latest. @softlion Thanks for the great details in the bug. Would really appreciate traction on this bug given a fix has already been proposed.

I also use CollectionView on a ContentPage. When I return to previous Page I always get the exception shown below.
This only happen if the collection has more than one item. This does not happen with just one item and it also works fine with UWP and Android. It only happen with iOS. This is a show stopper and not sure of a work around. Please fix it ASAP or provide a work around. Thanks.

◢ | $exception | {System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count. at System.Threading.SemaphoreSlim.Release (System.Int32 releaseCount) [0x0004c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/SemaphoreSlim.cs:795 at System.Threading.SemaphoreSlim.Release () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/threading/SemaphoreSlim.cs:760 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Reload () [0x00098] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:146 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00198] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:129 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x000b7] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewObservableItemsSource.cs:108 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/Foundation/NSAction.cs:178 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at Geometrics.AtomDownloader.iOS.Application.Main (System.String[] args) [0x00001] in C:\Project\XappsDev\AtomDownloaderXF\AtomDownloader.iOS\Main.cs:12 } | System.Threading.SemaphoreFullException

We've just updated a handful of apps to 4.8, from 4.4 and 4.5, with no other NuGet packages and we are seeing the same issues.

This issue is really easy to reproduce: Just fire one change event (Add/Remove) and right afterwards a Reset -> boom 💣💥. Looking at the implementation of BatchUpdates, it becomes very clear as to why that is:

```c#
void BatchUpdate(Action update)
{
_collectionView.PerformBatchUpdates(() =>
{
if (_batchUpdating.CurrentCount > 0) // if the semaphore is empty, just ignore it ¯_(ツ)_/¯ what bad should happen?
{
_batchUpdating.Wait();
}

    update();
},
        (_) =>
        {
            if (_batchUpdating.CurrentCount == 0) // anyway, I think we should release it, but only if it is not full already...
            {
                _batchUpdating.Release();
            }
        });

}


How on earth did this pass code review?

## Update

This is the reproduction code:

```c#
var collectionView = new CollectionView { ItemsSource = items };
var startButton = new Button { Text = "Start test" };
startButton.Clicked += (sender, args) =>
{
  var random = new Random();
  items.RemoveAt(random.Next(0, 99));
  items.RemoveAt(random.Next(0, 98));
  items.RemoveAt(random.Next(0, 97));
  items.Clear();
};

After fixing the semaphore issue, I encountered a much uglier problem that is not so easy to fix: Updates to the UICollectionView are performed async, but they sometimes use the _itemsSource field (e.g. when GetCell is called). But the _itemsSource can already have changed at this time! This leads to e.g. an IndexOutOfBoundsException and others. So I have to put some more effort into fixing this than originally thought... Will make a PR once I have some progress to share....

@bruzkovsky I do have a clean implementation of this for mvvmcross. Along with a clean implementation of a range observable collection perfectly working with that, much powerful than the one they put in .net5, and much older that the one your tech guru created some years ago. My code was started 6 years ago and is fully stable on hundred devices in a dozen of apps. It would be easy for me to move that to xamarin forms.

But this is a code that took me a very long time to architecture and build. I have nights on this. And i'm not 13th anymore (i'm 48 lol).

So i have some difficulties to give it to the open source community. Especially indian peoples that steal my mobile dev job (sorry mates but its true). I'm already an open source contributor with great components i hope, and xamarin forms core code contributions too, so it's not a problem of open source.

@softlion I'm sorry I cannot follow you. I didn't mean to suggest that you have to do anything, the problem is entirely on the XF side. I wanted to show that the ObservableItemsSource in its current state does not even work correctly with a plain ObservableCollection. My point is that the problem is more complicated than just the wrong use of SemaphoreSlim, therefore I proposed a refactoring of the whole ObservableItemsSource class in my PR, which also fixes this issue. It should also work with any ItemsSource that implements INotifyCollectionChanged correctly.

@bruzkovsky Any way to get this without waiting for an XF update ? Maybe using a custom renderer ?

@softlion I built my own package including the fix, but that's actually pretty easy to do.

git clone https://github.com/bruzkovsky/Xamarin.Forms.git
cd Xamarin.Forms
git checkout fix-11853
./build.ps1 -Target NugetPack -ScriptArgs '-packageVersion="4.8.0-custom.1"'

Then use the package in a local nuget package source.

@bruzkovsky I added your version to the Xamarin.iOS project only. It should replace any other versions coming from libraries ?

If yes, it still has the semaphore issue.

@softlion ugh, than can only mean that you don't have the right dll, because I deleted the SemaphoreSlim code here and here. But nuget should take the version that you have in your .iOS or .Android project, unless it's lower. Maybe you have to rebuild? Sometimes on iOS it just keeps the cached dlls.

@bruzkovsky rebuild worked. Ty!

@bruzkovsky I do have a clean implementation of this for mvvmcross. Along with a clean implementation of a range observable collection perfectly working with that, much powerful than the one they put in .net5, and much older that the one your tech guru created some years ago. My code was started 6 years ago and is fully stable on hundred devices in a dozen of apps. It would be easy for me to move that to xamarin forms.

But this is a code that took me a very long time to architecture and build. I have nights on this. And i'm not 13th anymore (i'm 48 lol).

So i have some difficulties to give it to the open source community. Especially indian peoples that steal my mobile dev job (sorry mates but its true). I'm already an open source contributor with great components i hope, and xamarin forms core code contributions too, so it's not a problem of open source.

Hi @bruzkovsky ,
Today, I got the same exception you found here. I previously came across other crashes, and I spent long days and nights to trace it, prepare a sample, and I even fixed it and shared it with XF. But today, I did not have to do all of this work, thanks to you. You saved me a lot of time.

But please, accept my words here. Xamarin community has offered us piles of free code that a lot of people spent thousands of days on. And they provided it to us for free and probably a lot of them were Indians. I understand that an
Indian person had hurt you in the past but remember it is not because he was Indian ;) .

One last thing, last year I submitted a fix that was only one line of code. Xamarin team spent a lot of time reviewing my code, testing it, refactoring it etc. At the end, they used different code but still they were kind enough to give me the credit by pulling the commit under my name. I encourage you to share your code.

I wish you the best.

@bruzkovsky I still have one crash.
image

{System.ObjectDisposedException: Cannot access a disposed object.Object name: 'GroupableItemsViewController`1'.  at Foundation.NSObject.get_SuperHandle () [0x0004a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/Foundation/NSObject2.cs:401   at UIKit.UIViewController.get_IsViewLoaded () [0x00023] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UIViewController.g.cs:2147   at Xamarin.Forms.Platform.iOS.ObservableItemsSource.NotLoadedYet () [0x00001] in D:\repos\_clones\Xamarin.FormsCollectionViewFixed\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:286   at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00001] in D:\repos\_clones\Xamarin.FormsCollectionViewFixed\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:130   at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x000ba] in D:\repos\_clones\Xamarin.FormsCollectionViewFixed\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:124   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021   at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/Foundation/NSAction.cs:178   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UIApplication.cs:86   at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UIApplication.cs:65   at WzXam2.iOS.Application.Main (System.String[] args) [0x00001] in C:\Dev\repos\MyApp\MyApp.iOS\Lib\Startup\Main.cs:12 }

@softlion This is another nasty issue, which doesn't seem to be fixed soon...
https://github.com/xamarin/Xamarin.Forms/issues/8308

In my case it happens when I delete entries of a list in a loop as follows:

var count = list.Count;
for (int i = 0; i < count; i++)
  list.RemoveAt(0);

But if I just call Clear I don't get the error
list.Clear();

Still not fixed in Xamarin Forms 5 prerelease

image

@bruzkovsky have you updated your clone to apply the fix the xamarin forms 5 prerelease ?

I tried to checkout the 5 branch and apply your fix but after that building fails:

"C:\Dev\repos\_clones\Xamarin.Forms.Bruzkovsky\Xamarin.Forms.sln" (Build cible) (1) ->
"C:\Dev\repos\_clones\Xamarin.Forms.Bruzkovsky\Xamarin.Forms.ControlGallery.WindowsUniversal\Xamarin.Forms.ControlGalle
ry.WindowsUniversal.csproj" (cible par défaut) (27) ->
(_ComputeAppxPackagePayload cible) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Micro
soft.AppXPackage.Targets(1943,5): error APPX1111: Payload contains two or more files with the same destination path 'Xa
marin.Forms.Xaml.pdb', but they are different sizes. Source files:  [C:\Dev\repos\_clones\Xamarin.Forms.Bruzkovsky\Xama
rin.Forms.ControlGallery.WindowsUniversal\Xamarin.Forms.ControlGallery.WindowsUniversal.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microso
ft.AppXPackage.Targets(1943,5): error APPX1111: C:\Dev\repos\_clones\Xamarin.Forms.Bruzkovsky\Xamarin.Forms.Controls\bi
n\Debug\netstandard2.0\Xamarin.Forms.Xaml.pdb [C:\Dev\repos\_clones\Xamarin.Forms.Bruzkovsky\Xamarin.Forms.ControlGalle
ry.WindowsUniversal\Xamarin.Forms.ControlGallery.WindowsUniversal.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microso
ft.AppXPackage.Targets(1943,5): error APPX1111: C:\Dev\repos\_clones\Xamarin.Forms.Bruzkovsky\Xamarin.Forms.Platform.UA
P\bin\Debug\uap10.0.14393\Xamarin.Forms.Xaml.pdb [C:\Dev\repos\_clones\Xamarin.Forms.Bruzkovsky\Xamarin.Forms.ControlGa
llery.WindowsUniversal\Xamarin.Forms.ControlGallery.WindowsUniversal.csproj]

Hi @softlion , sorry for the delay, busy week...
I still have my fix targeted on 4.8, but I think I'll have to switch to 5.0.0 to get my PR merged anyway. Your error looks like it could be solved by restarting VS or your machine. Did you succeed in applying the change?

No I have not been able to fix the build issue.

About your workaround, it duplicates the content of the list. This is not optimal.

I do have an implementation of this for mvvmcross which is both efficient and safe.

It does freeze the list state between updates but does not duplicate the items.

@softlion so please share it then :)

Strange that the items are duplicated. I tested the fix with a lot of rapid modifications to the list and didn't find any issue. But I still want to test it in our production app next week, maybe I'll find more errors there...

Was this page helpful?
0 / 5 - 0 ratings