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

DisplayAlert crashes an app if executed in a page constructor #4336

Closed
alexeystrakh opened this issue Jan 26, 2022 · 2 comments
Closed

DisplayAlert crashes an app if executed in a page constructor #4336

alexeystrakh opened this issue Jan 26, 2022 · 2 comments
Labels
area-controls-dialogalert DisplayAlert, dialog platform/windows 🪟 t/bug Something isn't working

Comments

@alexeystrakh
Copy link

Description

DisplayAlert crashes an app if executed in a page constructor

public partial class MainPage: ContentPage
{
        public MainPage()
        {
            InitializeComponent();
            DisplayAlert("Hello", "There", "OK");
        }
}

Steps to Reproduce

  1. Create a new MAUI app
  2. Add DisplayAlert call to the MainPage constructor
  3. Start the app and observe the app to crash on startup

Version with bug

Preview 12 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

windows10.0.19041

Did you find any workaround?

Yes, if you execute the same method with a delay, it works just fine

public partial class MainPage: ContentPage
{
        public MainPage()
        {
            InitializeComponent();
            RenderDialog();
        }

        private async Task RenderDialog()
        {
            await Task.Delay(5000);
            await DisplayAlert("Hello", "There", "OK");
        }
}

Relevant log output

Faulting application name: xxx.exe, version: 1.0.0.0, time stamp: 0x61954b73
Faulting module name: KERNELBASE.dll, version: 10.0.19041.1466, time stamp: 0xe01c7650
Exception code: 0xc000027b
Fault offset: 0x000000000010b362
Faulting process id: 0x6390
Faulting application start time: 0x01d812fb09610291
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: cc7145cf-2475-4e26-bdf6-e57bb709e481
Faulting package full name: 0A8834C6-F23D-4CEB-86B5-B57FD5D15D23_1.0.0.0_neutral__9zz4h110yvjzm
Faulting package-relative application ID: App
@alexeystrakh alexeystrakh added the t/bug Something isn't working label Jan 26, 2022
@alexeystrakh alexeystrakh changed the title DisplayAlert crashes an app if executed in a page contructor DisplayAlert crashes an app if executed in a page constructor Jan 26, 2022
@jamesmontemagno
Copy link
Member

Any reason you don't put it in the OnAppearing? This seems like a bad user experience as you can create a page at any time and it may not be visible at all.

I actually don't think this should be supported IMHO.

@Eilon Eilon added legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area-controls-dialogalert DisplayAlert, dialog labels Feb 11, 2022
@Eilon
Copy link
Member

Eilon commented Feb 11, 2022

Dup of #1514

@Eilon Eilon closed this as completed Feb 11, 2022
@kristinx0211 kristinx0211 added s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/verified Verified / Reproducible Issue ready for Engineering Triage labels Mar 2, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 1, 2022
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-dialogalert DisplayAlert, dialog platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants