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

OnAppearing not triggered when going back from Modal page #8513

Closed
marcmognol opened this issue Jul 4, 2022 · 8 comments · Fixed by #13177
Closed

OnAppearing not triggered when going back from Modal page #8513

marcmognol opened this issue Jul 4, 2022 · 8 comments · Fixed by #13177
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events area-navigation NavigationPage fixed-in-7.0.81 Look for this fix in 7.0.81! fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@marcmognol
Copy link
Contributor

Description

OnAppearing is not triggered when going back from Modal page.

Steps to Reproduce

  1. Download solution here
    BugMauiModal.zip

  2. Run solution

  3. On MainPage, click on button to go the Second page

  4. Go back with "Back button" located on navigation bar

  5. On MainPage, label should display "Appeared 2" --> OK

  6. On MainPage, click on button to go the Second page

  7. From SecondPage, click on "Open modal" button

  8. On modal page, click on "Close" button

  9. On second page, abel should display "Appeared 2" but it displays "Appeared 1 time"--> Not OK

Mean, OnAppearing was not triggered in this case

Version with bug

6.0.400 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11

Did you find any workaround?

N/A

Relevant log output

No response

@marcmognol marcmognol added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jul 4, 2022
@jsuarezruiz jsuarezruiz added platform/android 🤖 area-navigation NavigationPage area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jul 4, 2022
@jsuarezruiz
Copy link
Contributor

Verified, thanks for the attached sample and detailed steps.

@cdefgah
Copy link

cdefgah commented Aug 18, 2022

The same behavior occurs when you go back from a regular content page too. OnAppearing of the displayed page is not triggered.

@Martyf101
Copy link

There is inconsistent usage of the HasAppeared property in Page.

In FlyoutPage, TabbedPage and MultiPage it is used to store a reminder that the SendAppearing() call needs to be made at the appropriate time in the page lifecycle after a current page switch.

However, in NavigationPage it is used as a state machine toggle to ensure an OnDisappearing must be made before another OnAppearing is fired.

In NavigationPage line 406:

	void FireDisappearing(Page page)
	{
		if (HasAppeared)
			page?.SendDisappearing();
	}

	void FireAppearing(Page page)
	{
		if (HasAppeared)
			page?.SendAppearing();
	}

I don't believe this should be the same check for both functions, and the second should be checking the inverse ( HasAppeared == false ). When MauiNavigationImpl calls FireAppearing() in OnPopAsync() this check will fail, leaving the page in a broken state, causing both the OnAppearing not to fire and the ensuing OnDisappearing when the page leaves, as _hasAppeared doesn't get updated to True.

Minimizing the App will correct the HasAppeared state, or firing a SendAppearing() on the destination Page in ModalPopping as a temp workaround.

@borrmann
Copy link
Contributor

borrmann commented Jan 7, 2023

Is this going to be fixed anytime soon?
Also this happens on iOS as well.

@mikeparker104 mikeparker104 added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Feb 2, 2023
@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Feb 3, 2023
@mattleibow mattleibow added this to the Backlog milestone Feb 3, 2023
@ghost
Copy link

ghost commented Feb 3, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@samhouts samhouts added p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint and removed p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint labels Feb 3, 2023
@SailDev
Copy link

SailDev commented Feb 4, 2023

Why has this not the highest priority?

My personal opinion:

  • The "appearing" events belong to the most important events in the whole system.
  • You can't develop a serious application, without having reliable working lifecycle events. Period!

At the moment, the problems i have with modal pages (i.e. multiple popups) and memory leaks in general, forced me to redesign my whole application and to move everything (pages and view models) to singletons.

Now it's even more important, to have reliable lifecycle events, to manage the state of the view models.
Time, to add another workaround (maybe WeakReferenceMessenger).

All i want, since december 2021, is to publish a MAUI application, which looks acceptable and does not crash when it's used for more than 5 minutes.

@samhouts samhouts added p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint and removed p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint labels Feb 6, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 8 Planning Feb 8, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Feb 22, 2023
@developer9969
Copy link

developer9969 commented Apr 3, 2023

@rachelkang @samhouts hi - very grateful if you could confirm that this fix also applies to OnNavigatedTo and will be part of the next Visual studio release.. Or if not can this be part of @PureWeen https://github.com/PureWeen/ShanedlerSamples.. this kind of critical..

Many thanks

@ghost
Copy link

ghost commented Apr 3, 2023

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!

@samhouts samhouts added the fixed-in-7.0.81 Look for this fix in 7.0.81! label Apr 12, 2023
FrietStoofvlees pushed a commit to FrietStoofvlees/ProjectNASA that referenced this issue May 7, 2023
OnAppearing dotnet/maui#8513, fixed in latest versions.
Cleanup of messy code and added early returns
@ghost ghost locked as resolved and limited conversation to collaborators May 12, 2023
@samhouts samhouts added the fixed-in-7.0.92 Look for this fix in 7.0.92! label Jul 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events area-navigation NavigationPage fixed-in-7.0.81 Look for this fix in 7.0.81! fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 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.

10 participants