-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[regression/8.0.0] MAUI crashing on CarouselView render/remove, flyout menu #17396
Comments
I have additional information concerning the iOS crash, and it appears to be similar to the Android crash. Unfortunately, it doesn't trigger a breakpoint, so I don't have access to the call stack in Visual Studio. However, I have included some logging in my console output (see below). This crash occurs immediately after the splash screen when the landing page is being loaded. The landing page is a straightforward one, featuring a grid, an image, and two buttons. To clarify, I'm not certain whether the iOS and Android issues are identical. They do seem related, but if they are distinct problems, they may need to be addressed separately. If there's any way I can assist in resolving these issues, please don't hesitate to reach out to me!
|
could you share a snippet of code/xaml triggering the issue ? |
the stack trace point to 'newValue' being null in VisualStateGroupsPropertyChanged (as it comes after a ClearValue). What I don't get is that this code was barely changed, and VSGPropertyChanged always assumed newValue wasn't null. I'm going to propose a change to check for null value, and hope for the best as we don't have a small repro to test on |
@npostma can you share your Shell.xaml file and any related styles/app.xaml/styles.xaml/colors.xaml? Do you modify shell at all during load? |
@StephaneDelcroix Also, is there a way for me i can validate/test your fix? All i can see is this: @PureWeen First I will share a redacted version of my AppShell.xaml and colors.xaml. Styles is quite big and not sure what i can share from that file. Colors.xaml <?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="CompanyBlack">#000000</Color>
<Color x:Key="CompanyWhite">#ffffff</Color>
<Color x:Key="PrimaryBackground">#000000</Color>
<Color x:Key="PrimaryBackgroundAccent">#000000</Color>
<Color x:Key="SecondaryBackground">#000000</Color>
<Color x:Key="PrimaryForeground">#000000</Color>
<Color x:Key="AccentBackground">#000000</Color>
<Color x:Key="SeparatorBackground">#000000</Color>
<Color x:Key="PrimaryText">#000000</Color>
<Color x:Key="SecondaryText">#000000</Color>
<Color x:Key="HeaderText">#000000</Color>
<Color x:Key="SecondaryFaintedText">#000000</Color>
<Color x:Key="SecondaryLightenText">#000000</Color>
<Color x:Key="AccentText">#000000</Color>
<Color x:Key="AccentTextDisabled">#00000011</Color>
<Color x:Key="ErrorText">#000000</Color>
<Color x:Key="ErrorBackground">#000000</Color>
<Color x:Key="ErrorTextDisabled">#000000</Color>
<Color x:Key="WarningText">#000000</Color>
<Color x:Key="WarningTextBackground">#000000</Color>
<Color x:Key="WarningTextDisabled">#000000</Color>
<Color x:Key="SuccessText">#000000</Color>
<Color x:Key="SuccessTextBackground">#000000</Color>
<Color x:Key="SuccessTextDisabled">#00000011</Color>
<Color x:Key="Button">#000000</Color>
<Color x:Key="Active">#000000</Color>
<Color x:Key="Inactive">#000000</Color>
<Color x:Key="ButtonDisabled">#000000</Color>
</ResourceDictionary> FlyoutHeaderTemplate <?xml version="1.0" encoding="utf-8" ?>
<StackLayout
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:NAMESPACE"
x:Class="NAMESPACE.Views.Template.FlyoutHeaderTemplate"
xmlns:resources="clr-namespace:NAMESPACE.Resources"
Padding="0"
Margin="0"
HeightRequest="200"
MaximumHeightRequest="200"
VerticalOptions="StartAndExpand"
>
<StackLayout
Style="{DynamicResource SOMESTYLE}"
x:Name="CompanyHeader"
>
<Image
x:Name="CompanyLogo"
Style="{DynamicResource SOMESTYLE}"
/>
</StackLayout>
<Label
Text="{x:Static resources:Localization.SOMELABEL}"
Style="{DynamicResource SOMESTYLE}"
x:Name="LABELA"
/>
<Label
Text="{x:Static resources:Localization.SOMELABEL}"
Style="{DynamicResource SOMESTYLE}"
x:Name="LABELB"
/>
</StackLayout> |
if you remove this binding do you still get a crash? |
@PureWeen in short: yes, it stil crashes after removing the IsVisible binding. For android: Opening the app works. After login the page with the carousel is trying to load -> crash. For iOS: Loading the app -> crash. I looks like the same issue (same stack trace) but i do not think its one thing in my code. Console output after removing the IsVisible from the AppShell.xaml. After pressing 3x continue on the crash: **System.NullReferenceException:** 'Object reference not set to an instance of an object.'
The thread 0x4 has exited with code 0 (0x0).
The thread 0xd has exited with code 0 (0x0).
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
The thread 0xb has exited with code 0 (0x0).
Thread finished: <Thread Pool> #4
Thread finished: <Thread Pool> #13
Thread finished: <Thread Pool> #11
Thread started: .NET TP Worker #14
Thread started: <Thread Pool> #15
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
[DOTNET] exception: Exception: CurrentDomainOnUnhandledException
[DOTNET] Source:
[DOTNET] TargetSite:
[DOTNET] StackTrace: Inner Exception: Object reference not set to an instance of an object.
[0:] exception: Exception: CurrentDomainOnUnhandledException
Source:
TargetSite:
StackTrace: Inner Exception: Object reference not set to an instance of an object.
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
[mono-rt] at Microsoft.Maui.Controls.VisualStateManager.VisualStateGroupsPropertyChanged(BindableObject bindable, Object oldValue, Object newValue) in D:\a\_work\1\s\src\Controls\src\Core\VisualStateManager.cs:line 49
[mono-rt] at Microsoft.Maui.Controls.BindableObject.ClearValueCore(BindableProperty property, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 139
[mono-rt] at Microsoft.Maui.Controls.BindableObject.ClearValue(BindableProperty property, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 103
[mono-rt] at Microsoft.Maui.Controls.Setter.UnApply(BindableObject target, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\Setter.cs:line 100
[mono-rt] at Microsoft.Maui.Controls.Style.UnApplyCore(BindableObject bindable, Style basedOn) in D:\a\_work\1\s\src\Controls\src\Core\Style.cs:line 191
[mono-rt] at Microsoft.Maui.Controls.Style.Microsoft.Maui.Controls.IStyle.UnApply(BindableObject bindable) in D:\a\_work\1\s\src\Controls\src\Core\Style.cs:line 115
[mono-rt] at Microsoft.Maui.Controls.MergedStyle.SetStyle(IStyle implicitStyle, IList`1 classStyles, IStyle style) in D:\a\_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 193
[mono-rt] at Microsoft.Maui.Controls.MergedStyle.set_ClassStyles(IList`1 value) in D:\a\_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 87
[mono-rt] at Microsoft.Maui.Controls.MergedStyle.OnClassStyleChanged() in D:\a\_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 126
[mono-rt] at Microsoft.Maui.Controls.MergedStyle.<set_StyleClass>b__13_0(BindableObject bindable, Object oldvalue, Object newvalue) in D:\a\_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 70
[mono-rt] at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 611
[mono-rt] at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 539
[mono-rt] at Microsoft.Maui.Controls.Element.OnResourceChanged(BindableProperty property, Object value, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 815
[mono-rt] at Microsoft.Maui.Controls.Element.OnResourcesChanged(IEnumerable`1 values) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 671
[mono-rt] at Microsoft.Maui.Controls.VisualElement.OnParentResourcesChanged(IEnumerable`1 values) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1436
[mono-rt] at Microsoft.Maui.Controls.Element.SetParent(Element value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 355
[mono-rt] at Microsoft.Maui.Controls.Element.OnChildAdded(Element child) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 525
[mono-rt] at Microsoft.Maui.Controls.ShellItem.OnChildAdded(Element child) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellItem.cs:line 252
[mono-rt] at Microsoft.Maui.Controls.Element.AddLogicalChild(Element element) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 224
[mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRecyclerAdapter.ElementViewHolder.set_Element(Element value) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutRecyclerAdapter.cs:line 287
[mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRecyclerAdapter.OnBindViewHolder(ViewHolder holder, Int32 position) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutRecyclerAdapter.cs:line 110
[mono-rt] at AndroidX.RecyclerView.Widget.RecyclerView.Adapter.n_OnBindViewHolder_Landroidx_recyclerview_widget_RecyclerView_ViewHolder_I(IntPtr jnienv, IntPtr native__this, IntPtr native_holder, Int32 position) in C:\a\_work\1\s\generated\androidx.recyclerview.recyclerview\obj\Release
et6.0-android\generated\src\AndroidX.RecyclerView.Widget.RecyclerView.cs:line 581
[mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLI_V(_JniMarshal_PPLI_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, Int32 p1) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 180
[mono-rt] at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20825
[mono-rt] at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 75
[mono-rt] at AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.OnLayout(Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) in C:\a\_work\1\s\generated\androidx.coordinatorlayout.coordinatorlayout\obj\Release
et6.0-android\generated\src\AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.cs:line 2704
[mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutLayout.OnLayout(Boolean changed, Int32 left, Int32 top, Int32 right, Int32 bottom) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutLayout.cs:line 34
[mono-rt] at AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.n_OnLayout_ZIIII(IntPtr jnienv, IntPtr native__this, Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) in C:\a\_work\1\s\generated\androidx.coordinatorlayout.coordinatorlayout\obj\Release
et6.0-android\generated\src\AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.cs:line 2688
[mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPZIIII_V(_JniMarshal_PPZIIII_V callback, IntPtr jnienv, IntPtr klazz, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 444
[HostConnection] createUnique: call
[HostConnection] HostConnection::get() New Host Connection established 0x767da7026490, tid 6537
[HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2
|
@PureWeen @StephaneDelcroix I did some debugging by removing a lot of code en step by step re-adding the xml unit it crashes. My conclusions is that a lot of elements (95%) with a binding make the app crash. A simple example of this: In the view i have an element: <Label Grid.Row="1"
Text="{Binding Name}"
HorizontalOptions="CenterAndExpand"
VerticalOptions="Center"
Style="{DynamicResource SubTitle}"
/> if i remove the
So if there is a activeUser, use the name property, else use empty string. Changing this to Then i tested to keep activeUser Does this information help? This code works fine in Xamarin, Maui .NET6 and .NET7 [EDIT :: ADDED] Another simpler example @PureWeen @StephaneDelcroix. I have this element: <Label
FontFamily="LaSolid"
IsVisible="{Binding Verified, Converter={Converters:InverseBoolConverter}}"
Text=""
TextColor="{DynamicResource MyColor}"
HorizontalOptions="Center"
VerticalOptions="Center"
Style="{DynamicResource SubTitle}"
/> This crashes. Do i remove /// <summary>
/// Docs
/// </summary>
private bool verified = false;
public bool Verified
{
get => verified;
set
{
if (value == verified)
{
return;
}
verified = value;
OnPropertyChanged(nameof(Verified));
}
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChangedEventHandler changed = PropertyChanged;
if (changed == null)
{
return;
}
changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
} So this is quite simple code that crashes. I think there is a new way of doing this binding stuff in MAUI? But first i need the app to run before i can update/actualize the code to the new standards. |
Where do these labels live? <Label Grid.Row="1"
Text="{Binding Name}"
HorizontalOptions="CenterAndExpand"
VerticalOptions="Center"
Style="{DynamicResource SubTitle}"
/> are they part of your flyout item templates? |
@PureWeen Not applicable to the example provided above. These labels are situated within an extended class derived from ContentView. This ContentView is loaded within the constructor, subsequent to the InitializeComponent() call, within a class that itself extends a ContentPage. Should I remove all of this code, the issue transfers to the flyout menu. Furthermore, I encounter this crash when using a source binding for an image within a simple ContentPage, indicating that this specific crash can manifest across various scenarios. Container code of the content page <Grid x:Name="viewContainer" Margin="0" Padding="0" ColumnSpacing="0" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid> Constructor code from the ContentPage: InitializeComponent();
MyView = new CardsCarouselIOS();
MyView .BindingContext = BindingContext;
viewContainer.Add(MyView); |
I can conclude that this is indeed fixed. I do not experience the crash in the main or in the net/8.0 branch! Tested for android. |
Also fixed it for iOS, thanks! |
Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you! |
Description
I am currently in the process of porting my app to MAUI in .NET 8. This decision was primarily influenced by the fact that I've noticed several critical bug fixes in .NET 8 that have not been addressed or backported to .NET 7. However, despite a relatively smooth compilation process without any major issues, I've encountered significant challenges with app stability.
On iOS, the app crashes during the boot process, and on Android, it crashes when attempting to render a carousel. Additionally, when removing the carousel from the view, I encounter another crash when opening the flyout menu by clicking on the hamburger icon. This situation is quite perplexing, especially since the app was running smoothly without any crashes on the .NET 7 version.
I've attempted to investigate the root cause of these issues, but the callstack doesn't provide any information related to my project files; it only references framework files. My suspicion is that there might be an issue with the binding between views and view models or possibly with a custom control or helper within the application. Regrettably, I lack sufficient information to pinpoint the exact problem.
In summary, I'm actively working to resolve these issues and ensure a stable performance for my app in MAUI with .NET 8, but I'm currently faced with a lack of concrete clues regarding the source of the crashes.
Error (very generic, something needs to be initialized but its probably null)
Callstack
I am using the latest MAUI on Visual Studio 2022 community Preview
Steps to Reproduce
I have no idea, because its a big app being ported from xamarin -> maui .net7 (many layout issues, memory stream issues, etc) -> maui .net8. And i am trying to gather as much information possible to figure this out.
Link to public reproduction project repository
No response
Version with bug
8.0.0-rc.1.9171
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI, Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
Not yet
Relevant log output
The text was updated successfully, but these errors were encountered: