Bug 52318 - OnAppearing/Disappearing triggers for all pages in navigationstack backgrounding/foregrounding app
Summary: OnAppearing/Disappearing triggers for all pages in navigationstack background...
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-02-06 14:18 UTC by Jens-Christian
Modified: 2017-07-13 13:15 UTC (History)
13 users (show)

Is this bug a regression?: ---
Last known good build:

Test case to trigger error (54.18 KB, application/x-zip-compressed)
2017-02-07 07:00 UTC, Jens-Christian
NavPageProject.zip (73.63 KB, application/zip)
2017-03-02 11:42 UTC, Ione Souza Junior
Attached IDE logs (3.48 KB, application/x-zip-compressed)
2017-07-13 06:41 UTC, Aman Dharwal

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jens-Christian 2017-02-06 14:18:49 UTC
This is almost the same as https://bugzilla.xamarin.com/show_bug.cgi?id=41322, except that I'm using MasterDetailPage, not NavigationPage as my MainPage.

When using MasterDetailPage, the error is still present.

I'm testing using Xamarin.Forms
Comment 1 Björn Bentmar 2017-02-06 14:36:55 UTC
Can you describe the case a bit more?
Comment 2 Jens-Christian 2017-02-07 07:00:40 UTC
Created attachment 19745 [details]
Test case to trigger error

I have modified the example from https://bugzilla.xamarin.com/show_bug.cgi?id=41322, to use MasterDetailPage instead, to trigger this error.

The error is that when you have several pages in the navigation stack, and navigation out of the application (push home button, open web page with Device.OpenUri, take a photo, etc), all pages in the navigation stack receives OnAppearing, and will not receive OnAppearing when the pages are popped from the navigation stack.
Comment 3 Björn Bentmar 2017-02-07 10:05:51 UTC
sigh.. I just confirmed it, the same behavour still appears from the bug https://bugzilla.xamarin.com/show_bug.cgi?id=41322 when the NavigationPage is the detailpage of a MasterDetailPage.
Comment 4 Björn Bentmar 2017-02-07 10:24:35 UTC
However, this can be worked around.

in you App.cs add:


Now if you want to trigger appearing/disappearing on resume/pause, use the native resume/pause and implement a message for your own appearing/disappearing logic when app resumes or pauses
Comment 5 Jens-Christian 2017-02-07 11:18:48 UTC
Thank you for the workaround, I will look into it if the error isn't fixed when Xamarin.Forms 2.3.4 goes stable.
Comment 6 adrianknight89 2017-02-09 04:54:01 UTC
See https://github.com/xamarin/Xamarin.Forms/pull/754
Comment 7 Ione Souza Junior 2017-03-02 11:41:50 UTC
I found a similar problem, I looking for similar issues before create new ticket and found this.

Behaviour in iOS: 
1) Open app;
2) Navigate to second page
3) Put the app in background

After this, OnDisappearing event on page 2 is not called.

4) Put the app in foreground

After this, OnAppearing event on page 2 is not called.

Behaviour in Android

1) Open app;
2) Navigate to second page
3) Put the app in background

After this, OnDisappearing event on page 2 is called.

4) Put the app in foreground

After this, OnAppearing event on page 1 and 2 are called.

I attach sample project named NavPageProject for testing.

Informations about my environment:

=== Xamarin Studio Community ===

Version 6.2 (build 1821)
Installation UUID: a6a5f1a6-63ce-4c25-b5f7-1942c9a48cde
	Mono 4.8.0 (mono-4.8.0-branch/e4a3cf3) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000495

=== NuGet ===


=== Xamarin.Profiler ===

Version: 1.0.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: (Xamarin Studio Community)
Android SDK: /Users/ionixjunior/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.4 (API level 19)
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.Mac ===

Version: (Xamarin Studio Community)

=== Xamarin.iOS ===

Version: (Xamarin Studio Community)
Hash: 35d1ccd
Branch: cycle9
Build date: 2017-02-16 17:40:00-0500

=== Xamarin Inspector ===

Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Build Information ===

Release ID: 602001821
Git revision: d41b6e51f3fa46a1943f2e31a778d28a7c73d069
Build date: 2017-02-17 15:18:19-05
Xamarin addins: 1363a8d943bab7700c93a97474060b6734aa7f94
Build lane: monodevelop-lion-cycle9

=== Operating System ===

Mac OS X 10.12.0
Darwin ione.local 16.0.0 Darwin Kernel Version 16.0.0
    Mon Aug 29 17:56:20 PDT 2016
    root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64
Comment 8 Ione Souza Junior 2017-03-02 11:42:53 UTC
Created attachment 20083 [details]

Sample project.
Comment 9 thomas 2017-03-10 07:53:36 UTC
This especially a problem for all users of RxUI as it heavily relies on the WhenActivated pattern which uses the OnAppearing Hook
Comment 10 Diego 2017-03-10 18:02:43 UTC
Tested in Xamarin.Forms, this bug remains.
Using MasterDetail
Comment 11 Rui Marinho 2017-03-14 12:05:05 UTC
Should be fixed on 2.3.5-pre1
Comment 12 Diego 2017-03-30 12:46:47 UTC
@Rui, where could we get the version 2.3.5-pre1. So far the latest version in Nuget is
Comment 13 Aman Dharwal 2017-07-13 06:41:46 UTC
Created attachment 23514 [details]
Attached IDE logs

This issue doesn't exist anymore, hence marking it as Verified


Verified on Environment :


package id="Xamarin.Forms" version=""


Screencast link : https://www.screencast.com/t/2IvSgxBcEbM
Comment 14 thomas 2017-07-13 11:28:39 UTC
I just tested it and it seems that OnAppearing doesn't get called at all when backgrounding/foregrounding at least when using a TabbedPage as MainPage.
Comment 15 thomas 2017-07-13 12:10:18 UTC
Strange, tested it with another Solution and there it just works fine
Comment 16 thomas 2017-07-13 13:15:23 UTC
While closer looking I found some other odd behaviour. At startup when using a TabbedPage as MainPage you can observe this Call sequence for the active TabbedPage:


You can reproduce it with this App


You get this Output

[0:] ++++++++++++++++++++++++++++++TweetListPage OnAppearing
07-13 15:05:53.010 I/OpenGLRenderer(10466): Initialized EGL, version 1.4
WARNING: linker: /vendor/lib/libhwuibp.so: unused DT entry: type 
07-13 15:05:53.020 W/linker  (10466): /vendor/lib/libhwuibp.so: unused DT entry: type 0xf arg 0xeb5
0xf arg 0xeb5
Thread started: <Thread Pool> #14
InspectorDebugSession(7): HandleTargetEvent: ThreadStarted
07-13 15:05:53.098 W/Mono    (10466): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
07-13 15:05:53.101 W/Mono    (10466): The request to load the assembly System.Core v4.0.0.0 was remapped to v2.0.5.0
[0:] ++++++++++++++++++++++++++++++++TweetListPage OnDisappearing
[0:] ++++++++++++++++++++++++++++++TweetListPage OnAppearing