Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] NullReferenceException in the XamlParser when initializing views #15847

Open
DomBerentsen opened this issue Dec 13, 2023 · 1 comment
Open
Labels
p/iOS 🍎 s/unverified New report that has yet to be verified t/bug 🐛

Comments

@DomBerentsen
Copy link

Description

Our apps ocasionally crash because of a NullReferenceException in the XamlParser when initializing views. Something in the Xaml causes the s_xmlnsDefinitions List to be set to null again, and sometimes this happens while it is being used.
This is only confirmed to happen on iOS.

Stacktrace:

{System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Xaml.XamlParser.GatherXmlnsDefinitionAttributes () [0x00042] in D:\a\1\s\Xamarin.Forms.Xaml\XamlParser.cs:357
at Xamarin.Forms.Xaml.XamlParser.GetElementType (Xamarin.Forms.Xaml.XmlType xmlType, System.Xml.IXmlLineInfo xmlInfo, System.Reflection.Assembly currentAssembly, Xamarin.Forms.Xaml.XamlParseException& exception) [0x0001d] in D:\a\1\s\Xamarin.Forms.Xaml\XamlParser.cs:374
at Xamarin.Forms.Xaml.Internals.XamlTypeResolver.TryResolve (Xamarin.Forms.Xaml.XmlType xmlType, System.Type& type) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\XamlServiceProvider.cs:208
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor+MarkupExpansionParser.Parse (System.String match, System.String& remaining, System.IServiceProvider serviceProvider) [0x001b2] in D:\a\1\s\Xamarin.Forms.Xaml\ExpandMarkupsVisitor.cs:183
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor.ParseExpression (System.String& expression, System.Xml.IXmlNamespaceResolver nsResolver, System.Xml.IXmlLineInfo xmlLineInfo, Xamarin.Forms.Xaml.INode node, Xamarin.Forms.Xaml.INode parentNode) [0x000e4] in D:\a\1\s\Xamarin.Forms.Xaml\ExpandMarkupsVisitor.cs:106
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor.Visit (Xamarin.Forms.Xaml.MarkupNode markupnode, Xamarin.Forms.Xaml.INode parentNode) [0x00037] in D:\a\1\s\Xamarin.Forms.Xaml\ExpandMarkupsVisitor.cs:51
at Xamarin.Forms.Xaml.MarkupNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:113
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:152
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:154
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:154
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:152
at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:211
at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext, System.Boolean useDesignProperties) [0x0002e] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:228
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml, System.Reflection.Assembly rootAssembly, System.Boolean useDesignProperties) [0x000a2] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:104
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml, System.Boolean useDesignProperties) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:77
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.Type callingType) [0x00029] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:73
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.Type callingType) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\ViewExtensions.cs:37

Steps to Reproduce

We do not have a stable reproduction, it is a matter of timing. If we navigate back and forth to a view a lot it will sometimes cause the exception.

Expected Behavior

Initializing views should not cause crashes

Actual Behavior

Sometimes Initializing views causes a crash

Basic Information

Xamarin.forms: 5.0.0.2291

@DomBerentsen DomBerentsen added s/unverified New report that has yet to be verified t/bug 🐛 labels Dec 13, 2023
@jfversluis
Copy link
Member

Unfortunately without any reproduction or relevant code this will be pretty hard to diagnose or fix. Please let us know if you uncover any more details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p/iOS 🍎 s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

2 participants