Skip to content

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

@WebGoose

Description

@WebGoose

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

Metadata

Metadata

Assignees

Labels

area-navigationNavigationPagei/regressionThis issue described a confirmed regression on a currently supported versionp/1Work that is important, and has been scheduled for release in this or an upcoming sprintpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/ioss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions