dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.15k stars 1.74k forks source link

ios Shell #22452

Open Gekidoku opened 5 months ago

Gekidoku commented 5 months ago

Description

Im having a small issue with my Shell. This used to work the way i have it right now. but since i installed .net 8.0.5 on my mac and the latest workload it stopped working. In my function I set the mainpage like so

App.AppShell = new AppShellPlanning() { BackgroundColor = Colors.Black };
MainThread.BeginInvokeOnMainThread(async () =>
{
    await Task.Delay(100);
    App.Current.MainPage = App.AppShell;
});

The delay is there for an earlier issue, if didnt stick it in there it would crash sometimes back in ios 16.something.

Now when it executes with XCode 15.2 on an iphone simulator for 17.0 it gets to the last line and then logs this in the console

[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_UIMoreListTableView: 0x118af7e00; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600000cc3cc0>; backgroundColor = <UIDynamicSystemColor: 0x6000017cad00; name = tableBackgroundColor>; layer = <CALayer: 0x600000bc09e0>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <UIMoreListController: 0x1077b4600>>

What is odd is that my shell only has this in it at the moment (stripped everything away to see what was causing it)

 public AppShellPlanning()
 {
     InitializeComponent();       
     Shell.SetTabBarIsVisible(this, false);
     var SplashPage = new FlyoutItem()
     {
         Title = "Dashboard",
         Icon = ImageSource.FromFile("Db.png"),

     };
     SplashPage.Items.Add(new ShellContent()
     {
         Route = "SplashPage",
         ContentTemplate = new DataTemplate(typeof(SplashPage)),

     });

     this.Items.Add(SplashPage);
}

If I change my mainpage code to just set a navigation page of Splashpage then it does work, but I need the shell navigation.

//This works but is not a solution
 MainThread.BeginInvokeOnMainThread(async () =>
 {
     await Task.Delay(100);
     App.Current.MainPage = new NavigationPage(new SplashPage()) { Style = Application.Current.Resources["MyNavPage"] as Style, };
 });

Using visual studio code on mac

Steps to Reproduce

No response

Link to public reproduction project repository

should throw the error on app launch

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 5 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Gekidoku commented 5 months ago

Attempted to build for ios 17.2 same result. also the same when i build for ios 17.4.

on android this works

RoiChen001 commented 5 months ago

Can repro this issue at iOS platform on the latest 17.10 Preview 7(8.0.20&8.0.21).

Gekidoku commented 4 months ago

What is the status for this issue? Cant build on ios now and we have updates that are in our android app that our ios users also would like to have.

Gekidoku commented 4 months ago

Update on my part, now using .net SDK 8.0.302 Maui SDK 8.0.300 XCode 17.4

Same issue still

PureWeen commented 2 months ago

@Gekidoku I'm not clear on your exact blocker here

This warning

[TableView] Warning once only: UITableView was told to layout its visible cells and other

Isn't a blocker and shouldn't break your app

Gekidoku commented 2 months ago

I dont really have more info. Since the app stops with that being the last message in the console. Going by earlier messages i see roi was able to repro it with my repro project.

The repro project worked in earlier versions of .net 8 as far as I see i made no big changes to it.

As its the weekend now and my code is at work i can't provide more info at this time. Monday I'll try another build and see if I can find more in the console.

Gekidoku commented 2 months ago

Ok i have two screen recordings One is of the app in the repro other is of my actual app. Unfocus App Here i now see that the app launches and creates the flyout menu. however it freezes as soon as i select an item. Only thing i changed is i added

UIBackgroundModes fetch remote-notification

to the info .plist

Here is the video of my actual app. here To reiterate, this app works on android. exactly the same. only difference is that i use VerticalStackLayouts on iOS and Android uses CollectionViews. because collectionviews were showing strange behavior on ios. I cross tested this by using VerticalStackLayout on android as well but this worked just fine. Also in previous versions of .net Maui this worked..

as you can see the last thing i see in the debug console is 2024-08-12 13:43:47.992633+0200 UnfocusTest[72938:42431714] [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window. Table view: <_UIMoreListTableView: 0x10e593e00; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600000c6cc60>; backgroundColor = <UIDynamicSystemColor: 0x600001753b40; name = tableBackgroundColor>; layer = <CALayer: 0x60000065f200>; contentOffset: {0, 0}; contentSize: {0, 0}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <UIMoreListController: 0x10cf2a8c0>> 2024-08-12 13:43:48.002617+0200 UnfocusTest[72938:42431714] Simulator user has requested new graphics quality: 100

Gekidoku commented 2 months ago

Note that if i change my project file in my unfocus app to be net7.0-ios; then it does work.

However for my actual app this isnt a solution. Since that would mean maining a .net8 version and a .net7 version.

and some libraries i use only have a .net8 version.

Gekidoku commented 2 weeks ago

Seeing as the bot set this as done last month. Is a workload version available with this fix in it?

Gekidoku commented 1 week ago

@samhouts Im still getting a freeze when setting an app shell. even if only has 1 dummy page as a child.

On my dummy app it does load the shell. but then as soon as you select an item it freezes. https://github.com/Gekidoku/UnfocusTest <-- dummy app If you run it on .net9 and press the switchmain button to switch to a shell page. and then select an item in the menu the whole app freezes. except for the setmainpage option which is a button that just changes the mainpage. https://github.com/Gekidoku/UnfocusTest

Gekidoku commented 6 days ago

Included is a screen recording from vscode using .net9 (it has the same issue as .net8) In this example i switched to the new method of setting mainwindow. with overriding createwindow and setting application.current.window[0].page to switch it.

https://github.com/user-attachments/assets/946c0fff-f9de-42ab-bff7-b51feaa414ab

Gekidoku commented 6 days ago

Another comment yet again. This time I took my actual app. but ripped out the entire contents of the AppShell i normally use and just put in a Dummy page that has a label with text as the first FlyoutItem.

Cant really share the entire app since it contains company data. Also you'll see library security warnings. these are fixed by now and didnt make a difference.

https://github.com/user-attachments/assets/13fed67d-3dcd-489f-8bcd-9186944ef974

Gekidoku commented 6 days ago

Having alot of fun here.. updated visual studio on my windows machine to 17.12.0 Preview 3. and now my android app gets stuck in a GC loop..... Maybe this is also happening on the ios build but its just not send to the terminal.