Skip to content
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

NullReferenceException when setting BarBackgroundColor for a NavigationPage #25114

Closed
MitchBomcanhao opened this issue Oct 7, 2024 · 7 comments · Fixed by #25197
Closed

NullReferenceException when setting BarBackgroundColor for a NavigationPage #25114

MitchBomcanhao opened this issue Oct 7, 2024 · 7 comments · Fixed by #25197
Labels
area-navigation NavigationPage i/regression This issue described a confirmed regression on a currently supported version platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@MitchBomcanhao
Copy link

MitchBomcanhao commented Oct 7, 2024

Description

From 8.0.90 (as far as I can tell) I get NRE when attempting to set a NavigationPage's BarBackgroundColor.
I'm not sure of how this is failing (ie I can't share a repro project at the moment), but it can't hurt to get the ball rolling on this topic, perhaps others have had similar issues?

this is running on a Flyout page - its detail is set to a navigation page that encapsulates a content page.
when the content page triggers OnAppearing we set the BarBackgroundColor for the navigation page.

however, when it gets to the NavigationPageToolbar.ApplyChanges method, it blows up, as it seemingly receives a null navigationPage object

image

and that null object comes from the call from NavigationPageToolbar.OnPagePropertyChanged
image

Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.NavigationPageToolbar.ApplyChanges(Microsoft.Maui.Controls.NavigationPage navigationPage) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.NavigationPageToolbar.OnPagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.MenuItemTracker<System.__Canon>.OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs propertyChangedEventArgs) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.BindableObject.OnPropertyChanged(string propertyName) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.OnPropertyChanged(string propertyName) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.BindableObject.SetValueActual(Microsoft.Maui.Controls.BindableProperty property, Microsoft.Maui.Controls.BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, Microsoft.Maui.Controls.Internals.SetValueFlags attributes, Microsoft.Maui.Controls.SetterSpecificity specificity, bool silent) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.BindableObject.SetValueCore(Microsoft.Maui.Controls.BindableProperty property, object value, Microsoft.Maui.Controls.Internals.SetValueFlags attributes, Microsoft.Maui.Controls.BindableObject.SetValuePrivateFlags privateAttributes, Microsoft.Maui.Controls.SetterSpecificity specificity) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.BindableObject.SetValue(Microsoft.Maui.Controls.BindableProperty property, object value) Unknown
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.NavigationPage.BarBackgroundColor.set(Microsoft.Maui.Graphics.Color value) Unknown

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.91 SR9.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.82 SR8.2

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@MitchBomcanhao MitchBomcanhao added the t/bug Something isn't working label Oct 7, 2024
@MitchBomcanhao
Copy link
Author

this NavigationPageToolbar class was changed a few weeks ago and the OnPagePropertyChanged method was modified - this is likely where the issue is coming from - check commit fa9e370

the original OnPropertyChanged method was removed
image

the OnPagePropertyChanged method was changed to include most of the code that was removed from the other method
image

this is clearly doing things slightly differently, which is breaking things.

@MitchBomcanhao
Copy link
Author

the offending PR seems to be this one
#23076

@samhouts samhouts added platform/windows 🪟 potential-regression This issue described a possible regression on a currently supported version., verification pending area-navigation NavigationPage labels Oct 9, 2024
@markmccaigue
Copy link

We've also hit what I believe to be the same issue.

I can confirm that this also happens on both iOS and Android, and that it is a regression introduced in 8.0.90.

I have made a small reproduction, here, which demonstrates the issue

When running this project, the app will crash on launch. The expected behaviour, and the behaviour observed on previous MAUI releases, is that no crash occurs, and the color is correctly updated.

Our production application exhibiting this issue is more complex than the reproduction sample, and makes heavy use of dynamic resources for colors. The impact there is that the main section of our app is inaccessible, on Android the app hangs completely, on iOS it hangs, but will crash after user interaction with this same stack trace. I'm not currently aware of any viable workaround, so it's a pressing issue for us.

Thanks for your consideration. cc @MitchBomcanhao @samhouts

@samhouts
Copy link
Member

@kubaflo This seems related to some changes you made recently. Would you like to take a look? Thank you!!!

@kubaflo
Copy link
Contributor

kubaflo commented Oct 11, 2024

@samhouts @markmccaigue @MitchBomcanhao the fix: #25197

@markmccaigue
Copy link

Thanks so much for the quick PR!

Just for our planning purposes, in your opinion is it likely that this fix for the regression would make it's way into a service release in the near future? Thanks again @samhouts @kubaflo

@jaosnz-rep jaosnz-rep added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Oct 12, 2024
@jaosnz-rep
Copy link

jaosnz-rep commented Oct 12, 2024

I can repro this issue at Windows platform on the latest 17.12 Preview 2.1(8.0.90 & 8.0.91), but it works fine on 8.0.82.
Image

@jsuarezruiz jsuarezruiz added this to the .NET 8 SR10 milestone Oct 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-navigation NavigationPage i/regression This issue described a confirmed regression on a currently supported version platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants