Bug 41322 - OnAppearing/Disappearing triggers for all pages in navigationstack backgrounding/foregrounding app
Summary: OnAppearing/Disappearing triggers for all pages in navigationstack background...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.2.0
Hardware: All Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 48517 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-05-26 07:44 UTC by Björn Bentmar
Modified: 2017-03-10 18:20 UTC (History)
19 users (show)

See Also:
Tags: ac
Is this bug a regression?: Yes
Last known good build: 2.1.06529


Attachments
XF2.2 solution with android project (1.16 MB, application/x-rar)
2016-05-26 07:44 UTC, Björn Bentmar
Details
repro (202.78 KB, application/zip)
2016-09-10 16:23 UTC, adrianknight89
Details

Description Björn Bentmar 2016-05-26 07:44:54 UTC
Created attachment 16109 [details]
XF2.2 solution with android project

This bug came in XF 2.2 and only happens when using FormsAppCompatActivity.

What happens in that all pages that are alive call onappearing/disappearing when you toggle outside app OR change activity when taking photos with Xam.Plugin.Media for example. The appearing calls trigger even after removing a Page from navigation stack with Navigation.RemovePage(), this is also shown in my repro. The bug is both on emulators and harware pre and post lollipop. If you use the standard FormsApplicationActivity everything works just like its supposed to. I´ve added a repro that perfectly shows you this. This forced me to dowgrade many of my projects since logic in appearing/disappearing events went totally crazy resulting in breaking my apps. Ive also tested the latest prerelease of XF2.3 and its the same thing there. Because this causes all pages in stack to call appearing when going back to app, the acutal appearing is not called when its actually appearing, same thing for disappearing.

Please fix this!
Comment 1 Björn Bentmar 2016-05-26 08:22:15 UTC
(more information)

## Version information
Microsoft Visual Studio Professional 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Professional

Visual Basic 2015   00322-40000-00000-AA983
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA983
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA983
Microsoft Visual C++ 2015

ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11106.0
ASP.NET and Web Tools 2015.1 (Beta8)

Common Azure Tools   1.7
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio   1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

GorillaPlayerPackage Extension   1.0
GorillaPlayerPackage Visual Studio Extension Detailed Info

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   3.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60311.1
Microsoft SQL Server Data Tools

TypeScript   1.8.30.0
TypeScript tools for Visual Studio

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   4.0.3.214 (0dd817c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.0.3.5 (a94a03b)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   9.6.1.8 (3a25bf1)
Visual Studio extension to enable development for Xamarin.iOS.

##Steps to reproduce:
1. Download attachment
2. An alert will display triggered from OnAppearing, press ok
3.Navigate to page 2
4. Navigate to page 3
5. Toggle in and out of app, see output and dismiss Alerts.
(There are instructions in the app also)


##Expected behaviour:
The expected behaviour would be that the page calls appearing or disappearing when it actually is appearing or disappearing. It works just like its supposed to with standard FormsApplicationActivity instead of FormsAppCompatActivity

##Actual behaviour
All pages that are alive AND removed from stack with Navigation.RemovePage() call Appearing/disappearing when toggling in and out of app, or taking photo (changing activity)

##
Comment 3 Taylor 2016-07-25 18:18:38 UTC
Any update on this?  It's causing us quite a few problems as we launch the camera frequently and rely on the onAppearing once the camera has been dismissed.
Comment 4 Björn Bentmar 2016-08-01 17:57:23 UTC
Nothing has been done to solve it (based on what Xamarin has released)...
Comment 5 Jordan Foo 2016-08-29 02:59:14 UTC
Hi All,
I've also filed a bug that's different to reproduce, but exposes the same observed behaviour - All pages in the navigation page firing OnAppearing event.
However, for the reported bug, it occurs for both FormsAppCompatActivity & FormsApplicationActivity.
https://bugzilla.xamarin.com/show_bug.cgi?id=43815
Comment 6 adrianknight89 2016-09-10 16:22:27 UTC
I have this issue when I hit the power button to lock the screen. When I unlock, onappearing of previous pages will be called. :(
Comment 7 adrianknight89 2016-09-10 16:23:28 UTC
Created attachment 17407 [details]
repro

Navigate to Page2 and then lock the screen. When you unlock, keyboard from Page1 will show.
Comment 8 adrianknight89 2016-09-10 21:52:57 UTC
I submitted a PR in case it fixes your use cases. Please see https://github.com/xamarin/Xamarin.Forms/pull/342
Comment 9 Björn Bentmar 2016-09-14 10:10:37 UTC
I tested the dlls from made from the PR on my repro. And it works like its supposed to! :D

Please Xamarin include this fix asap :)
Comment 10 Samantha Houts [MSFT] 2016-09-30 23:12:59 UTC
Should be fixed in 2.3.4-pre1. Thank you!
Comment 11 Björn Bentmar 2016-09-30 23:17:13 UTC
GREAT! Thank you! :D
Comment 12 Parmendra Kumar 2016-12-01 14:09:46 UTC
I have checked this issue with Xamarin.Forms 2.3.4-pre1 and I have used sample attached in comment #7 and followed instruction and observed that this issue has been fixed.


Hence closing this issue.


Thanks.
Comment 13 Samantha Houts [MSFT] 2016-12-01 19:33:41 UTC
*** Bug 48517 has been marked as a duplicate of this bug. ***
Comment 14 Zafar 2016-12-21 20:59:03 UTC
Checked the issue with Xamarin.Forms 2.3.4.171-pre1, still getting reproduced. Please reopen the bug
Comment 15 Brendan Zagaeski (Xamarin Support) 2016-12-21 21:15:19 UTC
## Preliminary quick review of Comment 14

Note that unless the original test case from Comment 1 or Comment 7 still replicates the issue, then the best next step for Comment 14 will be to file a new bug report that includes a new test case that replicates the problem.

(If any of the CC list members of the bug gets a chance to double-check the earlier test cases from Comment 1 and Comment 7, that would be a good step too.)

Thanks in advance!
Comment 16 Jens-Christian 2017-02-06 14:19:19 UTC
Bug is not fixed in all cases, see https://bugzilla.xamarin.com/show_bug.cgi?id=52318
Comment 17 Diego 2017-03-10 17:59:37 UTC
Tested in version 2.3.4.212-pre4 this bug remains.
Please reopen
Comment 18 Brendan Zagaeski (Xamarin Support) 2017-03-10 18:20:35 UTC
## Note to the Xamarin team

The user from Comment 17 also commented a little later on Bug 52318, so Bug 52318 can be used as the location for the future updates on this issue.

Note You need to log in before you can comment on or make changes to this bug.