Bug 45294 - Unhandled exception UWP after back navigation
Summary: Unhandled exception UWP after back navigation
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Samantha Houts [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-10-11 21:25 UTC by richard
Modified: 2017-07-11 08:59 UTC (History)
8 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Debug unhandled exception event args (39.30 KB, image/png)
2016-10-11 21:25 UTC, richard
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description richard 2016-10-11 21:25:30 UTC
Created attachment 17988 [details]
Debug unhandled exception event args

I can reproduce at will by selecting an item in a Listview in ContentPage 'A' then navigating 
to another ContentPage 'B' containing a list view doing nothing on 'B' then navigate back to 'A'. 
'A' reappears and then exception is thrown. 

No issues with android; this MAY have begun occurring after Microsoft automagically updated my computer 
to Win 10 1607 - as I have primarily been working with physical android devices I am not sure - though 
the code being executed has not changed for quite some time and did NOT have issues with UWP in the 
not-to-distant past.

Xamarin.Forms 2.3.1.114
Visual Studio 2015 Update 3
Xamarin   4.2.0.703 (3b7df6f)
Xamarin.Android   7.0.1.3 (96c7ba6)
Xamarin.iOS   10.0.1.10 (ad1cd42)


Attached image file is screenshot showing exception info - also is included in text below.

Exception is caught at 'DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION' below


 partial class App : global::Windows.UI.Xaml.Application
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks"," 14.0.0.0")]
        private bool _contentLoaded;
        /// <summary>
        /// InitializeComponent()
        /// </summary>
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks"," 14.0.0.0")]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        public void InitializeComponent()
         {
            if (_contentLoaded)
                return;

            _contentLoaded = true;
#if DEBUG && !DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT
            DebugSettings.BindingFailed += (sender, args) =>
            {
                global::System.Diagnostics.Debug.WriteLine(args.Message);
            };
#endif
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
            UnhandledException += (sender, e) =>
            {
                if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
            };
#endif
        }
    }
-------------------------------------------------------------------------------
Exception: Error HRESULT E_FAIL has been returned by a call to a COM component
Message: Unspecified error
Native View:
 
[0] = 0x62e23610 {Windows.UI.Xaml.dll!ctl::ComObject<class ctl::ActivationFactory<class DirectUI::AccessKeyDisplayDismissedEventArgs> >::QueryInterface(struct _GUID const &,void * *)}
[1] = 0x63665710 {Windows.UI.Xaml.dll!ctl::ComObject<class ctl::ActivationFactory<class DirectUI::AccessKeyDisplayDismissedEventArgs> >::AddRef(void)}
[2] = 0x63647c00 {Windows.UI.Xaml.dll!ctl::ComObject<class ctl::ActivationFactory<class DirectUI::AccessKeyDisplayDismissedEventArgs> >::Release(void)}
Comment 1 Samantha Houts [MSFT] 2016-10-20 17:57:55 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it.  
 
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d  

Warm regards, 
Xamarin Forms Team
Comment 2 aculliney 2017-01-13 23:47:51 UTC
We are also seeing an increase in HRESULT E_FAIL errors with ListViews in a Win8.1 app running latest Xamarin.Forms stable (on a Win10 laptop running Version 1607, OS Build 14393.693).

Anecdotally, this also seems to have happened for us after a Win10 update, or possibly a Xamarin plugin for Visual Studio update.

I am attempting to create a reduced testcase, but haven't yet succeeded.  Below is a stacktrace of the exception.  Possibly it will help.  Regards,


...


>	xpulsar.exe!xpulsar.Windows.Shared.MainApp.InitializeComponent.AnonymousMethod__4_1(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) Line 50	C#
 	[Native to Managed Transition]	
 	Windows.UI.Xaml.dll!DirectUI::CFTMEventSource<Windows::UI::Xaml::IUnhandledExceptionEventHandler,Windows::UI::Xaml::IApplication,Windows::UI::Xaml::IUnhandledExceptionEventArgs>::Raise(Windows::UI::Xaml::IApplication * pSource, Windows::UI::Xaml::IUnhandledExceptionEventArgs * pArgs) Line 326	C++
 	Windows.UI.Xaml.dll!DirectUI::FrameworkApplication::RaiseUnhandledExceptionEvent(HRESULT hrToReport, HSTRING__ * hstrMessage, unsigned int * pfHandled) Line 747	C++
 	Windows.UI.Xaml.dll!DirectUI::ErrorHelper::RaiseUnhandledExceptionEvent(HRESULT hrToReport, const xstring_ptr & strMessage, unsigned int * pfHandled) Line 305	C++
 	Windows.UI.Xaml.dll!DirectUI::ErrorHelper::ProcessUnhandledError(DirectUI::ErrorInfo & errorInfo, unsigned int fSkipFailFastIfNoErrorContext, unsigned int * pfHandled) Line 590	C++
 	Windows.UI.Xaml.dll!DirectUI::FinalUnhandledErrorDetectedRegistration::OnFinalUnhandledErrorDetected(IInspectable * pSender, Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs * pArgs) Line 976	C++
 	Windows.UI.Xaml.dll!Microsoft::WRL::Details::InvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,Windows::Foundation::IEventHandler<Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs *>,Microsoft::WRL::FtmBase,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil,Microsoft::WRL::Details::Nil>,long (__stdcall*)(IInspectable *,Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs *),2>::Invoke(IInspectable * arg1, Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs * arg2) Line 274	C++
 	twinapi.appcore.dll!Windows::Internal::Details::GitInvokeHelper<struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs *>,class Windows::Internal::GitPtr,2>::Invoke(struct IInspectable *,struct Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs *)	Unknown
 	twinapi.appcore.dll!Windows::ApplicationModel::Core::UnhandledErrorInvokeHelper::Invoke(struct IInspectable *,struct Windows::ApplicationModel::Core::IUnhandledErrorDetectedEventArgs *)	Unknown
 	twinapi.appcore.dll!Microsoft::WRL::InvokeTraits<2>::InvokeDelegates<class <lambda_cfe4908e69df27956b2af89a159f6904>,struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs *> >(class <lambda_cfe4908e69df27956b2af89a159f6904>,class Microsoft::WRL::Details::EventTargetArray *,class Microsoft::WRL::EventSource<struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<2> > *)	Unknown
 	twinapi.appcore.dll!Microsoft::WRL::EventSource<struct Windows::Foundation::IEventHandler<class Windows::ApplicationModel::Core::UnhandledErrorDetectedEventArgs *>,struct Microsoft::WRL::InvokeModeOptions<2> >::DoInvoke<class <lambda_cfe4908e69df27956b2af89a159f6904> >(class <lambda_cfe4908e69df27956b2af89a159f6904>)	Unknown
 	twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplication::ForwardLocalError(struct IRestrictedErrorInfo *)	Unknown
 	twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationFactory::ForwardLocalError(struct IRestrictedErrorInfo *)	Unknown
 	combase.dll!CallErrorForwarder(void * hProcess, int fLocal, IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1235	C++
 	combase.dll!RoReportUnhandledError(IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1319	C++
 	Windows.UI.Xaml.dll!DirectUI::ErrorHelper::ReportUnhandledError(HRESULT hrError) Line 490	C++
 	Windows.UI.Xaml.dll!AgCoreCallbacks::ReportUnhandledError(unsigned int errorCode) Line 918	C++
 	Windows.UI.Xaml.dll!CXcpDispatcher::Tick() Line 1415	C++
 	Windows.UI.Xaml.dll!CXcpBrowserHost::OnPaint() Line 1700	C++
 	Windows.UI.Xaml.dll!CXcpDispatcher::OnPaint() Line 631	C++
 	Windows.UI.Xaml.dll!CControlBase::OnPaint() Line 212	C++
 	Windows.UI.Xaml.dll!CJupiterControl::Paint() Line 463	C++
 	Windows.UI.Xaml.dll!CJupiterControl::HandleWindowMessage(unsigned int uMsg, unsigned int wParam, long lParam) Line 241	C++
 	Windows.UI.Xaml.dll!CJupiterWindow::CoreWindowSubclassProc(HWND__ * hwnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 1057	C++
 	Windows.UI.Xaml.dll!CJupiterWindow::StaticCoreWindowSubclassProc(HWND__ * hwnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 479	C++
 	user32.dll!__InternalCallWinProc@20()	Unknown
 	user32.dll!UserCallWinProcCheckWow()	Unknown
 	user32.dll!DispatchClientMessage()	Unknown
 	user32.dll!___fnDWORD@4()	Unknown
 	ntdll.dll!_KiUserCallbackDispatcher@12()	Unknown
 	user32.dll!_DispatchMessageW@4()	Unknown
 	Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessMessage(int bDrainQueue, int * pbWindowMessagesProcessed, int * pbInvokeItemProcessed) Line 308	C++
 	Windows.UI.dll!Windows::UI::Core::CDispatcher::WaitAndProcessMessagesInternal(int bRunAlwaysOnce, void * hEventWait) Line 1768	C++
 	Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessEvents(Windows::UI::Core::CoreProcessEventsOption options) Line 562	C++
 	Windows.UI.Xaml.dll!DirectUI::FrameworkView::Run() Line 105	C++
 	twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationView::Run(void)	Unknown
 	twinapi.appcore.dll!Microsoft::WRL::Details::MakeAndInitialize<class Windows::ApplicationModel::Core::CoreApplication,class Windows::ApplicationModel::Core::CoreApplication>(class Windows::ApplicationModel::Core::CoreApplication * *)	Unknown
 	SHCore.dll!Microsoft::WRL::Details::RuntimeClassBaseT<3>::AsIID<class Microsoft::WRL::Details::RuntimeClass<struct Microsoft::WRL::Details::InterfaceList<class Windows::Internal::AsyncBaseWithProgressFTM<struct Windows::Foundation::IAsyncOperationWithProgressCompletedHandler<unsigned int,unsigned int>,struct Windows::Foundation::IAsyncOperationProgressHandler<unsigned int,unsigned int>,1,struct Microsoft::WRL::AsyncOptions<2,0,&struct _GUID const GUID_CAUSALITY_WINDOWS_PLATFORM_ID,2> >,struct Microsoft::WRL::Details::InterfaceList<struct Windows::Foundation::IAsyncOperationWithProgress<unsigned int,unsigned int>,struct Microsoft::WRL::Details::InterfaceList<struct Windows::Internal::IAsyncOperationLocal,struct Microsoft::WRL::Details::InterfaceList<struct Microsoft::WRL::CloakedIid<struct Windows::Internal::IAsyncDeferral>,struct Microsoft::WRL::Details::InterfaceList<struct Microsoft::WRL::CloakedIid<struct Windows::Internal::IComPoolTask>,struct Microsoft::WRL::Details::InterfaceList<struct Microsoft::WRL::CloakedIi()	Unknown
 	kernel32.dll!@BaseThreadInitThunk@12()	Unknown
 	ntdll.dll!__RtlUserThreadStart()	Unknown
 	ntdll.dll!__RtlUserThreadStart@8()	Unknown
Comment 3 aculliney 2017-01-25 16:35:54 UTC
It's possible that this bug is related to the issues mentioned here :

https://github.com/Microsoft/WindowsUIDevLabs/issues/14
https://github.com/Microsoft/WindowsUIDevLabs/issues/15.

We have not yet found a workaround nor have we been able to create a reduced testcase, but unfortunately the crashes continue in Windows.UI.Xaml.dll!CXcpDispatcher::Tick() Line 1415
Comment 4 aculliney 2017-02-02 00:06:09 UTC
Unfortunately we have not been able to create a reduced test case for this issue and cannot justify continued effort in pursuing one.

We have however found a solution that "works for us", and may help others who stumble upon this issue.  With each PushAsync() of a Xamarin.Forms.Page in our app running on WinRT, we first push a blank Xamarin.Forms.Page.  Coming back out we PopAsync() twice.  Ugly, but it appears to makes the crash go away (or much less likely to occur).

NOTE that we use this hackaround only for our WinRT build.  We have not experienced any crashes related to PopAsync() of Pages in our Android build.
Comment 5 Rui Marinho 2017-06-19 21:13:09 UTC
Because we have not be able to reproduce this issue in current versions we are now
 closing this issue. If you are still encountering this issue, please reopen the
ticket with the requested information. Thanks!
Comment 6 Matteo Bortolazzo 2017-07-11 08:59:27 UTC
Same problem here:
Page A with list -> page B -> Page C -> Back -> Back and Exception ={System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.} 
only on UWP