Skip to content

[Android] Toolbar item icon and text disappears when reopening from recent applications. #24357

@SergTomcat

Description

@SergTomcat

Description

Upon returning to foreground, previously drawn ToolbarItems of NavigationPage disappear. Looking at title shifted to the left, buttons are completely removed from layout.
Debugger shows that all ToolbarItems present in IList of NavigationPage

Similar bug marked as closed, but definetely repros today (#11552)

Steps to Reproduce

  1. Add Navigation Page
  2. Add ToolbarItems in constructor of ContentPage
  3. Use android "back" button to put app into backgound.
  4. Return app to foreground
public partial class MainPage : ContentPage
{
	
	public MainPage()
	{
		InitializeComponent();

		ToolbarItems.Add(new(null, "bug", () => { CounterBtn.Text = $"Bugt button clicked"; }));
		ToolbarItems.Add(new(null, "contacts", () => { CounterBtn.Text = $"Person button clicked"; }));
	}
}

Link to public reproduction project repository

https://github.com/SergTomcat/MAUI8_BugDemo2

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 10-14

Did you find any workaround?

Override OnAppearing method of every page with toolbar, clear items and readd them.

protected override void OnAppearing()
{
	base.OnAppearing();
	
	var tb = ToolbarItems.ToArray();
        ToolbarItems.Clear();
        foreach (var item in tb) 
                ToolbarItems.Add(item);
}

It plugs the hole, but require to be included in everypage, not mentioning additional perfomance overhead.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions