Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NavHost cannot be null on Back key pressed #15102

Closed
luwed opened this issue May 16, 2023 · 8 comments · Fixed by #23170
Closed

NavHost cannot be null on Back key pressed #15102

luwed opened this issue May 16, 2023 · 8 comments · Fixed by #23170
Assignees
Milestone

Comments

@luwed
Copy link

luwed commented May 16, 2023

Description

I noticed InvalidOperationException (NavHost cannot be null) when running app with debugger on Android 12 on Back key pressed.

Steps to Reproduce

  1. Create Maui app
  2. Define MainPage in App.xaml.cs as:
var rootPage = new MainPage();
MainPage = new NavigationPage(rootPage);
  1. Run app with debugger on Android 12
  2. Move app to background using Back key
  3. Return to the app using main launcher (icon)
  4. Press Back key again

Actual result:
InvalidOperationException is thrown:

NavHost cannot be null

   at Microsoft.Maui.Platform.StackNavigationManager.get_NavHost() in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\StackNavigationManager.cs:line 32
   at Microsoft.Maui.Platform.NavigationViewFragment.OnResume() in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\NavigationViewFragment.cs:line 75
   at AndroidX.Fragment.App.Fragment.n_OnResume(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/generated/androidx.fragment.fragment/obj/Release/net6.0-android/generated/src/AndroidX.Fragment.App.Fragment.cs:line 2614
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 22

Expected result:
No exception

Link to public reproduction project repository

https://github.com/luwed/maui-stuff/tree/NavHost-cannot-be-null-on-back

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

No response

Relevant log output

No response

@luwed luwed added the t/bug Something isn't working label May 16, 2023
@PureWeen PureWeen added this to the Backlog milestone May 16, 2023
@PureWeen PureWeen added the area-navigation NavigationPage label May 16, 2023
@ghost
Copy link

ghost commented May 16, 2023

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@PureWeen
Copy link
Member

@luwed this is most likely fixed in .NET8

One way that should workaround this is to override CreateWindow inside your App.xaml.cs file opposed to setting MainPage

	class App : Application
	{
		protected override Window CreateWindow(IActivationState activationState) =>
			new Window(new NavigationPage(new MainPage()));
	}

@luwed
Copy link
Author

luwed commented May 17, 2023

@PureWeen Thank you for your response. Proposed workaround generates another problem: if I press Back key and return to the app using main launcher then there is navigation within the app when Back key is pressed again. It looks like additional Activity or Window is created (please look at steps below):

  1. Run app with debugger on Android 12 -> MainActivity::OnCreate is called
  2. Press Back key -> MainActivity::OnDestroy is not called
  3. Return to the app using main launcher -> MainActivity::OnCreate is called
  4. Press Back key -> MainActivity::OnDestroy is called, we're still in the app
  5. Press Back key again -> There is navigation to Android Home Screen

@Zhanglirong-Winnie Zhanglirong-Winnie added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Jan 12, 2024
@ghost
Copy link

ghost commented Jan 12, 2024

Hi @luwed. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio Enterprise 17.9.0 Preview 2.1. Not repro on Android platforms.

@luwed
Copy link
Author

luwed commented Jan 12, 2024

Checked with Visual Studio Enterprise 2022 for Mac Version 17.6.8 and Microsoft Visual Studio Community 2022 (64-bit) Version 17.8.4. Results (with info about operating system) below.

  • macOS Sonoma
    • Visual Studio Enterprise 2022 for Mac Version 17.6.8 (build 400)/.NET 7.0 - issue can be reproduced
    • Visual Studio Enterprise 2022 for Mac Version 17.6.8 (build 400)/project converted to .NET 8.0 - different issue occurred, stacktrace below

[ViewRootImpl@229e1d[MainActivity]] stopped(true) old=false [mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState [mono-rt] at Java.Interop.JniEnvironment.InstanceMethods.CallIntMethod(JniObjectReference instance, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20203 [mono-rt] at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractInt32Method(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 492 [mono-rt] at AndroidX.Fragment.App.BackStackRecord.Commit() in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.BackStackRecord.cs:line 131 [mono-rt] at Microsoft.Maui.Platform.NavigationRootManager.SetContentView(IView view) in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\NavigationRootManager.cs:line 129 [mono-rt] at Microsoft.Maui.Platform.NavigationRootManager.Disconnect() in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\NavigationRootManager.cs:line 113 [mono-rt] at Microsoft.Maui.Handlers.WindowHandler.DisconnectHandler(NavigationRootManager navigationRootManager) in D:\a\_work\1\s\src\Core\src\Handlers\Window\WindowHandler.Android.cs:line 83 [mono-rt] at Microsoft.Maui.Handlers.WindowHandler.OnDisconnectHandler(Object platformView) in D:\a\_work\1\s\src\Core\src\Handlers\Window\WindowHandler.Android.cs:line 67 [mono-rt] at Microsoft.Maui.Handlers.ElementHandler.DisconnectHandler(Object platformView) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 112 [mono-rt] at Microsoft.Maui.Handlers.ElementHandler.Microsoft.Maui.IElementHandler.DisconnectHandler() in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 130 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 918 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.SetHandler(Context nativeElement, IElement element, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 156 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.SetWindowHandler(Activity platformWindow, IWindow window, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 166 [mono-rt] at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Activity activity, IApplication application, Bundle savedInstanceState) in D:\a\_work\1\s\src\Core\src\Platform\Android\ApplicationExtensions.cs:line 48 [mono-rt] at Microsoft.Maui.MauiAppCompatActivity.OnCreate(Bundle savedInstanceState) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiAppCompatActivity.cs:line 35 [mono-rt] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.App.Activity.cs:line 3082 [mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 125 [mono-rt] --- End of managed Java.Lang.IllegalStateException stack trace --- [mono-rt] java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState [mono-rt] at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1632) [mono-rt] at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1672) [mono-rt] at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341) [mono-rt] at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306) [mono-rt] at crc6488302ad6e9e4df1a.MauiAppCompatActivity.n_onCreate(Native Method) [mono-rt] at crc6488302ad6e9e4df1a.MauiAppCompatActivity.onCreate(MauiAppCompatActivity.java:49) [mono-rt] at android.app.Activity.performCreate(Activity.java:8290) [mono-rt] at android.app.Activity.performCreate(Activity.java:8270) [mono-rt] at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329) [mono-rt] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4085) [mono-rt] at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4277) [mono-rt] at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) [mono-rt] at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) [mono-rt] at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) [mono-rt] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) [mono-rt] at android.os.Handler.dispatchMessage(Handler.java:106) [mono-rt] at android.os.Looper.loopOnce(Looper.java:226) [mono-rt] at android.os.Looper.loop(Looper.java:313) [mono-rt] at android.app.ActivityThread.main(ActivityThread.java:8751) [mono-rt] at java.lang.reflect.Method.invoke(Native Method) [mono-rt] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) [mono-rt] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) [mono-rt] [mono-rt] --- End of managed Java.Lang.IllegalStateException stack trace --- [mono-rt] java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState [mono-rt] at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1632) [mono-rt] at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1672) [mono-rt] at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341) [mono-rt] at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306) [mono-rt] at crc6488302ad6e9e4df1a.MauiAppCompatActivity.n_onCreate(Native Method) [mono-rt] at crc6488302ad6e9e4df1a.MauiAppCompatActivity.onCreate(MauiAppCompatActivity.java:49) [mono-rt] at android.app.Activity.performCreate(Activity.java:8290) [mono-rt] at android.app.Activity.performCreate(Activity.java:8270) [mono-rt] at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329) [mono-rt] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4085) [mono-rt] at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4277) [mono-rt] at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) [mono-rt] at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) [mono-rt] at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) [mono-rt] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) [mono-rt] at android.os.Handler.dispatchMessage(Handler.java:106) [mono-rt] at android.os.Looper.loopOnce(Looper.java:226) [mono-rt] at android.os.Looper.loop(Looper.java:313) [mono-rt] at android.app.ActivityThread.main(ActivityThread.java:8751) [mono-rt] at java.lang.reflect.Method.invoke(Native Method) [mono-rt] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) [mono-rt] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) [mono-rt]

  • Windows 11
    • Microsoft Visual Studio Community 2022 (64-bit) Version 17.8.4/.NET 7.0 - issue can't be reproduced
    • Microsoft Visual Studio Community 2022 (64-bit) Version 17.8.4/project converted to .NET 8.0 - issue can't be reproduced

dotnet workload list

  • macOS Sonoma

wasm-tools 8.0.1/8.0.100 SDK 8.0.100
macos 14.0.8490/8.0.100 SDK 8.0.100
maui-maccatalyst 8.0.3/8.0.100 SDK 8.0.100
maui-ios 8.0.3/8.0.100 SDK 8.0.100
maui-android 8.0.3/8.0.100 SDK 8.0.100
ios 17.0.8490/8.0.100 SDK 8.0.100
maui 8.0.3/8.0.100 SDK 8.0.100
android 34.0.52/8.0.100 SDK 8.0.100

  • Windows 11

maui 8.0.3/8.0.100 SDK 8.0.100
maui-android 8.0.3/8.0.100 SDK 8.0.100
maui-ios 8.0.3/8.0.100 SDK 8.0.100
maui-mobile 8.0.3/8.0.100 SDK 8.0.100
android 34.0.52/8.0.100 VS 17.8.34408.163
maui-windows 8.0.3/8.0.100 VS 17.8.34408.163
maccatalyst 17.0.8490/8.0.100 VS 17.8.34408.163
ios 17.0.8490/8.0.100 VS 17.8.34408.163

@ghost ghost removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jan 12, 2024
@naaeef
Copy link

naaeef commented Feb 27, 2024

We have the same exception also in various cases when doing a release build.

@MDThomsen
Copy link

@PureWeen Hello, I was investigating this since I have been experiencing the same crash when replacing the MainPage just after opening my Android app after having minimized it on the latest Maui version (8.0.40). I was looking through the code and I noticed how this line performs a null check on NavigationManager.NavHost. However the getter of the NavHost will throw the exception in question when it is null. This means the return case will never be relevant in the case where _currentView and NavigationManager.NavHost are both null.

Is this intended?

@PureWeen PureWeen self-assigned this Jun 20, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Jun 20, 2024
PureWeen pushed a commit that referenced this issue Jun 21, 2024
Redth added a commit that referenced this issue Jun 25, 2024
* Size and SizeF should not throw on NaN

* Fix Release Versioning

* Upgrade from 1.5.1 to 1.5.4

* SwipeView Fix #22580 (#22741)

Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>

* Update vscode extension recommendations

* [XC] Fix SimplifyTypeExtensionVisitor (#23043)

* Add test

* Fix the visitor

* Add SR6 to issue template (#23071)

* Make sure the main branch is using .NET 8 SDK (#23077)

* Make sure the main branch is using .NET 8 SDK

The main branch needs to use the .NET 8 SDK because we are building the .NET 7 TFMs as well. The .NET 9 SDK does not support .NET 7 TFMs anymore.

* no previews!

* Setup preview versioning for SR6.1

* Remove compat appium tests

Since we're moving in a different direction for moving these over in #22635 these projects (and the Issue11853 test, since it's in the other PR) can be deleted.

* [main] Update arcade and xharness (#22981)

* Update arcade

* Update dotnet-tools.json

* Update xharness
# Conflicts:
#	.config/dotnet-tools.json
#	eng/Version.Details.xml
#	eng/Versions.props

* Remove more references to removed projects

* Make titlebar button foreground colors use app theme

* Update dependencies from https://github.com/dotnet/xharness build 20240612.3 (#23088)

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 9.0.0-prerelease.24311.2 -> To Version 9.0.0-prerelease.24312.3

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Add additional logging for PopLifeCycle

* Remove more legacy pipeline bits

* [iOS] Fixed NRE after calling ViewCell.ForceUpdateSize (#23094)

* [iOS] Fixed NRE after calling ViewCell.ForceUpdateSize

* - add test

---------

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>

* Add x:DataType to the carousel view UI tests (#23113)

* Bump to Android 34.0.113

Context: https://github.com/dotnet/android/releases/34.0.113
Changes: dotnet/android@34.0.79...34.0.113

I noticed the Android workload version used in dotnet/maui/main was a couple service releases old.

We should use the latest one, as it has a memory leak fix for `Post()`.

* Squashed commit of the following: (#22874)

commit db8a3bd
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Mon Jun 10 13:46:16 2024 +0800

    Add android

commit 0bd2d65
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Mon Jun 10 12:16:34 2024 +0800

    oops!

commit 647e5f5
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 18:15:40 2024 +0800

    Almost

commit c3ea650
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 16:17:58 2024 +0800

    sadfasdf

commit d9a398f
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 13:56:34 2024 +0800

    screenshots

commit 4b3c01f
Merge: 595ff03 e94b364
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 13:54:52 2024 +0800

    Merge branch 'main' into dev/gif-in-release

commit 595ff03
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Thu Jun 6 21:00:52 2024 +0800

    Update ImageUITests.cs

commit 2c20fe0
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Thu Jun 6 19:05:23 2024 +0800

    Make some tests

commit 1e82e8b
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Thu Jun 6 18:44:18 2024 +0800

    Take 2?

commit d576c82
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Thu Jun 6 07:11:17 2024 +0800

    Fix animated gifs in Release builds

* Fix loaded so it fires on second subscription (#23095)

* Fix loaded so it fires on second subscription

* Update VisualElement.cs

* Make sure the view is still alive after posting (#23114)

I saw in some of my local testing the shape view may
actually be disposed if you write code or when you
run the device tests.

When we come back after the UI loop, make sure the
platform view is still alive.

This should not happen if the view is attached to the
UI since it is still being used, but if you happen to
navigate or close some popup it may occur.

* [iOS] TapGestureRecognizer should not fire when view is not enabled (#23049)

* Don't receive touch when view is disabled

* Add UITest for Single Tap enabled/disabled

This removes the first pass unit test version which isn't really testing the scenario properly.

* Fix element automation id

* Don't fire tap for windows if control disabled

* Make failure case text less confusing

* [Tests] Update to Appium 5.0.0 (#23118)

* Update to appium 5.0.0

Their driver has some removed methods (LaunchApp/CloseApp) which seem to be now implemented for windows.

Also removed an extra explicit ref to system.drawing.common since it comes in transitively from appium.webdriver package (and the version was causing issues since the newer appium.webdriver uses a newer version).

* Fix windows launchapp/closeapp for newer appium

In Appium's dotnet driver in v5.0.0 they removed `LaunchApp` from the driver: appium/dotnet-client#766

The deprecation suggests using `ActivateApp` as an alternative, but that throws an error saying it's not implemented on the windows driver.

Curiously, `CloseApp` which was also marked as deprecated was _moved_ from the base appium driver to the `WindowsDriver` here: appium/dotnet-client#773

I think the same treatment should have been done to the `LaunchApp` method since there's no alternative in windows.

For now the workaround is to invoke the command manually:
`windowsDriver.ExecuteScript("windows: launchApp", [_app.GetAppId()]);`

* Use correct interface type in FrameRenderer (#23124)

* Use correct interface type in FrameRenderer (#23124) (#23146)

* Squashed commit of the following: (#19629)

commit f6c3bfa
Merge: d0b3f84 3143629
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Mon Jun 17 19:58:40 2024 +0800

    Merge remote-tracking branch 'origin/main' into dev/macos-actionsheet

commit d0b3f84
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Tue Jun 11 05:00:38 2024 +0800

    Fix the older macOS testing

commit 3dc6b4d
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Mon Jun 10 23:40:40 2024 +0800

    macOS 13 things

commit e3e48e4
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 02:15:55 2024 +0800

    docs

commit 693d79c
Merge: 3dbce49 a3c872d
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 02:08:31 2024 +0800

    Merge remote-tracking branch 'origin/main' into dev/macos-actionsheet

commit 3dbce49
Merge: 17ea9c6 93a1bc4
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 02:06:16 2024 +0800

    Merge remote-tracking branch 'origin/main' into dev/macos-actionsheet

commit 17ea9c6
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Jun 8 02:05:42 2024 +0800

    Fix the tests

commit 026da41
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Fri Jun 7 03:56:26 2024 +0800

    fixes

commit d2b85d5
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Thu Jun 6 23:58:33 2024 +0800

    namespaces

commit 9fa77cd
Merge: 3f9596b 9d71d32
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Thu Jun 6 23:57:00 2024 +0800

    Merge branch 'main' into dev/macos-actionsheet

    # Conflicts:
    #	src/Controls/samples/Controls.Sample.UITests/Test.cs
    #	src/Controls/src/Core/Platform/AlertManager/AlertManager.iOS.cs
    #	src/Controls/tests/TestCases.Shared.Tests/Tests/Concepts/AlertsGalleryTests.cs
    #	src/Controls/tests/TestCases/Concepts/AlertsGalleryPage.cs
    #	src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs
    #	src/TestUtils/src/UITest.Appium/HelperExtensions.cs

commit 3f9596b
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Sat Dec 30 09:29:31 2023 +0200

    Add some UI tests

    Done: iOS/macOS/Android. TODO: Windows

commit 68c930f
Author: Matthew Leibowitz <mattleibow@live.com>
Date:   Tue Dec 19 18:15:51 2023 +0200

    macOS does not use PopoverPresentationController

    Fixes #18156

* [ios/catalyst] fix more cycles in `NavigationPage`

Fixes: #21453
Context: #22810

In #22810, a leak in `NavigationPage` was fixed for the case:

    Application.Current.MainPage = new NavigationPage(new Page1());
    Application.Current.MainPage = new Page2();

However, it does *not* work for the case:

    await Navigation.PushModalAsync(new NavigationPage(new Page1()));
    await Navigation.PopModalAsync();

I could reproduce this problem in `MemoryTests.cs`.

There were still a few cycles in `NavigationRenderer`:

* `NavigationRenderer` -> `VisualElement _element` -> `NavigationRenderer`

* `NavigationRenderer` -> `Page Current` -> `NavigationRenderer`

* `NavigationRenderer` -> `ViewHandlerDelegator<NavigationPage> _viewHandlerWrapper` ->  `TElement _element` -> `NavigationRenderer`

After fixing these cycles, the test passes.

`ViewHandlerDelegator` was slightly tricky, as I had to make a
`_tempElement` variable and *unset* it immediately after use.

* Only change ViewHandlerDelegator for iOS/Catalyst

* [ios] fix leak in ListView *Cells (#23143)

* [ios] fix leak in ListView *Cells

Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2064274

After fixing #22867 for `CollectionView`, there was still a problem with
`ListView`. The following types were leaking in the sample app:

* `UIKit.UITableView`
* `Microsoft.Maui.Controls.Handlers.Compatibility.ViewCellRenderer.ViewTableCell`
* `Microsoft.Maui.Platform.MauiLabel`
* `Microsoft.Maui.Platform.MauiImageView`
* `Microsoft.Maui.Platform.WrapperView`

After a lot of debugging, we found that `Cell` was holding a reference
to the `UITableView`. This pointed *up* in the hierarchy, creating
a cycle.

I updated an existing device test to ensure the problem is solved.

* Fix missing handlers in tests

* Remove assertion

* Fix UITableView reference

* Update a different test

* Can't enumerate while adding

* Missed a null check

* [Housekeeping] Added UI Test to validate project template (#18567)

* Added template UI Test

* Added pending snapshot

* Updated snapshot

* Generate snapshots for all the platforms

* Added pending snapshots

* Updated snapshot

* More changes

* Updated droid snapshot

* More changes

* Updated snapshots

* Added sample path

* Update Issue19509.cs

* Update Issue19509.cs

---------

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>

* Optimize resetting gesture recognizers (#19987)

* reduce LINQ usage

* Remove useless check that will always be false

* use HashSet

* reduce enumerations and casting

* reduce LINQ usage

* only cast once

* add benchmarks

* fix build

---------

Co-authored-by: Edward Miller <symbiogenisis@outlook.com>

* [Windows] Fix ListView insert not working properly (#22746)

* Add test

* Remove force layout update during collection changed event

* Adjust await

* Update ListViewTests.Windows.cs

---------

Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>

* Fix <ApplicationTitle> encoding in maui templates (#22084)

* Makes <ApplicationTitle> use a custom symbol instead of the default name parameter to ensure the name is XML encoded where necessaru
* Adds new tests for various encodings and special characters
---------

Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com>

* Fixed a null check #15102 (#23170)

* [ios/catalyst] fix memory leak in TabbedPage (#23166)

* [ios/catalyst] fix memory leak in TabbedPage

Context: #23164

Just the same way as `NavigationPage` in #23164, `TabbedPage` also has
a memory leak caused by the cycle:

* `TabbedPage` -> `TabbedRenderer` -> `VisualElement _element;` -> `TabbedPage

I could add a new `[Theory]` in `MemoryTests.cs` to see the issue.

This PR fixes the memory leak by breaking the cycle in `TabbedRenderer`.

* Ignore test on Windows

I also cleaned up the Task.Delay()

* [iOS] Set PlatformGraphicsView to transparent input (#23208)

* Avoid JavaCast and exceptions and ask Java (#23215)

* Wire RefreshView up to our xplat layout workflow (#23169)

* Use better layout/measure path with refreshview

* - fix naming

* - set RefreshView content to maui compatible container

* - add test

* - fix null operator

* Update Issue23029.xaml.cs

* - fix content panel so it removes previous content

* - add additional check

* Fix Merge

---------

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>
Co-authored-by: redth <jondick@gmail.com>
Co-authored-by: Šimon Rozsíval <simon@rozsival.com>
Co-authored-by: Rui Marinho <me@ruimarinho.net>
Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Vitaly Knyazev <VitalyKnyazev@users.noreply.github.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: Jonathan Dick <jodick@microsoft.com>
Co-authored-by: Edward Miller <symbiogenesis@outlook.com>
Co-authored-by: Edward Miller <symbiogenisis@outlook.com>
Co-authored-by: Mike Corsaro <corsarom@gmail.com>
Co-authored-by: Michael Yanni <MiYanni@microsoft.com>
Co-authored-by: Eilon Lipton <Eilon@users.noreply.github.com>
Co-authored-by: Tim Miller <drasticactions@users.noreply.github.com>
@PureWeen PureWeen modified the milestones: Backlog, .NET 8 SR7 Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants