Skip to content

[iOS] Crash upon resuming the app - fix#23360

Merged
PureWeen merged 8 commits into
dotnet:mainfrom
kubaflo:fix-21948
Jul 5, 2024
Merged

[iOS] Crash upon resuming the app - fix#23360
PureWeen merged 8 commits into
dotnet:mainfrom
kubaflo:fix-21948

Conversation

@kubaflo
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo commented Jun 29, 2024

Issues Fixed

Fixes #21948

Before After
Screen.Recording.2024-06-29.at.13.15.13.mov
Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-06-29.at.13.11.30.mp4

@kubaflo kubaflo requested a review from a team as a code owner June 29, 2024 13:43
@kubaflo kubaflo requested review from Eilon and mattleibow June 29, 2024 13:43
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Jun 29, 2024
@kubaflo kubaflo added area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events platform/ios partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Jun 29, 2024
@kubaflo kubaflo changed the title [iOS] Crash upon resuming the app - fix (#21948) [iOS] Crash upon resuming the app - fix Jun 29, 2024
@kubaflo kubaflo requested a review from PureWeen June 29, 2024 15:02
@kubaflo kubaflo force-pushed the fix-21948 branch 2 times, most recently from 741bb9c to 7533fd5 Compare June 29, 2024 15:40

if (OperatingSystem.IsIOSVersionAtLeast(15))
{
foreach(var windowScene in application.ConnectedScenes)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we can just reduce all this code down to just this foreach statement for APIs > 13+

public static IWindow? GetWindow(this UIApplication application)
        {
            // If there's only one window to return then just return that window
			var windows = IPlatformApplication.Current?.Application?.Windows ?? Array.Empty<IWindow>();

			if (windows.Count == 1)
				return windows[0];

			if (OperatingSystem.IsIOSVersionAtLeast(13))
			{
				foreach(var windowScene in application.ConnectedScenes)
				{
					if (windowScene is UIWindowScene uiWindowScene)
					{
						if(uiWindowScene.Windows.Length == 1 && uiWindowScene.Windows[0].GetWindow() is IWindow window)
						{
							return window;
						}
					}
				}
			}
			else
			{
				if(application.Windows.Length == 1)
					return application.Windows[0].GetWindow();
			}

            return application.GetKeyWindow().GetWindow();
        }
        

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 2, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

kubaflo added a commit to kubaflo/maui that referenced this pull request Jul 3, 2024
@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 3, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

this.AddLogicalChild(page);
var handler = page.ToHandler(this.Handler.MauiContext);

uIWindow.RootViewController = new UIViewController();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to if/def this code for iOS

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 4, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 4, 2024

/azp run

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 4, 2024

/rebase

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 4, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen enabled auto-merge (squash) July 4, 2024 22:40

[Test]
[Category(UITestCategories.Window)]
public void OpenAlertWithModals()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing on catalyst. Is this test and scenario relevant on catalyst?

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 5, 2024

/rebase

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 5, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 5, 2024

/rebase

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 5, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 5, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen disabled auto-merge July 5, 2024 23:20
@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jul 5, 2024

Failing tests unrelated

@PureWeen PureWeen merged commit 8d9a1a5 into dotnet:main Jul 5, 2024
@samhouts samhouts added fixed-in-8.0.70 fixed-in-net9.0-nightly This may be available in a nightly release! labels Aug 2, 2024
@samhouts samhouts added fixed-in-9.0.0-preview.7.24407.4 and removed fixed-in-net9.0-nightly This may be available in a nightly release! labels Aug 27, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events community ✨ Community Contribution fixed-in-8.0.70 fixed-in-9.0.0-preview.7.24407.4 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash upon resuming the app 'window was already activated'

3 participants