Metriche repository
- Star
- (5644 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Description
Crash in Layout.ResolveLayoutChanges: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
Steps to Reproduce
Steps are unknown yet, we are trying to reliably recreate it. We are seeing the crashes through AppCenter and are getting plenty of them across different Android devices.
I have a console app that replicates the underlying bug: https://gist.github.com/slang25/f26349340f74300d67f7c552cb2b2493
Expected Behavior
No crash.
Actual Behavior
In a StackLayout, in Layout.OnChildMeasureInvalidated, it should queue up layout update operations in s_resolutionList for Layout.ResolveLayoutChanges to process.
Layout.ResolveLayoutChanges "copies" s_resolutionList, however it copies the reference, this means that if GetElementDepth is slow during OnChildMeasureInvalidated, it could have dereferenced the old list. By adding an item to the old s_resolutionList reference, it risks this exception for occurring.
Other Information
Console app that replicates basic non-thread-safe underlying issue can be found here: https://gist.github.com/slang25/f26349340f74300d67f7c552cb2b2493
There are a few quick fixes, including this: https://github.com/xamarin/Xamarin.Forms/compare/xamarin:master...slang25:fix-layout-crash?expand=1
But I'd like to work on a more complete fix.