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

Net 8: Page and control Unloaded events firing on iOS when navigating to another page #21916

Open
WebGoose opened this issue Apr 18, 2024 · 5 comments · May be fixed by #23196 or #25852
Open

Net 8: Page and control Unloaded events firing on iOS when navigating to another page #21916

WebGoose opened this issue Apr 18, 2024 · 5 comments · May be fixed by #23196 or #25852
Assignees
Labels
area-navigation NavigationPage i/regression This issue described a confirmed regression on a currently supported version p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@WebGoose
Copy link

Description

Since updating our app to Net 8, when navigating to a new page on iOS, the Unloaded and Loaded events for the starting page are firing, even though that page is still in the stack and is not actually unloaded. In fact, it's actually firing twice. The sequence goes:
Navigate -> Unloaded -> Loaded -> Unloaded

This doesn't happen on Android and never happened on either platform in Net 7.

This is causing quite a big headache for us now because many of our pages have event and other subscriptions that get cleaned up in Unloaded when the page is removed from the stack / closed. As a result we now have event handlers and other subs being unregistered incorrectly, leaving the page in a broken / non-functional state when the user navigates back to it

I ran into a similar issue in this ticket

Steps to Reproduce

if using the included repro project:

  1. Run the UnloadedNet8 app on iOS and put breakpoints in the loaded and unloaded event handlers on MainPage
  2. Navigate away and back using the buttons
  3. You will see when you click the button on Main Page that Unloaded fires, then Loaded, then Unloaded, and then the page navigates

This does not happen on Android, and does not happen in the UnloadedNet7 app project at all on either platform

Link to public reproduction project repository

https://gooseza.visualstudio.com/MauiBugs/_git/UnloadedEventBug

Version with bug

8.0.20 SR4

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.101

Affected platforms

iOS

Affected platform versions

iOS 17.3.1. Not sure if others are affected

Did you find any workaround?

Not one that I am happy with

I can possibly try re-registering my event handlers and subscriptions in Loaded or OnAppearing but this is not ideal as it will mean recreating them multiple times instead of just once when the page is created.

Relevant log output

No response

@WebGoose WebGoose added the t/bug Something isn't working label Apr 18, 2024
@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 19, 2024
@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio 17.10.0 Preview 3(8.0.20&8.0.7&8.0.3&8.0.0-rc.2.9530). Can repro on windows platform with sample project.
image

@samhouts samhouts added the potential-regression This issue described a possible regression on a currently supported version., verification pending label Apr 22, 2024
@PureWeen PureWeen added 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 May 7, 2024
@PureWeen PureWeen added this to the .NET 9 Planning milestone May 7, 2024
@PureWeen PureWeen self-assigned this May 7, 2024
@PureWeen PureWeen modified the milestones: .NET 9 Planning, .NET 8 SR7 May 31, 2024
@pulmuone
Copy link

same issue

@PureWeen PureWeen removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 15, 2024
@PureWeen
Copy link
Member

@pulmuone @WebGoose can you test this on the latest 8.0.60 release?

@PureWeen PureWeen added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Jun 15, 2024
@PureWeen PureWeen modified the milestones: .NET 8 SR7, .NET 8 SR8 Jun 15, 2024
@pulmuone
Copy link

@pulmuone @WebGoose can you test this on the latest 8.0.60 release?

yes

@kevinxufei kevinxufei added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 18, 2024
@kevinxufei
Copy link

Verified this issue with Visual Studio 17.11.0 Preview 2.0 (8.0.60). Can repro on iOS platform with sample project. And it can not repro on .NET7.

@kubaflo kubaflo linked a pull request Jun 22, 2024 that will close this issue
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-navigation NavigationPage i/regression This issue described a confirmed regression on a currently supported version p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: In Progress
7 participants