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

NRE with Essentials Preferences on Windows #5951

Closed
david-maw opened this issue Apr 9, 2022 · 3 comments
Closed

NRE with Essentials Preferences on Windows #5951

david-maw opened this issue Apr 9, 2022 · 3 comments
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/windows 🪟 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working

Comments

@david-maw
Copy link

Description

While testing a fairly large complex app in MAUI it faults navigating away from a page.

Steps to Reproduce

I can reproduce this but cannot provide a reproducible test case because I cannot figure out what exactly is triggering it and the failure I see is within a large body of code.

I've attached a stack trace that I think is immediately before the failure but I suspect the actual failure is in native code because I see this when it fails:
warning
I'm not sure how to request debug of native code in VS2022 but it would be helpful if the .NET stack were visible after a failure like this rather than just exiting the program when the dialog above and the "select another debugger" dialogs are dismissed.

Version with bug

Preview 14 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows 10

Did you find any workaround?

No.

Relevant log output

System.Private.CoreLib.dll!System.Runtime.InteropServices.ComWrappers.CallComputeVtables(System.Runtime.InteropServices.ComWrappersScenario scenario, System.Runtime.InteropServices.ComWrappers comWrappersImpl, object obj, System.Runtime.InteropServices.CreateComInterfaceFlags flags, out int count) Line 132
	at /_/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs(132)
[Native to Managed Transition]
[Managed to Native Transition]
System.Private.CoreLib.dll!System.Runtime.InteropServices.ComWrappers.TryGetOrCreateComInterfaceForObjectInternal(System.Runtime.CompilerServices.ObjectHandleOnStack comWrappersImpl, long wrapperId, System.Runtime.CompilerServices.ObjectHandleOnStack instance, System.Runtime.InteropServices.CreateComInterfaceFlags flags, out System.IntPtr retValue)
System.Private.CoreLib.dll!System.Runtime.InteropServices.ComWrappers.TryGetOrCreateComInterfaceForObjectInternal(System.Runtime.InteropServices.ComWrappers impl, object instance, System.Runtime.InteropServices.CreateComInterfaceFlags flags, out System.IntPtr retValue) Line 103
	at /_/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs(103)
System.Private.CoreLib.dll!System.Runtime.InteropServices.ComWrappers.GetOrCreateComInterfaceForObject(object instance, System.Runtime.InteropServices.CreateComInterfaceFlags flags) Line 81
	at /_/src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs(81)
WinRT.Runtime.dll!WinRT.ComWrappersSupport.CreateCCWForObjectForABI(object obj, System.Guid iid)
WinRT.Runtime.dll!WinRT.MarshalInspectable<System.__Canon>.CreateMarshaler<WinRT.IInspectable.Vftbl>(System.__Canon o, System.Guid iid, bool unwrapObject)
WinRT.Runtime.dll!WinRT.MarshalInspectable<object>.CreateMarshaler(object o, bool unwrapObject)
WinRT.Runtime.dll!ABI.Windows.Foundation.Collections.IMapMethods<string, object>.Insert(WinRT.IObjectReference obj, string key, object value)
WinRT.Runtime.dll!ABI.System.Collections.Generic.IDictionaryMethods<string, object>.Indexer_Set(WinRT.IObjectReference obj, string key, object value)
Microsoft.Windows.SDK.NET.dll!Windows.Storage.ApplicationDataContainerSettings.this[string].set(string key, object value)
Microsoft.Maui.Essentials.dll!Microsoft.Maui.Essentials.Implementations.PreferencesImplementation.Set<bool>(string key, bool value, string sharedName)
Microsoft.Maui.Essentials.dll!Microsoft.Maui.Essentials.Preferences.Set(string key, bool value, string sharedName)
Microsoft.Maui.Essentials.dll!Microsoft.Maui.Essentials.Preferences.Set(string key, bool value)
DivisiBill.dll!DivisiBill.Services.AppSettings.ImagePageCleanExit.set(bool value) Line 82
	at C:\Users\david\Documents\Develop\Phone\DivisiBillMAUI\DivisiBill\DivisiBill\Services\AppSettings.cs(82)
DivisiBill.dll!DivisiBill.ImagePage.OnAppearing() Line 15
	at C:\Users\david\Documents\Develop\Phone\DivisiBillMAUI\DivisiBill\DivisiBill\Views\ImagePage.xaml.cs(15)
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Page.SendAppearing()
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ShellContent.SendPageAppearing(Microsoft.Maui.Controls.Page page)
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ShellContent.SendAppearing()
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ShellSection.PresentedPageAppearing()
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ShellSection.OnRemovePage(Microsoft.Maui.Controls.Page page)
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ShellSection.NavigationImpl.OnRemovePage(Microsoft.Maui.Controls.Page page)
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Internals.NavigationProxy.RemovePage(Microsoft.Maui.Controls.Page page)
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Shell.NavigationImpl.OnRemovePage(Microsoft.Maui.Controls.Page page)
Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Internals.NavigationProxy.RemovePage(Microsoft.Maui.Controls.Page page)
DivisiBill.dll!DivisiBill.ScanPage.AppendItemList(bool clearItems) Line 177
	at C:\Users\david\Documents\Develop\Phone\DivisiBillMAUI\DivisiBill\DivisiBill\Views\ScanPage.xaml.cs(177)
[Resuming Async Method]
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<System.__Canon>.ExecutionContextCallback(object s) Line 287
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(287)
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 183
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs(183)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<DivisiBill.ScanPage.<AppendItemList>d__14>.MoveNext(System.Threading.Thread threadPoolThread) Line 324
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(324)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<System.__Canon>.MoveNext() Line 302
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(302)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__12_0(System.Action innerContinuation, System.Threading.Tasks.Task innerTask) Line 302
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs(302)
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation..cctor.AnonymousMethod__17_0(object state) Line 671
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(671)
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback callback, object state, ref System.Threading.Tasks.Task currentTask) Line 697
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(697)
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run(System.Threading.Tasks.Task task, bool canInlineContinuationTask) Line 412
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(412)
System.Private.CoreLib.dll!System.Threading.Tasks.Task.RunContinuations(object continuationObject) Line 3387
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs(3387)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetExistingTaskResult(System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult> task, System.Threading.Tasks.VoidTaskResult result) Line 446
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(446)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult() Line 109
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilder.cs(109)
[Completed] DivisiBill.dll!DivisiBill.Models.Meal.MarkAsNewAsync(string why) Line 714
	at C:\Users\david\Documents\Develop\Phone\DivisiBillMAUI\DivisiBill\DivisiBill\Models\Meal.cs(714)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<System.__Canon>.ExecutionContextCallback(object s) Line 287
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(287)
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 183
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs(183)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<DivisiBill.Models.Meal.<MarkAsNewAsync>d__61>.MoveNext(System.Threading.Thread threadPoolThread) Line 324
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(324)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<System.__Canon>.MoveNext() Line 302
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(302)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__12_0(System.Action innerContinuation, System.Threading.Tasks.Task innerTask) Line 302
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs(302)
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation..cctor.AnonymousMethod__17_0(object state) Line 671
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(671)
System.Private.CoreLib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback callback, object state, ref System.Threading.Tasks.Task currentTask) Line 697
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(697)
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run(System.Threading.Tasks.Task task, bool canInlineContinuationTask) Line 412
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(412)
System.Private.CoreLib.dll!System.Threading.Tasks.Task.RunContinuations(object continuationObject) Line 3387
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs(3387)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.SetExistingTaskResult(System.Threading.Tasks.Task<System.Threading.Tasks.VoidTaskResult> task, System.Threading.Tasks.VoidTaskResult result) Line 446
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(446)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult() Line 109
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilder.cs(109)
[Completed] DivisiBill.dll!DivisiBill.Services.Saver.SaveCurrentMealIfChangedAsync(string why) Line 84
	at C:\Users\david\Documents\Develop\Phone\DivisiBillMAUI\DivisiBill\DivisiBill\Services\Saver.cs(84)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<System.__Canon>.ExecutionContextCallback(object s) Line 287
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(287)
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 183
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs(183)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<DivisiBill.Services.Saver.<SaveCurrentMealIfChangedAsync>d__6>.MoveNext(System.Threading.Thread threadPoolThread) Line 324
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(324)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<System.__Canon>.MoveNext() Line 302
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs(302)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__12_0(System.Action innerContinuation, System.Threading.Tasks.Task innerTask) Line 302
	at /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs(302)
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.GetActionLogDelegate.AnonymousMethod__0() Line 438
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(438)
System.Private.CoreLib.dll!System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation..cctor.AnonymousMethod__8_0(object state) Line 371
	at /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs(371)
Microsoft.InteractiveExperiences.Projection.dll!Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.Post.AnonymousMethod__0()
Microsoft.InteractiveExperiences.Projection.dll!ABI.Microsoft.UI.Dispatching.DispatcherQueueHandler.Do_Abi_Invoke(System.IntPtr thisPtr)
[Native to Managed Transition]
[Managed to Native Transition]
Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStatics.Microsoft.UI.Xaml.IApplicationStatics.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback)
Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback)
DivisiBill.dll!DivisiBill.WinUI.Program.Main(string[] args) Line 31
	at C:\Users\david\Documents\Develop\Phone\DivisiBillMAUI\DivisiBill\DivisiBill\obj\Debug\net6.0-windows10.0.19041\win10-x64\Platforms\Windows\App.g.i.cs(31)
@david-maw david-maw added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 9, 2022
@Eilon Eilon added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label Apr 11, 2022
@jfversluis jfversluis changed the title Fault in framework code NRE with Essentials Preferences on Windows Apr 14, 2022
@jfversluis
Copy link
Member

As mentioned in your linked issue, it should definitely be possible to get the right exception shown that gives you a bit more to work with. It seems subsequently it throws a good old COM exception because the underlaying layer is WinUI. Either try to tweak your exception settings or run the same on maybe Android to see if it shows up there as well and it gives you a bit more information.

Although I understand that you say this is in a big codebase and it's hard to get us a reproduction, that also makes it very hard to diagnose this and say with confidence that this is actually a bug in our codebase. That makes this issue very hard to make actionable.

From the stack trace it seems to have something to do with the preferences that you're trying to save. Do you have any relevant code around that? Would you be able to take that code and put it in a separate project and see if you can reproduce it that way?

@jfversluis jfversluis added s/needs-repro Attach a solution or code which reproduces the issue and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Apr 14, 2022
@ghost
Copy link

ghost commented Apr 14, 2022

Hi @david-maw. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

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.

@david-maw
Copy link
Author

Thanks, I'll go ahead and close this one on the assumption that #6034 is a reproducible test case of this same issue and it looks like the error is caused by something local. (exceptions configuration perhaps).

@ghost ghost locked as resolved and limited conversation to collaborators May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/windows 🪟 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants