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

[BUG] Popup crashes the app on iOS #1924

Closed
2 tasks done
erossini opened this issue Jun 11, 2024 · 3 comments
Closed
2 tasks done

[BUG] Popup crashes the app on iOS #1924

erossini opened this issue Jun 11, 2024 · 3 comments
Labels
bug Something isn't working needs reproduction stale The author has not responded in over 30 days unverified

Comments

@erossini
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

In my .NET8 MAUI application, I use the MAUI CommunityToolkit version 9.0.1. I have an issue with the Popup that crashes my app. I saw a bug on GitHub that is exactly my issue but there is no answer for it.

I defined my Popup view

<?xml version="1.0" encoding="utf-8" ?>
<toolkit:Popup
		x:Class="LanguageInUse.Views.Popups.LoadingPopup"
		xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
		xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
		xmlns:lang="clr-namespace:LanguageInUse"
		xmlns:popups="clr-namespace:LanguageInUse.Views.Popups"
		xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">

	<toolkit:Popup.Resources>
		<Style TargetType="{x:Type popups:LoadingPopup}">
			<Setter Property="Size" Value="300,300" />
			<Setter Property="Color" Value="White" />
			<Setter Property="HorizontalOptions" Value="Center" />
			<Setter Property="VerticalOptions" Value="Center" />
			<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="False" />
		</Style>
	</toolkit:Popup.Resources>

	<StackLayout
			Margin="30"
			HorizontalOptions="CenterAndExpand"
			VerticalOptions="CenterAndExpand"
			WidthRequest="350">
		<VerticalStackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
			<ActivityIndicator
					HorizontalOptions="Center"
					IsRunning="True"
					Color="{StaticResource Gray900}" />
			<Label
					x:Name="labelLoading"
					MaximumWidthRequest="240"
					Style="{StaticResource labelLoading}"
					Text="{lang:Translate Loading}"
					WidthRequest="240" />
		</VerticalStackLayout>
	</StackLayout>
</toolkit:Popup>

When my app is in Release mode and it displays the popup on iOS, I get this error

CommunityToolkit.Maui.Core.Views.MauiPopup.SetShadowView(UIView&
target)
CommunityToolkit.Maui.Core.Views.MauiPopup.ViewDidLayoutSubviews()
ObjCRuntime.Runtime.ThrowException(IntPtr )
UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr ,
IntPtr ) UIKit.UIApplication.Main(String[] , Type , Type )
LanguageInUse.Program.Main(String[] args)

To display the Popup, I use this line

var loadingPopup = new LoadingPopup();
loadingPopup.SetMessage(AppResources.DictionaryWordsLoading);
loadingPopup.Opened += async (s, e) =>
{
    try
    {
        // my code
    }
    catch (Exception ex)
    {
    }
    finally
    {
        if (loadingPopup != null)
            await loadingPopup.CloseAsync();
    }
};
await Application.Current.MainPage.ShowPopupAsync(loadingPopup);
loadingPopup = null;

This code is in the ViewModel.

How can I fix it?

Expected Behavior

The popup doesn't crash the application.

Steps To Reproduce

  1. In your project you have a Page and this page opens another page with
await Shell.Current.GoToAsync($"{nameof(WordEdit)}?DictionaryID={DictionaryID}", true);
  1. When I go back, the ViewModel of the first page runs an activity with the code I posted in the Current Behavior.
  2. The page is not fully displayed yet
  3. The Popup raises the error related to SetShadowView
  4. The app crashes

Link to public reproduction project repository

I don't have one

Environment

- .NET MAUI CommunityToolkit: 9.0.1
- OS: iOS 17
- .NET MAUI: 8

Anything else?

No response

@erossini erossini added bug Something isn't working unverified labels Jun 11, 2024
@acaliaro
Copy link

@erossini do you have a repo with the problem?

I tried the latest version of the community toolkit which was supposed to fix the problem, but the problem persists. In my case it is due to a DisplayAlert displayed when a Popup is already visible. Removed DisplayAlert, crash does not appear

Maybe something like #1168 ?

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 2 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@dotnet-policy-service dotnet-policy-service bot added the stale The author has not responded in over 30 days label Jun 17, 2024
Copy link
Contributor

We haven't received a reproduction sample from you. The issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs reproduction stale The author has not responded in over 30 days unverified
Projects
None yet
Development

No branches or pull requests

3 participants