Bug 40333 - [Android] IllegalStateException: Recursive entry to executePendingTransactions
Summary: [Android] IllegalStateException: Recursive entry to executePendingTransactions
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
: 40639 ()
Depends on:
Reported: 2016-04-13 09:32 UTC by Michael Rumpler
Modified: 2016-07-05 06:49 UTC (History)
7 users (show)

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

text from output window (274.29 KB, text/plain)
2016-04-13 09:32 UTC, Michael Rumpler
repro project with XF 2.2 (196.23 KB, application/x-zip-compressed)
2016-04-13 14:13 UTC, Michael Rumpler
repro project with XF (193.00 KB, application/x-zip-compressed)
2016-04-13 14:15 UTC, Michael Rumpler
repro project with XF (192.80 KB, application/x-zip-compressed)
2016-04-13 14:17 UTC, Michael Rumpler

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 Michael Rumpler 2016-04-13 09:32:08 UTC
Created attachment 15694 [details]
text from output window

I updated my app to use XF, but now I get the "Recursive entry to executePendingTransactions" exceptions every time I try to navigate. With the old version (2.1) I only got it sometimes and with I didn't see it at all.

My MainPage is a MasterDetailPage (MasterBehavior=Split) with NavigationPage for both Master and Detail. And my app uses AppCompat. On a phone, this is different, but I'm only testing on the tablet now.

The Master shows a ListView and when the user taps an item, then a new page is pushed to the Master navigation. OnAppearing of that new page in the Master I replace the whole navigation stack of the detail with a new page. I.e. I call InsertPageBefore to insert the new page at the beginning and then do a PopToRootAsync.

This results in an IllegalStateException: Recursive entry to executePendingTransactions

I attached all the text from my output window including the stack trace of the exception at the very end. The stack trace includes Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnPopToRootAsync, so it appears that it happens in my master page's OnAppearing event where I call this method:

	public static async Task NavigateDetailTo(ViewModel viewModel, bool focusDetail)
		var mainPage = MainPage;
		var md = mainPage as MasterDetailPage;
		if(md != null)
			// tablet
			var detailNav = md.Detail.Navigation;
			var currentRoot = detailNav.NavigationStack[0];
			var currentVM = currentRoot.BindingContext;
			if (currentVM == null || currentVM.GetType() != viewModel.GetType())
				var newPage = ViewFactory.CreatePage(viewModel);
				detailNav.InsertPageBefore(newPage, currentRoot);
				currentRoot.BindingContext = viewModel;

			if(detailNav.NavigationStack.Count > 1)
				await detailNav.PopToRootAsync();
			// phone

The output also shows that the app hangs when I try to build my MasterDetailPage with many thread/GC problems, but I'll open a separate bug for that.

I'll try to make a repro project for this bug and attach it when it is finished.
Comment 1 Michael Rumpler 2016-04-13 14:13:57 UTC
Created attachment 15696 [details]
repro project with XF 2.2

This repro project uses XF The exception happens every time you tap an item in the ListView in the Master.
Comment 2 Michael Rumpler 2016-04-13 14:15:49 UTC
Created attachment 15697 [details]
repro project with XF

This project uses the exact same code as the others, but it uses XF The exception comes sometimes when going back.
Comment 3 Michael Rumpler 2016-04-13 14:17:22 UTC
Created attachment 15698 [details]
repro project with XF

This project also uses the exact same code, but XF
Navigation works as expected. There is no exception.
Comment 4 Michael Rumpler 2016-04-13 14:43:29 UTC
This is the same exception as in https://bugzilla.xamarin.com/show_bug.cgi?id=39403 although that was said to be fixed in 2.2.0-pre1. Well, maybe in case of a TabbedPage, but not with a MasterDetailPage.
Comment 5 Samantha Houts [MSFT] 2016-04-24 20:51:15 UTC
*** Bug 40639 has been marked as a duplicate of this bug. ***
Comment 6 Michael Rumpler 2016-05-17 07:57:46 UTC
I now checked with XF and - still the same problem.
Comment 7 Michael Rumpler 2016-05-27 12:09:31 UTC
I would look at this myself, but unfortunately bug #39403 was fixed before XF was open sourced and thus I don't see what has been changed for that. Apparently those changes fixed the same exception for a TabbedPage but made it worse in my situation.
Comment 8 E.Z. Hart [MSFT] 2016-06-01 21:00:19 UTC
We have a fix in for this problem; it will be available in an upcoming release.
Comment 9 Samantha Houts [MSFT] 2016-06-16 16:41:45 UTC
Should be fixed in 2.3.1-pre1
Comment 10 Parmendra Kumar 2016-07-01 07:53:30 UTC
I have checked this issue with Xamarin.Forms 2.3.1-pre1 and used sample project attached in comment #1 and observed that its working fine.

Hence closing this issue.

Comment 11 Michael Rumpler 2016-07-05 06:49:27 UTC
Yes, looks good so far. Thank you!