Bug 21400 - Android - pre1 - MasterDetail - Toolbar bug
Summary: Android - pre1 - MasterDetail - Toolbar bug
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.2
Hardware: Other Other
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-17 14:13 UTC by daniel.luberda
Modified: 2014-10-16 18:24 UTC (History)
4 users (show)

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

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:
Status:
RESOLVED FIXED

Description daniel.luberda 2014-07-17 14:13:12 UTC
Steps: 
1. Tap "MasterDetail - Toolbar bug" cell. New page is opened
2. Press back button
3. Try to open "MasterDetail - Toolbar bug" cell again. 

Result:
1. "MasterDetail - Toolbar bug" cell cannot be tapped
2. Toolbar item on MainMenu is "ToolbarItem2" not ToolbarItem1


public class MainMenu : ContentPage
{
	MasterDetailToolbarBug secondPage = new MasterDetailToolbarBug();

	public MainMenu()
	{
		Title = "XamarinTest MainMenu";

		var menu1 = new MainMenuCell("MasterDetail - Toolbar bug", "Icon.png");
		menu1.Tapped += (o, e) => 
		{
			Navigation.PushAsync(secondPage);
		};

		var menu = new TableView() {
			VerticalOptions = LayoutOptions.FillAndExpand,
			HorizontalOptions = LayoutOptions.FillAndExpand,
			HasUnevenRows = true,
			Intent = TableIntent.Menu,
			Root = new TableRoot {
				new TableSection("Menu")
				{ 
					menu1,
				}
			}
		};

		Content = menu;

		ToolbarItems.Add(new ToolbarItem("ToolbarItem1", "Icon.png", () => {}));
	}

	class MainMenuCell : ViewCell
	{
		public MainMenuCell(string title, string iconFile)
		{
			View = new StackLayout() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Orientation = StackOrientation.Horizontal,
				Spacing = 15,
				Padding = 10,
				Children = {
					new Image() {
						Source = ImageSource.FromFile(iconFile),
						VerticalOptions = LayoutOptions.CenterAndExpand,
					},
					new Label() {
						Text = title,
						VerticalOptions = LayoutOptions.CenterAndExpand,
						Font = Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold)
					}
				}
			};
		}
	}
}

public class MasterDetailToolbarBug : MasterDetailPage
{
	public MasterDetailToolbarBug()
	{
		Title = "MasterDetailToolbarBug";

		Master = new ContentPage()
		{
			Title = "Master"
		};
		Detail = new ContentPage()
		{
			Title = "Detail",
		};
		Detail.ToolbarItems.Add(new ToolbarItem("ToolbarItem2", "Icon.png", () => {}));
	}
}
Comment 1 daniel.luberda 2014-07-17 14:58:14 UTC
Sometimes, exception is raised:

System.Diagnostics.Debugger.Mono_UnhandledException (ex={System.ArgumentException: 'jobject' must not be IntPtr.Zero.
Parameter name: jobject
at Android.Runtime.JNIEnv.CallNonvirtualBooleanMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00010] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.14-series/528056fd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:574
at Android.Support.V4.Widget.DrawerLayout.IsDrawerOpen (Android.Views.View) <IL 0x0009a, 0x0029b>
at Xamarin.Forms.Platform.Android.MasterDetailRenderer.get_Presented () <IL 0x00007, 0x0002e>
at Xamarin.Forms.Platform.Android.MasterDetailRenderer.set_Presented (bool) <IL 0x00002, 0x0002f>
at Xamarin.Forms.Platform.Android.MasterDetailRenderer.HandlePropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x0006a, 0x001c7>
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00044, 0x0007c>
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00042>
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00042>
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00042>
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00042>
at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00042>
at Xamarin.Forms.BindableObject.OnPropertyChanged (string) <IL 0x00012, 0x00087>
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty,object,bool,bool,bool) <IL 0x000a3, 0x002d7>
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty,object,bool,bool,bool) <IL 0x00213, 0x007cf>
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty,object,bool) <IL 0x0005a, 0x001e7>
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty,object) <IL 0x00004, 0x00037>
at Xamarin.Forms.MasterDetailPage.set_IsPresented (bool) <IL 0x0000c, 0x0005b>
.........
at Xamarin.Forms.ToolbarItem/<>c__DisplayClass2.<.ctor>b__0 (object,System.EventArgs) <IL 0x00006, 0x00029>
at Xamarin.Forms.ToolbarItem.Activate () <IL 0x00032, 0x000eb>
at Xamarin.Forms.Platform.Android.GenericMenuClickListener.OnMenuItemClick (Android.Views.IMenuItem) <IL 0x00006, 0x00029>
at Android.Views.IMenuItemOnMenuItemClickListenerInvoker.n_OnMenuItemClick_Landroid_view_MenuItem_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.14-series/528056fd/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.IMenuItem.cs:272
at (wrapper dynamic-method) object.ec658cb9-a934-4ebf-ba4f-c6ef2baaa2b6 (intptr,intptr,intptr) <IL 0x00017, 0x00023>
}) in
Comment 2 Eric Maupin 2014-07-17 18:52:19 UTC
Fixed for next release.
Comment 3 daniel.luberda 2014-07-30 15:53:33 UTC
Still valid in 4.2.2 (stable)

$exception	{System.ArgumentException: 'jobject' must not be IntPtr.Zero. Parameter name: jobject at Android.Runtime.JNIEnv.CallNonvirtualBooleanMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00010] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.14-series/7c475463/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:574 at Android.Support.V4.Widget.DrawerLayout.IsDrawerOpen (Android.Views.View) <IL 0x000aa, 0x0041f> at Xamarin.Forms.Platform.Android.MasterDetailRenderer.get_Presented () <IL 0x00007, 0x00057> at Xamarin.Forms.Platform.Android.MasterDetailRenderer.set_Presented (bool) <IL 0x00002, 0x0004f> at Xamarin.Forms.Platform.Android.MasterDetailRenderer.HandlePropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x0006a, 0x00297> at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00044, 0x0009f> at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00067> at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00067> at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00067> at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00067> at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00067> at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00067> at Xamarin.Forms.BindableObject.OnPropertyChanged (string) <IL 0x00012, 0x000c7> at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty,object,bool,bool,bool) <IL 0x000a3, 0x004f3> at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty,object,bool,bool,bool) <IL 0x00213, 0x00ab7> at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty,object,bool) <IL 0x0005a, 0x00277> at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty,object) <IL 0x00004, 0x00057> at Xamarin.Forms.MasterDetailPage.set_IsPresented (bool) <IL 0x0000c, 0x00083> at Xamarin.Forms.Platform.Android.MasterDetailRenderer.OnDrawerStateChanged (int) <IL 0x0000c, 0x0007b> at Android.Support.V4.Widget.DrawerLayout/IDrawerListenerInvoker.n_OnDrawerStateChanged_I (intptr,intptr,int) <IL 0x0000b, 0x000ab> at (wrapper dynamic-method) object.dc09efce-0430-4c51-9194-d24d53248162 (intptr,intptr,int) <IL 0x00017, 0x00043> }	System.ArgumentException
Comment 4 daniel.luberda 2014-10-16 18:24:01 UTC
Tested on 1.2.3 - it's fixed now.