Closed timrisi closed 6 years ago
As another point of info, I just tested on Android (been on iOS) and the same crash does not occur there.
Still fails with master
Hm, can't get this running with a debug build. Looks like the warnings may be hanging the build. And I cannot disable them. Sigh.
@timrisi any chance you could try install the nightly and clean out some of the warnings?
I'll try it out
I haven't had the time yet to clean up warnings (and for some reason, if I load up the project in VS on windows I get over 2000 warnings. Just over 30 in VSfM. Mostly stuff like
Warning CA2140 Transparent method 'SingleUpgradeViewModel.SingleUpgradeViewModel()' references security critical method 'ViewModel.ViewModel()'. In order for this reference to be allowed under the security transparency rules, either 'SingleUpgradeViewModel.SingleUpgradeViewModel()' must become security critical or safe-critical, or 'ViewModel.ViewModel()' become security safe-critical or transparent.).
Never seen those before this. I did at least have time to install the nightly and try it with that. Builds fine for me (debug, iPhone Simulator), still gets the same crash using the nightly version of XF.
I'll see if I can get warnings cleaned up tomorrow.
Got it built/deployed on the latest nightly on my update iPhone 8 and I see no repro. Maybe it got fixed. Please let us know if you still see the crash.
Still crashing on 2.6.0.170883-nightly
Has anyone had a chance to look at this anymore? This is affecting numerous users on my current version of my app on the App Store, and I haven't managed to find a workaround yet.
We're still looking at this
Experimenting more with this yesterday and this morning, it looks like PR1569 fixes the problem. I pulled the source and made the single change of adding the
_prototype = null;
in the ListViewRenderer and it seems to be working fine without crashing in the simulator for me. I haven't been able to test it on device yet because I'm getting a code sign error that I'm still trying to figure out. I'll update again once I get it tested on device.
Excellent thank you, that might save me a lot of time as I was about to switch over to this on tuesday :)
Got the code signing figured out (gogo keychain issues). Built and ran it on device and it looks to be working successfully there without crashing as well. It also seems to fix a long-standing issue I've had with searching in a ListView (if you typed too fast). I am still getting another long-standing crash when searching in a Grouped ListView and having 0 results, but that's a different issue that doesn't need to be part of this one.
Shoot me a link
Sorry I meant your other crash
Ooh, haha. I haven't created an issue for that one myself. It looks like the same basic issue as https://bugzilla.xamarin.com/show_bug.cgi?id=59412. I have a grouped ListView with only 1 group showing, when searching it frequently crashes if the search result contains 0 items. SearchBar has the Text property bound to a string, setter for the string calls a method that filters what's in the collection and resets the ObservableCollection bound as the source of the ListView.
I also found https://forums.xamarin.com/discussion/55026/forms-listview-crashes-when-itemsource-has-item-removed-and-another-inserted today, where someone mentioned they only noticed the issue with the RecycleElement caching strategy. I tried changing the ListView to use RetainElement instead and so far it seems to have fixed the crash for me.
SearchText property is at https://github.com/timrisi/AuroraSquadBuilder/blob/master/SquadBuilder/ViewModel/Squadron/PilotsListViewModel.cs#L107 in my project
If you want to do me a favor at some point file it. It will go into the triage queue automatically when you do :)
Have tried this fix in 2.5.1 pre1, still behaving the same. Control is sometimes null and labelrenderer will fail. Surely if the control is null we should either be making a control or not bothering with the renderer? We're still having to rely on a labelrenderer override, doing null checks on control for any method that uses it.
Your original renderer only checks for a null control ONCE, in LayoutSubviews/Layout, line 75
Now that I think of it, I'm wondering if the inclusion of
Github #1435/Bugzilla 59813 - ""NullReferenceException" in "Xamarin.Forms.Platform.iOS.Renderers.LabelRenderer.cs" within "UpdateText()" & "UpdateTextColor()"" (#1216) (#1226) (#1244)
in the release notes might have been someone not checking the issue itself and just seeing "oh, that issue was closed therefore it must have been fixed."
If the Control is null and then you are getting crashes at this point it means the Renderer was disposed but then re-used anyway during Cell recycling. This is the root cause of the issue and no amount of null checking fixes that. We need to figure out where the disposed renderer is getting re-used and why. This is the single most complicated part of forms.
I understand that null checks will only mask the problem, but the reality for us is that with the checks the app works without noticeable issues - without them it'd crash so often that it would be unusable, so we'd be stuck with a very old version of forms, negating all the good work you've done since back then.
Are you using a TableView or a ListView that is getting you the crash?
we use listviews on a tabbed page but that page is not even in view when the null reference issue happens. So we get to a page, tap an item in the listview and that'll navigate to another page. On that page, we can do actions that will change the status of the object that is associated to the item we've tapped in the listview, which will cause some label to change in there. This will then fail on the labelrenderer with null reference exceptions.
We are also facing same exception even in 2.5.1 pre1
What recycling strategy are you using on these list views?
@jassmith We are using RecycleElement as recycling strategy
We're using CachingStrategy="RecycleElement"
I'm getting this error, even with 2.5.1.317207-pre1. I've been trying different CachingStrategy but it fails for any of them. But then, I've tried disabling HasUnevenRows and that did the trick, works like a charm. Hope it helps you trying to workaround or catch the root problem.
I've switched all three listviews to CachingStrategy="RetainElement" still crashes.
what appears to make it stop crashing is setting HasUnevenRows="False", which we can't use as our UI needs the flexibility to show different size listview items.
I'm on 2.5.1 pre2, by the way.
When you test this stuff could you go nuts and test it with uneven rows, 1000s of custom cells with all sorts of crazy stuff like gesture recognizers & grouping (only just got the UWP fix for this) etc etc please?
+1 when set HasUnevenRows="False" the problem fixed, but the UI goes crazy :(
This bug is affecting us badly as well with iOS devices in Forms 2.5.0.280555, any workaround? setting HasUnevenRows="false" isn't an option.
This issue also affects my codebase.
Fixed in 2.5.1-pre3
I was going to wait to close this until the pre-release went out on the small but possible chance our repro doesn't cover exactly what this repro does, but this bug is getting a lot of attention and I want people to know we believe it is fixed.
@jassmith
Thanks for the update Jason
@jassmith Thanks for your effort and update Json
@jassmith Thanks for the update and when 2.5.1-pre3 will be released?
just to confirm, the problem fixed
many thanks
I am now getting a new problem on iOS after upgrading to pre3. Works OK on Android/UWP when I clear the collection ready to fill it with new data.
Unhandled Exception:
System.ArgumentOutOfRangeException:
2018-03-23 13:02:55.078 XApp.iOS[621:401290] ConvertToNSExceptionAndAbort
2018-03-23 13:02:55.104 XApp.iOS[621:401290] Inserted Xamarin Exception Stack Line!
2018-03-23 13:02:55.104 XApp.iOS[621:401290] Name: System.ArgumentOutOfRangeException
2018-03-23 13:02:55.106 XApp.iOS[621:401290] MessageSystem.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.Xamarin Exception Stack:
Parameter name: index
at Xamarin.Forms.ListProxy.get_Item (System.Int32 index) [0x0000b] in D:\agent_work\1\s\Xamarin.Forms.Core\ListProxy.cs:127
at Xamarin.Forms.ListProxy.System.Collections.IList.get_Item (System.Int32 index) [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Core\ListProxy.cs:444
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].get_Item (System.Int32 index) [0x00008] in <61c9c84c76a542edaa908d1413be3995>:0 at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.HeaderViewDisplayingEnded (UIKit.UITableView tableView, UIKit.UIView headerView, System.nint section) [0x0000e] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:967 at (wrapper managed-to-native) ObjCRuntime.Messaging.voi d_objc_msgSend(intptr,intptr) at UIKit.UITableView.ReloadData () [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.8/src/Xamarin.iOS/UIKit/UITableView.g.cs:792 at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateItems (System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Int32 section, System.Boolean resetWhenGrouped) [0x002b2] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:599 at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:307 at Xamarin.Forms.Internals.TemplatedItemsList
2[TView,TItem].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <61c9c84c76a542edaa908d1413be3995>:0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].GroupedReset () [0x000b6] in <61c9c84c76a542 edaa908d1413be3995>:0 at Xamarin.Forms.Internals.TemplatedItemsList
2[TView,TItem].OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00459] in <61c9c84c76a542edaa908d1413be3995>:0
at Xamarin.Forms.Internals.TemplatedItemsList2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Boolean fixWindows) [0x00008] in <61c9c84c76a542edaa908d1413be3995>:0 at Xamarin.Forms.Internals.TemplatedItemsList
2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <61c9c84c76a542edaa908d1413be3995>:0
at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in D:\agent_work\1\s\Xamarin.Forms.Core\ListProxy.cs:233
at Xamarin.Forms.ListProxy+<>cDisplayClass33_0.1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000f] in <b65d24b2b3f9452c81c3e18faaf3900f>:0 at System.Collections.ObjectModel.ObservableCollection
1[T].OnCollectionReset () [0x00007] in 1[T].ClearItems () [0x00022] in <b65d24b2b3f9452c81c3e18faaf3900f>:0 at System.Collections.ObjectModel.Collection
1[T].Clear () [0x00014] in <8895ea4500b545169bb09a7b11e
bc56b>:0
at XApp.ViewModels.MeetingDocListViewModel.InitWithData (System.Int32 pubId, System.Int32 commId, System.Int32 meetingId) [0x00001] in c:\Projects\XApp\XApp\XApp\ViewModels\MeetingDocListViewModel.cs:48
at XApp.Views.MeetingDocListView.Initialise (System.Int32 pubId, System.Int32 commId) [0x0003c] in c:\Projects\XApp\XApp\XApp\Views\MeetingDocListView.xaml.cs:243
at XApp.Views.Root+
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.8/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.
@jassmith Finally had the chance to try 2.5.1 pre3 and couldn't get it to fail on my brief test - it was fairly easy to get it to do it beforehand so this seems like an improvement.
I've tested on hardware (iPhone 6, iOS 11.2.6) and this PR fixes our issue.
Definitely an improvement,
Thanks.
Hi,
While this seems fixed testing on hardware we still randomly get a crash testing on simulators (XCode 11.3).
2018-04-09 14:18:06.568 MyApp.iOS[9478:140208] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.52.10/UITableView.m:2012
Hi, i getting the same issue when using image in listview. This time happened in ImageRenderer。 I am using Xamarin.Forms 2.5.1-sr1
at Xamarin.Forms.Platform.iOS.EventTracker.LoadRecognizers () [0x0005d] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\EventTracker.cs:373
at Xamarin.Forms.Platform.iOS.EventTracker.OnElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs e) [0x0004e] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\EventTracker.cs:439
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs
1[TElement] e) [0x00020] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:279
at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs
1[TElement] e) [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:85
at Xamarin.Forms.Platform.iOS.ImageRenderer.<>n0 (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) <0x125bd6ec0 + 0x0005a> in
After updating to 2.5.1.444934 the problem was resolved. I was running version 2.5.0.122203 which had this issue.
Description
I posted on the XF forums about the issue (https://forums.xamarin.com/discussion/120074/crashing-in-xamarin-forms-platform-ios-labelrenderer-updatetext) but haven't had any responses yet, and it looks like a bug in Forms itself, not my code, so moving over to here.
I've been using XF 2.3.4.270 for quite a while now. With the last update, I finally updated ot a newer version (2.5.0.121934) so I could use the UseSafeAreas calls to support the iPhone X screen.. Everything seemed to be working fine in beta, and I released the update to the wild on iOS. Since releasing the update, I've started having reports trickle in from various users about the app crashing frequently. I never had 2 users reporting the exact same instance causing the crash, so it took quite a while to track down what was happening.
I finally figured out the sequence in app to make it crash (and why the reports differed so much), and started trying to find the cause. Debugging the app from VSfM gave me a rather unhelpful System.NullReferenceException on: UIApplication.Main (args, null, "AppDelegate");
After turning on "Show external symbols" for debugging I was finally able to get a more useful stack trace of:
Xamarin.Forms.Platform.iOS.LabelRenderer.UpdateText() in Xamarin.Forms.Platform.iOS.LabelRenderer.OnElementPropertyChanged(Xamarin.Forms.Label sender, System.ComponentModel.PropertyChangedEventArgs e) in Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName) in D:\agent_work\1\s\Xamarin.Forms.Core\BindableObject.cs:138 Xamarin.Forms.Element.OnPropertyChanged(string propertyName) in D:\agent_work\1\s\Xamarin.Forms.Core\Element.cs:401 Xamarin.Forms.BindableObject.SetValueActual(Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject.BindablePropertyContext context, string value, bool currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, bool silent) in D:\agent_work\1\s\Xamarin.Forms.Core\BindableObject.cs:594 Xamarin.Forms.BindableObject.SetValueCore(Xamarin.Forms.BindableProperty property, string value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject.SetValuePrivateFlags privateAttributes) in D:\agent_work\1\s\Xamarin.Forms.Core\BindableObject.cs:391 Xamarin.Forms.BindingExpression.ApplyCore(SquadBuilder.Pilot sourceObject, Xamarin.Forms.Label target, Xamarin.Forms.BindableProperty property, bool fromTarget) in D:\agent_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:174 Xamarin.Forms.BindingExpression.Apply(bool fromTarget) in D:\agent_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:56 Xamarin.Forms.BindingExpression.BindingExpressionPart.b__47_0() in D:\agent_work\1\s\Xamarin.Forms.Core\BindingExpression.cs:547
Foundation.NSAsyncActionDispatcher.Apply() in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/Foundation/NSAction.cs:163
UIKit.UIApplication.UIApplicationMain() in
UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/UIKit/UIApplication.cs:79
UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Users/builder/data/lanes/5665/db807ec9/source/xamarin-macios/src/UIKit/UIApplication.cs:63
SquadBuilder.iOS.Application.Main(string[] args) in /Users/tim/Projects/AuroraSquadBuilder/iOS/Main.cs:16
The app itself is open sourced now, so I can share the code leading up to the crash, as well as the sequence of events to cause it. I created an imgur album (http://imgur.com/a/tUNCz) outlining the steps to get the app to crash, since it's a lot easier to explain with images showing what to do.
On the main squadron page where you can see the ListView of all the pilots in that squadron, it shows a string with all of the upgrades equipped on each pilot in the list view cell for that pilot. My best guess is it's something to do with that being updated from having no upgrades to adding the first one, but I really can't say for sure. It's also notable that if you take an existing squadron with multiple pilots (for instance, adding multiple pilots, then backing all the way out to the list of all squadrons, then going back into the same squadron and equipping upgrades on the first pilot in the list), it works fine. It's only crashing when you add multiple pilots, then go back to the first and try to add upgrades all while viewing the one squadron.
When the upgrade from the upgrades list is selected, it sends a message to the MessagingCenter, which is subscribed to at line 67 of PilotViewModel.cs (http://github.com/timrisi/AuroraSquadBuilder/blob/v1.3.2/SquadBuilder/ViewModel/Squadron/PilotViewModel.cs#L64). It makes it htrough the whole lambda, unsubscribes, then crashes somewhere after that.
Currently on VSfM 7.3.3 (build 7), Mono 5.4.1.7, XI 11.6.1.4. It crashes like this on any version of XF from 2.4.0.280 onwards (I updated originally to the latest version of 2.5.0). If I revert back to 2.3.4.270 (and remove the UseSafeAreas calls) it works just fine. Updating to a newer version again, even if I load back up the last version of my app and simply update the XF version to 2.5.0.x with no other changes, it starts crashing the same way.
I downloaded the source code for XF and built it locally, then ran my project tareting that instead of the nuget packages. App crashes at github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs#L287
Control.Text = (string)values[1];
Control in this case is null. Anyone have any idea what's going on? (Just got it all built and ran, so haven't had the chance to dig beyond that, and it's late so I'm off to bed. Will try to dig more tomorrow).
I thought it might be related to my use of Xlabs.Forms for some pieceS (mostly MVVM stuff) so I removed the nuget packages and replaced them with my own lightweight classes, but the issue still persists.
Steps to Reproduce
Steps are outlined in an imgur album to include screenshots: http://imgur.com/a/tUNCz.
If you perform the same steps in an existing list (skip creating a new list and simply select an existing one with multiple pilots from the first page, then select the first pilot in the list and try to change upgrades) it works fine with no crash. It only crashes with a new list.
It also works fine if you add pilots one at a time and equip them with upgrades before adding the next pilot. It only crashes when adding multiple pilots in a new list, then going back to modify upgrades on the first one.
Expected Behavior
App does not crash
Actual Behavior
App crashes
Basic Information
Screenshots
http://imgur.com/a/tUNCz
Reproduction Link
http://github.com/timrisi/AuroraSquadBuilder