dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.99k stars 1.72k forks source link

Native embedding: OnAppearing override not invoked #11281

Open davidbritch opened 1 year ago

davidbritch commented 1 year ago

Description

I've been playing around with native embedding. In native apps on Android, iOS, and Windows, the ContentPage.OnAppearing override isn't being invoked on navigation, whereas it is in .NET MAUI apps. This makes it more difficult to load data on page load, which many people tend to do in OnAppearing.

This behaviour is identical in .NET 6 and 7, so I suspect it's more an omission than a regression.

Steps to Reproduce

  1. Pick a platform. I'd recommend Android or Windows, because when the app launches on iOS it takes a while a breakpoint at the start of FinishedLaunching to even be hit.
  2. Put in a breakpoint in NotesPage.OnAppearing.
  3. Run sample.

The breakpoint is never hit.

Link to public reproduction project repository

https://github.com/davidbritch/dotnet-maui-issues/tree/main/Embedding

Version with bug

.NET 7 GA (also occurs in .NET 6)

Last version that worked well

Don't think it's ever worked.

Affected platforms

iOS, Android, Windows

ghost commented 1 year ago

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.

Zhanglirong-Winnie commented 10 months ago

Verified this issue with Visual Studio Enterprise 17.8.0 Preview 3.0. Can repro on android platform with sample project. https://github.com/davidbritch/dotnet-maui-issues/tree/main/Embedding

nau-dwb commented 8 months ago

Note the Page.Appearing and Page.Disappearing events also do not fire when using MAUI embedded.

We're trying to migrate our mission critical mobile application from Xamarin Android\iOS with embedded Xamarin Forms to .NET 7 Android\iOS using embedded MAUI and the embedded use case appears to be severely broken. This is but one of many issues we've encountered.

Being able to hook into when the page appears and disappears is a pretty common use case. This has been open since 2022 - can we please get some priority placed on resolving this? Not sure if any of the work proposed under Issue 1718 would get this closer to resolved?

I also have sample repro code in the 'simple-maui-embedded' solution from https://github.com/nau-dwb/maui-embedded-use-issues/tree/main

follesoe commented 5 months ago

Issues like these are hindering migration for several larger Xamarin apps to MAUI. We have an app making extensive use of Xamarin.Forms embedding.

PureWeen commented 4 months ago

Unfortunately, we didn't properly take into account multi-window with embedding so there are a few paths that don't light up with embedding.

I've modified the sample here to light up "appearing" and "disappearing"

https://github.com/PureWeen/maui-embedded-use-issues/commit/dd8a660ec9e595ce15274c26777035cc1a328b2d

In XF we just wired appearing/disappearing to platform hooks so that's really what this work comes down to.

If for some reason the code I have setting up a window doesn't work for you, then I'd just recommend calling through to your own methods on the ContentPage that fire at the same points in time