Xamarin Forms 4.4.0.991210-pre2
IPhone 7, iOS v13.1.3
NullReferenceException
at Xamarin.Forms.Platform.iOS.StructuredItemsViewRenderer
have a lot of IsVisible Bindings and other bindings in my XAML
in XAML you can mainly find two CollectionViews, StackLayout, FlexButtons
It is reproducible when one of the CollectionViews visibility changes from hidden to IsVisible and back to hidden, and then in my shell navigating to an entry in another FlyoutItem and then back to original FlyoutItem entry. So keep in mind only when switching from menu entries in different FlyoutItems
Strangely if I just switch from menu entries in the same FlyoutItem the exception doesn't occur.
Unfortunately can not provide an example code in quick notice.
Full stack trace:
at Xamarin.Forms.Platform.iOS.StructuredItemsViewRenderer2[TItemsView,TViewController].LayoutSubviews () [0x0000c] in <4f759157e6f148a992d3fa3b90518ad0>:0 at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr) at CoreAnimation.CALayer.LayoutSublayers () [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/CALayer.g.cs:508 at Xamarin.Forms.Platform.iOS.VisualElementTracker+<>c__DisplayClass29_0.
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <4f759157e6f148a992d3fa3b90518ad0>:0 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:188 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000de] in <4f759157e6f148a992d3fa3b90518ad0>:0
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <4f759157e6f148a992d3fa3b90518ad0>:0
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:188
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:238
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
at UIKit.UIViewController.get_View () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIViewController.g.cs:3171
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:104
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:120
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:188
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.LoadRenderers () [0x00028] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:146
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.ViewDidLoad () [0x00035] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:63
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
Reminds on this issue 5161
Unfortunately we need to have multiple FlyoutItems in AppShell because we use it only for navigation drawer (hamburger), no bottom tabs, and when we have more then 5 menu items in a FlyoutItem, the styling of the appbar/toolbar is broken for the pages 6+ on iOS
How collection view item template looks like:
xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
xmlns:material="clr-namespace:XF.Material.Forms.UI;assembly=XF.Material"
<DataTemplate x:DataType="mvvmData:SelectableItemVM">
<ContentView>
<material:MaterialCard IsClippedToBounds="True" CornerRadius="2" Elevation="2" Padding="5"
VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" IsClickable="True"
ClickCommand="{Binding ToggleSelected}" Style="{DynamicResource Key=SelectableCardView}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ff:CachedImage
VerticalOptions="Center"
HeightRequest="140"
WidthRequest="140"
Aspect="AspectFit"
BackgroundColor="WhiteSmoke"
Source="{Binding ItemDetails.CalculatedImageUri}"/>
<StackLayout Grid.Column="1" Padding="5,15">
<Label
Text="{Binding ItemDetails.Name}"
FontAttributes="Bold"
Style="{DynamicResource Key=SelectableCardViewLabel}"/>
<Label Text="{Binding ItemDetails.ItemClassName}"
Style="{DynamicResource Key=SelectableCardViewLabel}"/>
<Label Text="{Binding ItemDetails.ModelName}"
Style="{DynamicResource Key=SelectableCardViewLabel}"/>
<Label Text="{Binding ItemDetails.ManufacturerName}"
Style="{DynamicResource Key=SelectableCardViewLabel}"/>
<Label Text="{Binding ItemDetails.SerialNumber}"
Style="{DynamicResource Key=SelectableCardViewLabel}"/>
<Label Text="{Binding ItemDetails.Description}"
Style="{DynamicResource Key=SelectableCardViewLabel}"/>
</StackLayout>
</Grid>
</material:MaterialCard>
</ContentView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Unfortunately can not provide an example code in quick notice.
While I understand you might not have the time, I hope you understand that this will probably also mean that we won't be able to solve this any time soon. Having a reproduction will greatly help us identify and solve the problem.
demo xamarin forms project
iPhone 11 Pro Max iOS 13.2 2019-12-03 10-12-16.mp4.zip
Video of reproduction steps
I checked now and it seems that ListView doesn't have this problem, only CollectionView
@jfversluis How soon can it be solved and released? So we know whether to revert to alternatives. We have a deployment rather soon.
Originates from this line: https://github.com/xamarin/Xamarin.Forms/blob/87d720c71ec1c8f8fea2daf2105ba4b6689d71f1/Xamarin.Forms.Platform.iOS/CollectionView/StructuredItemsViewRenderer.cs#L81
Where Controller is null at the time of the crash.
Steps:
CollectionViewCollectionView to be visible and then invisible. Make sure it's invisible when you leave the pageJust iOS, Android is all fine and still happening in latest nightly.
Full stack trace
at Xamarin.Forms.Platform.iOS.StructuredItemsViewRenderer
2[TItemsView,TViewController].LayoutSubviews () [0x00006] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewRenderer.cs:77 at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr) at CoreAnimation.CALayer.LayoutSublayers () [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/CALayer.g.cs:508 at Xamarin.Forms.Platform.iOS.VisualElementTracker+<>c__DisplayClass29_0.<OnUpdateNativeControl>g__update|0 () [0x00162] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:252 at Xamarin.Forms.Platform.iOS.VisualElementTracker.OnUpdateNativeControl (CoreAnimation.CALayer caLayer) [0x002be] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:324 at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateNativeControl () [0x00060] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:376 at Xamarin.Forms.Platform.iOS.VisualElementTracker.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00055] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:352 at Xamarin.Forms.Platform.iOS.VisualElementTracker..ctor (Xamarin.Forms.Platform.iOS.IVisualElementRenderer renderer, System.Boolean trackFrame) [0x0006b] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:50 at Xamarin.Forms.Platform.iOS.VisualElementTracker..ctor (Xamarin.Forms.Platform.iOS.IVisualElementRenderer renderer) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:36 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x0009f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:257
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:144 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:188 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000de] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:264
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:144
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:188
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:238
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
at UIKit.UIViewController.get_View () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.2.2/src/Xamarin.iOS/UIViewController.g.cs:3171
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:104
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:120
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:188
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.LoadRenderers () [0x00028] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:146
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.ViewDidLoad () [0x00035] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:63
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.8.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.8.2.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at TestDemoCrash.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jfversluis/Downloads/TestDemoCrash/TestDemoCrash/TestDemoCrash.iOS/Main.cs:17
I am having this same issue!
Same issue. I am trying to use the Collection View inside ContentView. Works fine in Android. In iOS it is throwing NullReferenceException. Here's the ST:
" at Xamarin.Forms.Platform.iOS.StructuredItemsViewRenderer2[TItemsView,TViewController].LayoutSubviews () [0x00006] in D:\\a\\1\\s\\Xamarin.Forms.Platform.iOS\\CollectionView\\StructuredItemsViewRenderer.cs:81 \n at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)\n at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86 \n at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65 \n at ProjectName.iOS.Application.Main (System.String[] args) [0x00001] in /........./Main.cs:12 "
"
Same issue here! Android is working, but IOS No.
XAML
//Here the tabs are inserted at run time
<FlyoutItem x:Name="FlyoutItemMain" FlyoutDisplayOptions="AsMultipleItems" />
<FlyoutItem x:Name="FlyoutItemReport" FlyoutDisplayOptions="AsMultipleItems" Shell.TabBarIsVisible="False" />
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems" Shell.TabBarIsVisible="False" >
<Tab Title="Profile">
<Tab.Icon>
<FontImageSource FontFamily="{StaticResource SegMDL2}" Glyph="" Color="#343434" />
</Tab.Icon>
<ShellContent ContentTemplate="{DataTemplate views:PersonPage}" />
</Tab>
<Tab Title="About">
<Tab.Icon>
<FontImageSource FontFamily="{StaticResource SegMDL2}" Glyph="" Color="#343434" />
</Tab.Icon>
<ShellContent ContentTemplate="{DataTemplate views:AboutPage}" />
</Tab>
</FlyoutItem>
</Shell.Items>
C#
var font = Device.RuntimePlatform == Device.Android ? "SegMDL2.ttf#Segoe MDL2 Assets" : "Segoe MDL2 Assets";
FlyoutItemMain.Items.Add(new ShellContent
{
Title = "Ponto",
Route = "Registrar",
Content = new HomePage(),
Icon = new FontImageSource { FontFamily = font, Glyph = "\uED5A", Color = Color.FromHex("#343434") }
});
FlyoutItemReport.Items.Add(new ShellContent
{
Title = "Marca莽茫o 24Hs",
Content = new Relatorios24hsPage(),
Icon = new FontImageSource { FontFamily = font, Glyph = "\uE9F9", Color = Color.FromHex("#343434") }
});
The problem is in any page shell that I call MainPage. If I call a ContentPage it works!
Today I updated the Mono version!
=== Visual Studio Professional 2019 for Mac ===
Version 8.4.5 (build 19)
Installation UUID: c1337f6b-7a99-4d59-bc1a-23e08278a6a1
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.16.1.25 (issue-7441-d16-3-vsmac / 881172e73)
Package version: 606000155
=== Mono Framework MDK ===
Runtime:
Mono 6.6.0.155 (2019-08/296a9afdb24) (64-bit)
Package version: 606000155
=== Roslyn (Language Service) ===
3.4.0-beta4-19562-05+ff930dec4565e2bc424ad3bf3e22ecb20542c87d
=== NuGet ===
Version: 5.3.0.6192
=== .NET Core SDK ===
SDK: /usr/local/share/dotnet/sdk/3.1.101/Sdks
SDK Versions:
3.1.101
3.0.101
3.0.100
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.6.0/lib/mono/msbuild/Current/bin/Sdks
=== .NET Core Runtime ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.1
3.0.1
3.0.0
2.1.15
2.1.14
2.1.13
=== Xamarin.Profiler ===
Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Updater ===
Version: 11
=== Apple Developer Tools ===
Xcode 11.3.1 (15715)
Build 11C504
=== Xamarin.Mac ===
Version: 6.10.0.17 (Visual Studio Professional)
Hash: 5f802ef53
Branch: xcode11.3
Build date: 2020-01-07 11:53:06-0500
=== Xamarin.iOS ===
Version: 13.10.0.17 (Visual Studio Professional)
Hash: 5f802ef53
Branch: xcode11.3
Build date: 2020-01-07 11:53:06-0500
=== Xamarin Designer ===
Version: 16.4.0.479
Hash: 074544417
Branch: remotes/origin/d16-4
Build date: 2020-01-22 22:50:22 UTC
=== Xamarin.Android ===
Version: 10.1.3.7 (Visual Studio Professional)
Commit: xamarin-android/d16-4/d66aed0
Android SDK: /Users/devprime/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
None installed
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.2
SDK Build Tools Version: 28.0.3
Build Information:
Mono: fd9f379
Java.Interop: xamarin/java.interop/d16-4@c4e569f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.28.0@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b
=== Microsoft Mobile OpenJDK ===
Java SDK: /Users/devprime/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Android SDK Manager ===
Version: 16.4.0.10
Hash: 2c49a7d
Branch: remotes/origin/d16-4
Build date: 2020-01-30 10:22:44 UTC
=== Android Device Manager ===
Version: 16.4.0.30
Hash: f9172e2
Branch: remotes/origin/d16-4
Build date: 2020-01-30 10:23:04 UTC
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 804050019
Git revision: 5b9e12b8142016693a4b0f0bdac84ffac1d84c28
Build date: 2020-02-07 12:51:25+00
Build branch: release-8.4
Xamarin extensions: 5b9e12b8142016693a4b0f0bdac84ffac1d84c28
=== Operating System ===
Mac OS X 10.15.2
Darwin 19.2.0 Darwin Kernel Version 19.2.0
Sat Nov 9 03:47:04 PST 2019
root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64
This happened for me when transitioning from one page containing a collection view to a different page. Before the 2nd page is requested, I need to hide the collection view (IsVisible=false) to prevent a weird flash I was seeing. However, the collection view remained hidden after transitioning to the 2nd page, and when I went back to the 1st page (that has the collection view), I get the error. I was able to fix this by sending a message from page 2 to page 1 telling page 1 to 'show' the collection view (IsVisible=true). Once I had that in place, the error went away.
For my case, if the collection view is hidden prior to navigating away, when you go back to that page, the error is immediately thrown. Doesn't matter if you try to show the collection view in page 1's OnAppearing method.
Hopefully this helps someone else?
Most helpful comment
Originates from this line: https://github.com/xamarin/Xamarin.Forms/blob/87d720c71ec1c8f8fea2daf2105ba4b6689d71f1/Xamarin.Forms.Platform.iOS/CollectionView/StructuredItemsViewRenderer.cs#L81
Where
Controlleris null at the time of the crash.Steps:
CollectionViewCollectionViewto be visible and then invisible. Make sure it's invisible when you leave the pageJust iOS, Android is all fine and still happening in latest nightly.
Full stack trace