-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Android] OnAppearing only called on 1st tab of AppShell home page #9531
Comments
I'm having the same problem in one of our projects |
This is a relatively important issue when the page is dependent on OnAppearing() to load the data for the page. Is there another alternative to OnAppearing to accomplish loading the data for the page? Should I attempt to load the data for all of the tabbed pages when the 1st tab page is initialized? Is anyone looking/working on this? |
I think this is already being looked at. Check out "OnAppearing not triggered when going back from Modal page #8513" |
I have also problems with OnAppearing for tabs. It is executed many times on Windows (#10161) and it is not executed at all when tabs are switched on Androind. |
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. |
It is sad that it will not be fixed in the near future. The issue is quite important because it OnAppearing is used to load data (or do other initializations that requires async/await). I am also using OnAppearing/OnDisappearing to subscribe/unsubscribe events, start/stop sound and other task that are done in background. This can cause big problems when these methods does not run when the developer expects them (in case of Android), or if the run multiple times instead of once (in case of Windows). |
Having the same issue. Lost two days of work because I thought I was doing some mistakes. MAUI really is full of bugs, and I can accept it because of its juvenility. But bugs like these I think should be prioritized. I must abandon the Tab structure in my app structure because of this issue |
This issue has been around for 4 years, already existed in Xamarin.Forms: This makes AppShell tabs behavior very inconsistent between iOS and Android and is likely to confuse new MAUI developers a lot. Workaround: |
Duplicate of #8102 ? |
Yes. I think @PureWeen you guys should just summarize these all into one issue (see the links just in this issue, #8513, #8102, #10161). This really applies to many different other types of issues as well; dotnet/maui repo now has over 2.1k issues and steadily climbing, and how is it feasible to keep track of what is actually important and keep a high-level overview and do release(sprint planning if duplicates are not being eliminated?! |
Like many others here, I am BOGGLED that this is considered "not critical", and not worth fixing in the foreseeable future. It's a pretty common pattern to have a set of actions to do when coming into a page (any time, not just the first time it loaded). Things such as mentioned above, updating controls, changing styles, binding values, or any number of other things, based on the current state of the application. Not being able to do this means that MAUI is all but useless (at least on Android) for anything except the simplest, most basic of applications (ie... nothing needing to deal with local state). |
Hello. I have come here from #8513 as that was the precise scenario I was running into this (OnAppearing not running after popping a modal page), but that issue has been closed. Since this issue is still open I will add my comments here instead. I have the same version as specified in the closed issue (7.0.59) which supposedly has the fix, and yet not fixed. In fact the opposite, this is the first time I've ever run into this issue - was working rock solid up until my latest VS upgrade (from 17.4.3 to 17.5.1). This is on Windows (I haven't tried other platforms yet). I especially wanted to note that this only happens intermittently! So although in the closed issue it appeared to be fixed, it may not have been. I haven't yet identified any common scenario where it happens to where it doesn't happen. I'll let you know if I notice any such patterns, but yeah, this is like taking you car to the mechanic and it all works fine at the workshop, but plays up again when you get home. Argh. P.S. this is using .NET 7 |
This person also experiencing the issue a few days ago https://stackoverflow.com/questions/75635738/navigation-pushmodalasync-does-not-trigger-onappearing-in-maui |
Just had it happen again and have some (hopefully) helpful diagnostic information for you. Context is I have a page which, in OnAppearing, goes through and lists existing accounts on the page (which is a ContentPage nested in a NavigationPage). I have debug statements throughout OnAppearing, From this page I can click a button to edit/add an account, also with debugs throughout. It is pushed as a ModalPage, and popped when you click on the "Save" button... at which point, of course, the OnAppearing should run again and produce the updated listing of accounts. So what happens when it's working correctly is... What ACTUALLY happened this time was,,, Ran correctly when I added the first account. Then I click to add 2nd account, and right after that OnAppearing starts running even though I just hid the page! It finishes running before I finish creating the 2nd account, and when I save that OnAppearing fails to run this time. And that then caused further problems due to resource contention (which should never happen, because OnAppearing shouldn't be running whilst I'm still in the pushed EditAccount page). Seems to me that a bit has (not) been reversed somewhere and now it thinks disappearing is appearing and appearing is disappearing. UPDATE: I've ruled out one thing I thought it might be. The issue is most definitely related to OnAppearing getting it's sense reversed somehow - runs when page disappears, doesn't run when it appears. It doesn't happen every time, but it happens a lot. i.e. in the scenario where I'm trying to add 2 accounts, I usually get the first account added, but almost never get the 2nd account added. In about 12 tries I only got 2 accounts added once. In other words, when you're trying this out, make sure you set up a scenario where you are repeatedly pushing/popping and you should be able to reproduce (no, I can't share the app that I'm having this happen in, sorry). |
@SmartmanApps I advise you read the thread on the other issue (#8102) for explanations and work-arounds. You'll see the fix was scheduled for Service Release 4 (see #8102 (comment)). 7.0.59 is Service Release 3. I have no Idea when SR4 will be released. |
Hey @durandt, Thanks, but I tried using Shane's workaround nuget and it didn't fix my issue. It references shell, so maybe it only works with shell? I'm experiencing the issue on Windows with a Content/NavigationPage. Thanks. |
@SmartmanApps this issue concerns Android and Shell. Look for an existing issue matching yours for Windows or create a new one. |
Hello @durandt, This is an issue with OnAppearing. It happens on both Windows and Android. i.e. it's an issue with MAUI OnAppearing, all platforms, possibly all wrappers as well (ContentPage/NavigationPage, Shell). The issue here, if not the exact same issue (which I strongly suspect it is), then it's at least an underlying issue which you can't resolve this issue until the underlying OnAppearing issue is resolved (if in fact they are separate issues to begin with, but I strongly doubt it). Get someone who is using shell tabbed pages to put the same diagnostics in their app as I have and you will probably see the same thing happenning (OnAppearing runs a 2nd time prematurely, then doesn't run when it's supposed to the next time, in this case that would be on the 2nd tabbed page, for me it was when I did my first PopModalAsync). I'm not going to raise a new issue only to have it closed as being a duplicate of this one. I already spent half a day collecting diagnostics which I have supplied, but you need to get someone who is having this issue on shell tabbed pages to perform the same diagnostics - I suspect that will prove it's the same issue, an issue with OnAppearing (all platforms, all wrappers). This issue matches what I'm seeing, I'm just not using Shell. |
They've all been closed now - this is the only one still open. I don't think 8102 is a duplicate, because people have reported the supplied workaround works for them, but it didn't work for me (that appears to be a Shell issue, not an OnAppearing issue). On the other hand I'm pretty sure the other 2 are duplicates - in any case they've both been closed. I'm not raising another issue lest it also get closed as a duplicate of this one. We need to prove one way or another if they're all the same issue or not. See diagnostics I've supplied (put a debug at the start and end of OnAppearing, and anything else you're clicking on, like a Push/PopModalAsync, 2nd tabbed page, whatever). I'll also note again it's an intermittent fault, so you may need to try it several times. |
I found this and suspect it may be a fix for my issue (incorrect OnAppearing life-cycles), and probably also this issue (incorrect OnAppearing life-cycles), if someone can just do the necessary diagnostics to see if they are indeed the same issue - #13177 (comment) |
Verified this issue with Visual Studio Enterprise 17.6.0 Preview 7.0. Repro on Android platform with sample project. But windows works fine. |
What is the state here, is it fixed or not (#8102 is marked as fixed in 7.0.81), but this is still open? |
Description
On the Android, when I have 2 tabs defined for an AppShell homepage, the OnAppearing method doesn't get called for the ContentPage when I select the 2nd tab. It does get called on the 1st tab contentpage which is initially called when the home page is displayed .
I am using Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version 17.4.0 Preview 1.0 on Windows 11.
Steps to Reproduce
Version with bug
6.0.312
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 12, API 31
Did you find any workaround?
No
Attached app
Xaminals.zip
No response
The text was updated successfully, but these errors were encountered: