uno icon indicating copy to clipboard operation
uno copied to clipboard

[IOS] Commandbar title disappears when garbage collector is triggered.

Open Marc-Antoine-Soucy opened this issue 2 years ago • 7 comments

Current behavior

When the commandbar has it's title linked to a templatebinding and you navigate to another page, trigger the garbage collector, and then go back, the title is gone.

gbcollector

Expected behavior

The title should not disappear.

How to reproduce it (as minimally and precisely as possible)

Open the app, navigate to the next page, click on the garbage collector button Navigate back Notice Title disappeared CommandBarOffset (1).zip

Workaround

Works on UWP/WinUI

Yes (the bug is not present in UWP)

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia, Uno.UI.RemoteControl / Uno.WinUI.RemoteControl

NuGet package version(s)

image

Affected platforms

IOS

IDE

Visual Studio 2022

IDE version

Version 17.2.5

Relevant plugins

none

Anything else we need to know?

I made this sample from another sample that only had android/ios/uwp. I will try to put all the platforms in my samples in the future.

Marc-Antoine-Soucy avatar Jul 13 '22 18:07 Marc-Antoine-Soucy

I have a feeling that this may be happening because of the Content being set to a FrameworkElement instead of just a string. If you were to TemplateBind the CommandBarTitle directly to the CommandBar.Content property does the issue still occur?

We have to basically force the custom view for the title to have its parent be the CommandBar instead of the native view. I'm thinking that we're not maintaining that relationship somewhere so the binding breaks

https://github.com/unoplatform/uno/blob/d4689ec1356d2cab7cb770fb1cb3d5e789fe9d16/src/Uno.UI/Controls/CommandBar/CommandBarNavigationItemRenderer.iOS.cs#L131-L135

kazo0 avatar Jul 20 '22 20:07 kazo0

@kazo0 So, I tried it and the title does indeed stop disappearing. Only thing I'm not 100% about is how to change the style of the title. Is there some style I can override to change it?

Marc-Antoine-Soucy avatar Jul 21 '22 14:07 Marc-Antoine-Soucy

@Marc-Antoine-Soucy no :) you're pretty much stuck with the native iOS look of the title.

"When Content is a string, it's displayed using the platform's default font family, font size, font style and text alignment. Only the foreground color can be changed, using Foreground" https://platform.uno/docs/articles/controls/CommandBar.html#content

I am looking into the issue, hopefully we can get the custom Content working properly again soon

kazo0 avatar Jul 21 '22 14:07 kazo0

Alright, thanks

Marc-Antoine-Soucy avatar Jul 21 '22 15:07 Marc-Antoine-Soucy

I have a bad feeling it has to do with the fix from here: https://github.com/unoplatform/uno/issues/7012

kazo0 avatar Jul 25 '22 19:07 kazo0

Maybe not, it seems that the view is still actually present in the CommandBar, it's just empty since the TemplateBinding looks to be broken. If we use just a regular Binding to some string in the PageLayout's DataContext, it will still be there after GC.

I'll have to keep digging to see why the TemplateBinding isn't working

kazo0 avatar Jul 25 '22 21:07 kazo0

We may need to force an strong reference to some views and not rely on the CommandBar proxy's storage.

jeromelaban avatar Aug 01 '22 19:08 jeromelaban

@Marc-Antoine-Soucy

I am no longer able to reproduce this in your sample app, nor in the one I created here: GcCommandBar.zip

Maybe this doesn't occur in later version of iOS? Can you confirm on your end that this is no longer an issue?

kazo0 avatar Dec 07 '22 02:12 kazo0

@kazo0 I tried it on 16.x versions of IOS and it was fixed, so It does seem to be fixed on later versions of IOS. But, it still happens on IOS 14.3 simulator.

Marc-Antoine-Soucy avatar Dec 07 '22 14:12 Marc-Antoine-Soucy

@Marc-Antoine-Soucy

Ah interesting, is this still a high priority or is your client not going to be targeting the affected versions of iOS?

kazo0 avatar Dec 07 '22 14:12 kazo0

@takla21 mentioned that this issue is of high priority for an upcoming scenario.

jeromelaban avatar Jul 20 '23 15:07 jeromelaban

@takla21 This is still happening on latest iOS versions or is it a blocker for iOS 14 and below?

kazo0 avatar Jul 21 '23 16:07 kazo0

@kazo0 So I went ahead and updated the sample to latest and test whether it was still happening and it seems to happen on ios 14 & 15. However, on IOS 16 it seems fixed (iPhone SE iOS 16.5)

ios15ios14

Here's the updated sample CommandBarSample.zip

takla21 avatar Jul 26 '23 21:07 takla21

Curious if the same occurs with NavigationBar from Toolkit, I would imagine so

kazo0 avatar Aug 03 '23 19:08 kazo0