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

Setting IsBusy causes exception/crash #9658

Closed
ryanaw83 opened this issue Aug 25, 2022 · 5 comments · Fixed by #9783
Closed

Setting IsBusy causes exception/crash #9658

ryanaw83 opened this issue Aug 25, 2022 · 5 comments · Fixed by #9783
Assignees
Labels
area-controls-dialogalert DisplayAlert, dialog fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! high It doesn't work at all, crashes or has a big impact. platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Milestone

Comments

@ryanaw83
Copy link

ryanaw83 commented Aug 25, 2022

Description

When setting IsBusy in OnAppearing event of a ContentPage it either throws an exception or crashes (on Android). In my main project, it crashes the application. When reproducing in a new MAUI app, it throws an exception having these details...

{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: MauiContext should have been set on parent. at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view) in D:\a_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 110 at Microsoft.Maui.Controls.Platform.AlertManager.AlertRequestHelper.PageIsInThisContext(IView page) in D:\a_work\1\s\src\Controls\src\Core\Platform\AlertManager\AlertManager.Android.cs:line 316 at Microsoft.Maui.Controls.Platform.AlertManager.AlertRequestHelper.OnPageBusy(IView sender, Boolean enabled) in D:\a_work\1\s\src\Controls\src\Core\Platform\AlertManager\AlertManager.Android.cs:line 92 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) --- End of inner exception stack trace --- at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Microsoft.Maui.Controls.MessagingCenter.Subscription.InvokeCallback(Object sender, Object args) in D:\a_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 96 at Microsoft.Maui.Controls.MessagingCenter.InnerSend(String message, Type senderType, Type argType, Object sender, Object args) in D:\a_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 225 at Microsoft.Maui.Controls.MessagingCenter.Microsoft.Maui.Controls.IMessagingCenter.Send[Page,Boolean](Page sender, String message, Boolean args) in D:\a_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 118 at Microsoft.Maui.Controls.MessagingCenter.Send[Page,Boolean](Page sender, String message, Boolean args) in D:\a_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 111 at Microsoft.Maui.Controls.Page.OnPageBusyChanged() in D:\a_work\1\s\src\Controls\src\Core\Page.cs:line 563 at Microsoft.Maui.Controls.Page.<>c.<.cctor>b__129_0(BindableObject bo, Object o, Object n) in D:\a_work\1\s\src\Controls\src\Core\Page.cs:line 36 at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 532 at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 466 at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 388 at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 362 at Microsoft.Maui.Controls.Page.set_IsBusy(Boolean value) in D:\a_work\1\s\src\Controls\src\Core\Page.cs:line 101 at MauiTestApp.MainPage.OnAppearing() in C:\Users\RyanWillis\source\repos\MauiTestApp\MauiTestApp\MainPage.xaml.cs:line 28 at Microsoft.Maui.Controls.Page.SendAppearing() in D:\a_work\1\s\src\Controls\src\Core\Page.cs:line 487 at Microsoft.Maui.Controls.ShellContent.SendPageAppearing(Page page) in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 150 at Microsoft.Maui.Controls.ShellContent.SendAppearing() in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 131 at Microsoft.Maui.Controls.ShellSection.PresentedPageAppearing() in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellSection.cs:line 958 at Microsoft.Maui.Controls.ShellSection.SendAppearing() in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellSection.cs:line 1060 at Microsoft.Maui.Controls.ShellItem.SendAppearing() in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellItem.cs:line 328 at Microsoft.Maui.Controls.ShellNavigationManager.<>c__DisplayClass16_0.g__WaitForWindowToSet|1(Object sender, EventArgs e) in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellNavigationManager.cs:line 242 at Microsoft.Maui.Controls.Element.OnChildAdded(Element child) in D:\a_work\1\s\src\Controls\src\Core\Element.cs:line 357 at Microsoft.Maui.Controls.ShellContent.OnChildAdded(Element child) in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 156 at Microsoft.Maui.Controls.ShellContent.set_ContentCache(Page value) in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 196 at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent() in D:\a_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 81 at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellSectionRenderer.cs:line 123 at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) in C:\a_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:line 1999 at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 352}

Steps to Reproduce

  1. Create new MAUI app
  2. Add the code below and run it
protected override void OnAppearing()
	{
		base.OnAppearing();

		IsBusy = true;
	}

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 10+

Did you find any workaround?

None, it happens every time (on Android), but I was not able to test it on iOS.

Relevant log output

No response

@ryanaw83 ryanaw83 added the t/bug Something isn't working label Aug 25, 2022
@jsuarezruiz jsuarezruiz added platform/android 🤖 high It doesn't work at all, crashes or has a big impact. area-controls-dialogalert DisplayAlert, dialog labels Aug 29, 2022
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Aug 29, 2022
@jsuarezruiz
Copy link
Contributor

Could you attach a small sample where reproduce the issue?. Thanks in advance.

@jsuarezruiz jsuarezruiz added the s/needs-info Issue needs more info from the author label Aug 29, 2022
@ghost
Copy link

ghost commented Aug 29, 2022

Hi @ryanaw83. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. 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.

@ryanaw83
Copy link
Author

ryanaw83 commented Aug 29, 2022

MauiTestApp.zip

Running this bare-bones MAUI app throws an exception at "IsBusy = true;"

I am using the very latest version of MAUI (pulled directly from Github).

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Aug 29, 2022
@SunshineSpring666
Copy link

For MAUI Android, same Exception encountered here. It happens everytime the app runs.

Simply set IsBusy = true;
then run the app and "System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation." is raised.
Note: The environment is latest VS Preview + latest MAUI.

@jsuarezruiz
Copy link
Contributor

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.Maui.Controls.MessagingCenter.Subscription.InvokeCallback(Object sender, Object args) in D:\a\_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 96
   at Microsoft.Maui.Controls.MessagingCenter.InnerSend(String message, Type senderType, Type argType, Object sender, Object args) in D:\a\_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 225
   at Microsoft.Maui.Controls.MessagingCenter.Microsoft.Maui.Controls.IMessagingCenter.Send[Page,Boolean](Page sender, String message, Boolean args) in D:\a\_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 118
   at Microsoft.Maui.Controls.MessagingCenter.Send[Page,Boolean](Page sender, String message, Boolean args) in D:\a\_work\1\s\src\Controls\src\Core\MessagingCenter.cs:line 111
   at Microsoft.Maui.Controls.Page.OnPageBusyChanged() in D:\a\_work\1\s\src\Controls\src\Core\Page.cs:line 563
   at Microsoft.Maui.Controls.Page.<>c.<.cctor>b__129_0(BindableObject bo, Object o, Object n) in D:\a\_work\1\s\src\Controls\src\Core\Page.cs:line 36
   at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 532
   at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 466
   at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 388
   at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 362
   at Microsoft.Maui.Controls.Page.set_IsBusy(Boolean value) in D:\a\_work\1\s\src\Controls\src\Core\Page.cs:line 101
   at MauiTestApp.MainPage.OnAppearing() in C:\Users\jsuarez\Downloads\MauiTestApp\MauiTestApp\MainPage.xaml.cs:line 14
   at Microsoft.Maui.Controls.Page.SendAppearing() in D:\a\_work\1\s\src\Controls\src\Core\Page.cs:line 487
   at Microsoft.Maui.Controls.ShellContent.SendPageAppearing(Page page) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 150
   at Microsoft.Maui.Controls.ShellContent.SendAppearing() in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 131
   at Microsoft.Maui.Controls.ShellSection.PresentedPageAppearing() in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellSection.cs:line 958
   at Microsoft.Maui.Controls.ShellSection.SendAppearing() in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellSection.cs:line 1060
   at Microsoft.Maui.Controls.ShellItem.SendAppearing() in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellItem.cs:line 328
   at Microsoft.Maui.Controls.ShellNavigationManager.<>c__DisplayClass16_0.<HandleNavigated>g__WaitForWindowToSet|1(Object sender, EventArgs e) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellNavigationManager.cs:line 242
   at Microsoft.Maui.Controls.Element.OnChildAdded(Element child) in D:\a\_work\1\s\src\Controls\src\Core\Element.cs:line 357
   at Microsoft.Maui.Controls.ShellContent.OnChildAdded(Element child) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 156
   at Microsoft.Maui.Controls.ShellContent.set_ContentCache(Page value) in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 196
   at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent() in D:\a\_work\1\s\src\Controls\src\Core\Shell\ShellContent.cs:line 81
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellSectionRenderer.cs:line 123
   at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:line 1999
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 352

@jsuarezruiz jsuarezruiz self-assigned this Aug 30, 2022
@jsuarezruiz jsuarezruiz added this to the .NET 7 Planning milestone Aug 30, 2022
@hartez hartez moved this to Done in MAUI SDK Ongoing Nov 23, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 23, 2022
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Feb 22, 2023
@samhouts samhouts modified the milestones: .NET 7 Planning, 8.0-preview1 Apr 6, 2023
@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 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! high It doesn't work at all, crashes or has a big impact. platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants