Bug 59716 - NRE on ListView's cell update when templated with grid and label
Summary: NRE on ListView's cell update when templated with grid and label
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS (show other bugs)
Version: 2.4.0
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-09-25 08:21 UTC by mailcannon
Modified: 2017-11-21 14:11 UTC (History)
6 users (show)

See Also:
Tags: hasunevenrows, listview, ac
Is this bug a regression?: ---
Last known good build:

repro project (186.09 KB, application/x-7z-compressed)
2017-09-25 08:21 UTC, mailcannon

Description mailcannon 2017-09-25 08:21:37 UTC
Created attachment 24908 [details]
repro project

I have this xaml. And items adding by an event(i.e. asynchronously).

        <Button Text="Update" Command="{Binding UpdateListCommand}" />
        <ListView ItemsSource="{Binding Items}"
                                Text="{Binding }"

When HasUnevenRows="True", application crashes exactly on third click on "Update" button with NullReferenceException in LabelRenderer. 
When i set HasUnevenRows="False" or remove the Grid or make list updating synchronous - everything working fine.
Repro project included
Comment 1 Paul DiPietro [MSFT] 2017-09-25 19:33:11 UTC
Verified testing the behavior against 2.4.0-pre3.
Comment 2 mailcannon 2017-10-02 11:30:25 UTC
still crashes with
Comment 3 mailcannon 2017-10-03 09:37:25 UTC
the workarround i found is:

to set CachingStrategy="RecycleElement" ||
to set HasUnevenRows="False" ||
to remove the Grid from viewcell template
Comment 4 mailcannon 2017-10-03 09:41:35 UTC
I changed all ListView's behaviours to CachingStrategy="RecycleElement", bun unfortunatelly, app is still crashes rarely with labels that are not in ViewCell template.

Xamarin.Forms.Platform.iOS.LabelRenderer.OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
<Module>.invoke_void_object_PropertyChangedEventArgs(object, PropertyChangedEventArgs)(wrapper delegate-invoke)
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)
Xamarin.Forms.Element.OnPropertyChanged(string propertyName)
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent)
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)
Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)
Xamarin.Forms.BindingExpression.Apply(bool fromTarget)
UIKit.UIApplication.UIApplicationMain(int, string[], intptr, intptr)(wrapper managed-to-native)
UIKit.UIApplication.Main(string[] args, IntPtr principal, IntPtr delegate)
UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName)
TimeTracker.iOS.Application.Main(string[] args)

as you can see, crashes after OnElementPropertyChanged call as well aw when label is in ViewCell template.
Comment 5 mailcannon 2017-10-03 09:44:58 UTC
Also, i found out that if i remove any labels from my own application, its still crashes with ObjectDisposedException on images that are left in ViewCell template.
Comment 6 mailcannon 2017-10-03 09:50:52 UTC
In repro project, if change
  Text="{Binding }"



then app is crashing after few updates with 

NSInternalInconsistencyException Reason: table view row height must not be negative - provided height for index path (<UIMutableIndexPath 0x7fa282b88110> 2 indexes [0, 0]) is -1.000000

no matter what CachingStrategy is set.
Comment 7 mailcannon 2017-10-03 09:51:24 UTC
please, do something, this is not stable at all
Comment 8 cjw1115@hotmail.com 2017-10-24 08:31:18 UTC
it's a bug about ListViewRenderer.
When I install Xamarin.Forms2.3.4,everything is ok.But when I install Xamarin.Fomrs2.4.0,the app will be crash when the itemsource changed frequently.
And I have made a git diff between 2.3.4 and 2.4.0 version about ListViewRenderer.cs,I found that the renderer is almost refactor.
Comment 9 otyq08 2017-11-13 21:23:11 UTC
I'm also running into that problem, please fix.
Mailcannon please set the regression flag to true.
Comment 10 mailcannon 2017-11-21 07:10:13 UTC
repro project is not crashing anymore with
Comment 11 Paul DiPietro [MSFT] 2017-11-21 14:11:36 UTC
Thank you for the update; presumed resolved.

Note You need to log in before you can comment on or make changes to this bug.