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

Android/Forms Tabpage OnDisappearing firing minimized #1438

Closed
davidortinau opened this issue Dec 20, 2017 · 14 comments

Comments

@davidortinau
Copy link
Contributor

commented Dec 20, 2017

Migrated from https://bugzilla.xamarin.com/show_bug.cgi?id=44211

Description

Steps to Reproduce

Run Sample for Tabs Android Forms.

Click Push Page2.
Click Push Tab

Tab Message:
Tab2Page2 Appear (OK)
TabPage1 Appear (OK)
TabPage1 Disappear (WHY? wrong)
TabPage1 Appear (WHY 2 times?)
Tabpage2 Disappear (WHY?)

Expected Behavior

What I think should happen.
TabPage1 Appear
TabPage2 Appear

Proposed solution: #354

Basic Information

  • Version with issue: 2.4.0.91020

Reproduction Link

FormsAppearDisappear.zip

@davidortinau davidortinau added this to Ready in v3.0.0 via automation Dec 20, 2017
@pauldipietro pauldipietro added this to New in Triage Dec 20, 2017
@brux88

This comment has been minimized.

Copy link

commented Dec 20, 2017

how i can fix this behavior?

@edecision-plaroche

This comment has been minimized.

Copy link

commented Dec 21, 2017

Hi Guys,

It is crazy, i posted a solution since last may 2017 on the PR 354.

It is seems nobody want really solve this problem.

If you comment lines 37 to 51 in FragmentContainer.cs, the events appears all normal....

public override bool UserVisibleHint
{
	get { return base.UserVisibleHint; }
	set
	{
		base.UserVisibleHint = value;
//		if (_isVisible == value)
//			return;
//		_isVisible = value;
//		if (_isVisible.Value)
//			PageController?.SendAppearing();
//		else
//			PageController?.SendDisappearing();
	}
}

In facts, if you comment thoses lines (UserVisibleHint), methods below, do their jobs.

public override void OnHiddenChanged(bool hidden)
{
	base.OnHiddenChanged(hidden);

	if (Page == null)
		return;

	if (hidden)
		PageController?.SendDisappearing();
	else
		PageController?.SendAppearing();
}

public override void OnPause()
{
	bool shouldSendEvent = Application.Current.OnThisPlatform().GetSendDisappearingEventOnPause();
	if (shouldSendEvent)
		SendLifecycleEvent(false);

	base.OnPause();
}

public override void OnResume()
{
	bool shouldSendEvent = Application.Current.OnThisPlatform().GetSendAppearingEventOnResume();
	if (shouldSendEvent)
		SendLifecycleEvent(true);

	base.OnResume();
}

Can someone confirm that ?
Best regards,
Paulin

@rmarinho rmarinho moved this from New to Ready For Work in Triage Dec 21, 2017
@nbsoftware

This comment has been minimized.

Copy link

commented Dec 31, 2017

Just to confirm that the bug is indeed hitting me too with latest XF 2.5.0.121934
Any clue of when that can be fixed?

@JayShockwave

This comment has been minimized.

Copy link

commented Jan 1, 2018

This is happening for me too.

@rmarinho rmarinho self-assigned this Jan 9, 2018
@rmarinho rmarinho moved this from Ready to In Progress in v3.0.0 Jan 9, 2018
@rmarinho

This comment has been minimized.

Copy link
Member

commented Jan 10, 2018

@JayShockwave @nbsoftware what0s the issue you are seeing? the only thing i see is that TabPage1 Appearing doesn't fire the 1st time with the latest 2.5.0

@nbsoftware

This comment has been minimized.

Copy link

commented Jan 10, 2018

After some digging, I found that my issue was actually something else, unrelated to this one.
Sorry.

@JayShockwave

This comment has been minimized.

Copy link

commented Jan 10, 2018

@rmarinho I spend a good part of this morning trying to reproduce the behavior in a simpler form to illustrate but I am unable to do so. Must be a bug in my code. Disregard my comment, thanks.

@xMRi

This comment has been minimized.

Copy link

commented Jan 17, 2018

I can repro the case. And I have a very basic and simple sample.
I am using the Xamarin.Forms Version 2.5.0.122203!

Main Page launching TabbedPage with 2 pages Page1 and Page2

Page1::OnAppearing is called twice. Launch application. Click button. Debug output shows:

[0:] MainPage::OnAppearing
[0:] MainPage::OnTestClicked
[0:] Page1::OnAppearing
[0:] Page1::OnDisppearing
[0:] Page1::OnAppearing

DoubleOnAppear.zip

@rmarinho rmarinho referenced this issue Jan 18, 2018
0 of 4 tasks complete
@rmarinho rmarinho closed this in d2f6ffa Feb 20, 2018
Triage automation moved this from Ready For Work to Invalid Feb 20, 2018
v3.0.0 automation moved this from In Progress to Done Feb 20, 2018
jsuarezruiz added a commit to XamarinFormsCommunity/Xamarin.Forms that referenced this issue Feb 28, 2018
* 'master' of https://github.com/xamarin/Xamarin.Forms: (23 commits)
  [C] use direct cast
  [Core, iOS, Android, UWP, WPF] Hide scroll view scroll bars (xamarin#1910)
  Allow users to specify resolution method for handlers, effects, and services (xamarin#1870) fixes xamarin#1739
  [Build] Update submodule
  Capitalization keyboard flag additions for Entry/Editor (xamarin#1683) (xamarin#1833)
  [Build] Don't specify .net sdk version
  Simplify event raising invocation pattern (xamarin#1971)
  [iOS Maps] Pin rendering customization (xamarin#1065)
  set csharp_space_after_keywords_in_control_flow_statements to true to fit our design guide lines (xamarin#1964)
  [iOS] Add shadow effect (xamarin#1896)
  Added support for ListView full width separators on iOS (xamarin#1854) fixes xamarin#1665
  Support CascadeInputTransparent to Tizen (xamarin#1916)
  [Android]?Remove UserVisibleHint (xamarin#1550) fixes xamarin#1438
  [iOS] ViewDidLayoutSubviews after removing page (xamarin#1532) fixes xamarin#1426
  Use relative URL to support recursive checkout in VSTS (xamarin#1926)
  [UITest] Fix test for UITest package update (xamarin#1923)
  Implemented MaxLength property on Entry and Editor (xamarin#1880)
  [Build]Fix master and build (xamarin#1920)
  [Build] Fix windows cert
  Fix to absolute URL
  ...

# Conflicts:
#	Xamarin.Forms.Controls/CoreGalleryPages/EditorCoreGalleryPage.cs
#	Xamarin.Forms.Controls/CoreGalleryPages/EntryCoreGalleryPage.cs
#	Xamarin.Forms.Core/InputView.cs
#	Xamarin.Forms.CustomAttributes/TestAttributes.cs
#	Xamarin.Forms.Platform.Android/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.MacOS/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.MacOS/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.Tizen/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.WPF/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.WPF/Renderers/EntryRenderer.cs
#	Xamarin.Forms.Platform.iOS/Renderers/EditorRenderer.cs
#	Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs
@vhugogarcia

This comment has been minimized.

Copy link

commented Mar 10, 2018

The issue is still present on latest stable version of Xamarin.Forms. Do you know if the version 2.5.1 is going to contain this fix?

btw, the issue is not only for the event onDisappearing but also the event onAppearing.

@LeoJHarris

This comment has been minimized.

Copy link

commented Mar 18, 2018

I just installed forms 2.5.1 into my project and the OnAppearing is still being called twice. Pretty sure there needs also to be a new issue "Android/Forms Tabpage OnAppearing firing minimized".

@nbsoftware

This comment has been minimized.

Copy link

commented Jun 12, 2018

Hello,

May I ask why this one seems to be closed?

As far as I can see, I still have the issue with in latest XF 3.0.0.561731.

Is it because it is linked to #2240 which happens to be still opened (although it think it is not the exact same issue)?

This is very frustrating because I have a XF Map on the first tab and it refreshes in a very very ugly way when switching from another tab to this one - only in Android of course.

@samhouts samhouts removed this from Closed in Triage Jun 12, 2018
@davidortinau

This comment has been minimized.

Copy link
Contributor Author

commented Jun 13, 2018

Hi @nbsoftware, please open a new issue with a sample project demonstrating the problem if you're issue doesn't appear to be solve in the latest 3.0.0.

@nbsoftware

This comment has been minimized.

Copy link

commented Jun 14, 2018

Hi @davidortinau ,
Well you are correct, with the sample attached to this issue, it does work now.
After further investigation, my project involves a specific Android BottomBar implementation as well as NavigationPages for all tab pages.
In that context, the bug still appears in latest XF versions.
It does not if tab pages are simple pages.
But the weird thing is that it wasn't happening with some previous version of XF.
I'll try to take some time to build 2 samples demonstrating the problem and create a new issue.
Thanks

@JFMG

This comment has been minimized.

Copy link

commented Nov 22, 2018

Hi everyone,
this bug is fixed in the latest Xamarin.Forms version. However, if you still might use the NuGet package ThriveGmbH.BottomNavigationBar.XF, you will still have this issue. To solve it you have to remove this NuGet package from all of your projects and use the Xamarin.Forms toolbar placement for Android which was introduced with Xamarin.Forms 3.1.

Solution:
Reference 1: https://blog.xamarin.com/xamarin-forms-3-1-improvments/#androidbottomtabs
Reference 2: https://montemagno.com/xamarin-forms-official-bottom-navigation-bottom-tabs-on-android/

It was less than 10 lines of code which I had to change to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.