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

New animation related crashes #517

Closed
ehren opened this issue May 25, 2016 · 14 comments
Closed

New animation related crashes #517

ehren opened this issue May 25, 2016 · 14 comments

Comments

@ehren
Copy link
Contributor

ehren commented May 25, 2016

I don't have any steps to reproduce. These happen in a few different places in my app (always the same call stack). Guessing this is somehow related to fd809e0 but can't say if modifications to my app will bypass the issue at this point.

crash 1 stack:

    combase.dll!RoFailFastWithErrorContextInternal2(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 1034  C++
    combase.dll!RoFailFastWithErrorContext(HRESULT hrError) Line 1041   C++
    twinapi.appcore.dll!`wil::ErrorHandlingHelpers::Instance(void)'::`2'::`dynamic atexit destructor for 'wrapper''(void)   Unknown
    twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationFactory::ForwardLocalError(struct IRestrictedErrorInfo *)   Unknown
    combase.dll!CallErrorForwarder(void * hProcess, int fLocal, IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1167  C++
    combase.dll!RoReportUnhandledError(IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1251   C++
>   msvcp140d_app.dll!Concurrency::details::_ExceptionHolder::ReportUnhandledError() Line 331   C++
    UIKIT.DLL!Concurrency::details::_ExceptionHolder::~_ExceptionHolder() Line 750  C++
    UIKIT.DLL!Concurrency::details::_ExceptionHolder::`scalar deleting destructor'(unsigned int)    C++
    UIKIT.DLL!std::_Ref_count_obj<Concurrency::details::_ExceptionHolder>::_Destroy() Line 914  C++
    UIKIT.DLL!std::_Ref_count_base::_Decref() Line 112  C++
    UIKIT.DLL!std::_Ptr_base<Concurrency::details::_ExceptionHolder>::_Decref() Line 339    C++
    UIKIT.DLL!std::shared_ptr<Concurrency::details::_ExceptionHolder>::~shared_ptr<Concurrency::details::_ExceptionHolder>() Line 568   C++
    UIKIT.DLL!Concurrency::details::_Task_impl_base::~_Task_impl_base() Line 1483   C++
    UIKIT.DLL!Concurrency::details::_Task_impl<unsigned char>::~_Task_impl<unsigned char>() Line 2074   C++
    UIKIT.DLL!Concurrency::details::_Task_impl<unsigned char>::`scalar deleting destructor'(unsigned int)   C++
    UIKIT.DLL!std::_Ref_count_obj<Concurrency::details::_Task_impl<unsigned char> >::_Destroy() Line 913    C++
    UIKIT.DLL!std::_Ref_count_base::_Decref() Line 112  C++
    UIKIT.DLL!std::_Ptr_base<Concurrency::details::_Task_impl<unsigned char> >::_Decref() Line 339  C++
    UIKIT.DLL!std::shared_ptr<Concurrency::details::_Task_impl<unsigned char> >::~shared_ptr<Concurrency::details::_Task_impl<unsigned char> >() Line 568   C++
    UIKIT.DLL!Concurrency::task<unsigned char>::_ContinuationTaskHandle<void,XamlCompositor::Controls::CALayerXaml ^,std::function<XamlCompositor::Controls::CALayerXaml ^ __cdecl(Concurrency::task<void>)>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>::~_ContinuationTaskHandle<void,XamlCompositor::Controls::CALayerXaml ^,std::function<XamlCompositor::Controls::CALayerXaml ^ __cdecl(Concurrency::task<void>)>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>() Line 3569   C++
    UIKIT.DLL!Concurrency::task<unsigned char>::_ContinuationTaskHandle<void,XamlCompositor::Controls::CALayerXaml ^,std::function<XamlCompositor::Controls::CALayerXaml ^ __cdecl(Concurrency::task<void>)>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>::`scalar deleting destructor'(unsigned int) C++
    UIKIT.DLL!std::default_delete<Concurrency::details::_TaskProcHandle>::operator()(Concurrency::details::_TaskProcHandle * _Ptr) Line 1195    C++
    UIKIT.DLL!std::unique_ptr<Concurrency::details::_TaskProcHandle,std::default_delete<Concurrency::details::_TaskProcHandle> >::~unique_ptr<Concurrency::details::_TaskProcHandle,std::default_delete<Concurrency::details::_TaskProcHandle> >() Line 1398    C++
    UIKIT.DLL!Concurrency::details::_TaskProcHandle::_RunChoreBridge(void * _Parameter) Line 147    C++
    UIKIT.DLL!Concurrency::details::_TaskCollectionBaseImpl::_ScheduleTask(Concurrency::details::_TaskProcHandle * _Parameter, Concurrency::details::_TaskInliningMode _InliningMode) Line 193  C++
    UIKIT.DLL!Concurrency::details::_Task_impl_base::_ScheduleTask(Concurrency::details::_TaskProcHandle * _PTaskHandle, Concurrency::details::_TaskInliningMode _InliningMode) Line 1709   C++
    UIKIT.DLL!Concurrency::details::_Task_impl_base::_ScheduleContinuationTask::__l5::void <lambda>(void)::__l8::<lambda>() Line 1810   C++
    UIKIT.DLL!std::_Invoker_functor::_Call<void <lambda>(void) &>(Concurrency::details::_Task_impl_base::_ScheduleContinuationTask::__l5::void <lambda>(void)::__l8::void <lambda>(void) & _Obj) Line 1400  C++
    UIKIT.DLL!std::invoke<void <lambda>(void) &>(Concurrency::details::_Task_impl_base::_ScheduleContinuationTask::__l5::void <lambda>(void)::__l8::void <lambda>(void) & _Obj) Line 1466   C++
    UIKIT.DLL!std::_Invoke_ret<void,void <lambda>(void) &>(std::_Forced<void,1> __formal, Concurrency::details::_Task_impl_base::_ScheduleContinuationTask::__l5::void <lambda>(void)::__l8::void <lambda>(void) & <_Vals_0>) Line 1484 C++
    UIKIT.DLL!std::_Func_impl<void <lambda>(void),std::allocator<int>,void>::_Do_call() Line 212    C++
    msvcp140d_app.dll!std::_Func_class<void>::operator()() Line 280 C++
    msvcp140d_app.dll!Concurrency::details::_PPLTaskContextCallbackBridge(tagComCallData * _PParam) Line 235    C++
    combase.dll!CRemoteUnknown::DoCallback(tagXAptCallback * pCallbackData) Line 1704   C++
    rpcrt4.dll!_Invoke@12�()    Unknown
    rpcrt4.dll!_NdrStubCall2@16�()  Unknown
    combase.dll!CStdStubBuffer_Invoke(IRpcStubBuffer * This, tagRPCOLEMESSAGE * prpcmsg, IRpcChannelBuffer * pRpcChannelBuffer) Line 1529   C++
    combase.dll!ObjectMethodExceptionHandlingAction<<lambda_adf5d6ba83bff890864fd80ca2bbf1eb> >(InvokeStubWithExceptionPolicyAndTracing::__l7::<lambda_adf5d6ba83bff890864fd80ca2bbf1eb> action, ObjectMethodExceptionHandlingInfo * pExceptionHandlingInfo, ExceptionHandlingResult * pExceptionHandlingResult, void *) Line 91    C++
    combase.dll!DefaultStubInvoke(bool bIsAsyncBeginMethod, IServerCall * pServerCall, IRpcChannelBuffer * pChannel, IRpcStubBuffer * pStub, unsigned long * pdwFault) Line 1880    C++
    combase.dll!ServerCall::ContextInvoke(tagRPCOLEMESSAGE * pMessage, IRpcStubBuffer * pStub, CServerChannel * pChannel, tagIPIDEntry * pIPIDEntry, unsigned long * pdwFault) Line 1568    C++
    combase.dll!AppInvoke(ServerCall * pServerCall, CServerChannel * pChannel, IRpcStubBuffer * pStub, void * pv, void * pStubBuffer, tagIPIDEntry * pIPIDEntry, WireLocalThis * pLocalb) Line 1612 C++
    combase.dll!ComInvokeWithLockAndIPID(ServerCall * pServerCall, tagIPIDEntry * pIPIDEntry, bool * pbCallerResponsibleForRequestMessageCleanup) Line 2686 C++
    combase.dll!ComInvoke(ServerCall * pServerCall, bool * pbCallerResponsibleForRequestMessageCleanup) Line 2226   C++
    combase.dll!ThreadDispatch(ServerCall * pServerCall) Line 414   C++
    combase.dll!CComApartment::ASTAHandleMessage(IMessageParam * pParam) Line 2525  C++
    combase.dll!ASTAWaitContext::Wait(unsigned int cHandlesOuter, void * const * pHandlesOuter, unsigned long dwTimeoutOuter, ASTAWaitContext::ProcessEventsMsgWaitParams * pProcessEventsMsgWaitParams, unsigned long * pdwLastError) Line 1026    C++
    combase.dll!CoMsgWaitInProcessEvents(CO_PROCESS_EVENTS_CONTEXT * pContext, unsigned long nCount, void * const * pHandles, unsigned long dwMilliseconds, unsigned long dwWakeMask, unsigned long dwFlags) Line 1987  C++
    Windows.UI.dll!Windows::UI::Core::CDispatcher::WaitAndProcessMessages(void * hEventWait) Line 370   C++
    Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessEvents(Windows::UI::Core::CoreProcessEventsOption options) Line 541   C++
    Windows.UI.Xaml.dll!CJupiterWindow::RunCoreWindowMessageLoop() Line 1118    C++
    Windows.UI.Xaml.dll!CJupiterControl::RunMessageLoop() Line 796  C++
    Windows.UI.Xaml.dll!DirectUI::DXamlCore::RunMessageLoop() Line 2767 C++
    Windows.UI.Xaml.dll!DirectUI::FrameworkView::Run() Line 103 C++
    twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationView::Run(void) Unknown
    twinapi.appcore.dll!Microsoft::WRL::Details::Make<struct Microsoft::WRL::Details::InvokeHelper<struct Windows::Foundation::IAsyncActionCompletedHandler,class <lambda_e4b1934750ab38adfb74f12296e81f29>,2>,class <lambda_e4b1934750ab38adfb74f12296e81f29> &>(class <lambda_e4b1934750ab38adfb74f12296e81f29> &)    Unknown
    SHCore.dll!CallerIdentity::GetCallingProcessHandle(unsigned long,enum RUNTIMEBROKER_CALLERIDENTITY_CHECK,void * *)  Unknown
    kernel32.dll!@BaseThreadInitThunk@12�() Unknown
    ntdll.dll!__RtlUserThreadStart()    Unknown
    ntdll.dll!__RtlUserThreadStart@8�() Unknown

Debug build output:

Exception thrown at 0x7468DAE8 (KernelBase.dll) in Winobjc.exe: 0x40080201: WinRT originate error (parameters: 0x80070057, 0x0000001D, 0x05EDE9F8).
Exception thrown at 0x7468DAE8 in Winobjc.exe: Microsoft C++ exception: Platform::InvalidArgumentException ^ at memory location 0x05EDD2E0. HRESULT:0x80070057 The parameter is incorrect.
WinRT information: The parameter is incorrect.

Unhandled exception at 0x74576FB1 (combase.dll) in Winobjc.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x05EDC994, 0x00000001).
@jaredhms
Copy link
Contributor

Thanks for the bug report. Can you grab the HRESULT from the second frame in the call stack?

Also, can you please try to repro after adding noexcept to the lambdas on these two lines?

https://github.com/Microsoft/WinObjC/blob/master/Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp#L250

https://github.com/Microsoft/WinObjC/blob/master/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp#L1693

For example; similar to this line:

https://github.com/Microsoft/WinObjC/blob/master/Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp#L662

@ehren
Copy link
Contributor Author

ehren commented May 26, 2016

The HRESULT is E_INVALIDARG.

I'm just building those changes now.

@ehren
Copy link
Contributor Author

ehren commented May 26, 2016

Unfortunately, I still get the exact same crash stack after doing a clean debug build with those changes. Should mention this apparently happens on a GC of some kind - about 6 seconds after a bunch of deallocations associated with popping a few view controllers off the UINavigationController stack (not in response to user interaction).

@ehren
Copy link
Contributor Author

ehren commented May 26, 2016

May have a different crash stack (now on app startup) with a release build with the added noexcept changes. I'm going to ensure I'm dealing with a clean release build before posting the stack.

@ehren
Copy link
Contributor Author

ehren commented May 26, 2016

Here's a different crash stack from a release build (HRESULT is E_INVALIDARG)

    combase.dll!RoFailFastWithErrorContextInternal2(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 1034  C++
    combase.dll!RoFailFastWithErrorContext(HRESULT hrError) Line 1041   C++
    twinapi.appcore.dll!`wil::ErrorHandlingHelpers::Instance(void)'::`2'::`dynamic atexit destructor for 'wrapper''(void)   Unknown
    twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationFactory::ForwardLocalError(struct IRestrictedErrorInfo *)   Unknown
    combase.dll!CallErrorForwarder(void * hProcess, int fLocal, IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1167  C++
    combase.dll!RoReportUnhandledError(IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1251   C++
>   msvcp140_app.dll!516aac71() Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for msvcp140_app.dll]  
    [External Code] 

As a sanity test (should have done this first!) I'm also getting the same crash stack with the latest winobjc.zip release (so it's not something silly like linking the wrong .obj file)

>   combase.dll!RoFailFastWithErrorContextInternal2(HRESULT hrError, unsigned long cStowedExceptions, _STOWED_EXCEPTION_INFORMATION_V2 * * aStowedExceptionPointers) Line 1035  C++
    combase.dll!RoFailFastWithErrorContext(HRESULT hrError) Line 1041   C++
    twinapi.appcore.dll!`wil::ErrorHandlingHelpers::Instance(void)'::`2'::`dynamic atexit destructor for 'wrapper''(void)   Unknown
    twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationFactory::ForwardLocalError(struct IRestrictedErrorInfo *)   Unknown
    combase.dll!CallErrorForwarder(void * hProcess, int fLocal, IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1167  C++
    combase.dll!RoReportUnhandledError(IRestrictedErrorInfo * pRestrictedErrorInfo) Line 1251   C++
    msvcp140_app.dll!527dac71() Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for msvcp140_app.dll]  
    [External Code] 

I'm going to play around a bit with those noexcept changes + look a bit more at the places in my app apparently causing the issue. One case may be related to changing a visible UIImageView's image
with UIView transitionWithView: while a UITableView row animation is running - but can't say for sure.

@ehren
Copy link
Contributor Author

ehren commented May 26, 2016

I don't think the noexcepts did anything but I was able to "fix" this by just disabling that SnapshotLayer function pointed to by @jaredhms (fixed all crashes and even a bit of new jankiness in the 'UITableViewRow + transitionWithView' double animation case mentioned above):

diff --git a/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp b/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
index d3771a1..10366a8 100644
--- a/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
+++ b/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
@@ -1684,7 +1684,7 @@ void EventedStoryboard::_CreateWoosh(CALayerXaml^ layer, bool fromRight, bool in
 }

 concurrency::task<CALayerXaml^> EventedStoryboard::SnapshotLayer(CALayerXaml^ layer) {
-    if (((layer->m_size.Height == 0) && (layer->m_size.Width == 0)) || (layer->Opacity == 0)) {
+    if (true || ((layer->m_size.Height == 0) && (layer->m_size.Width == 0)) || (layer->Opacity == 0)) {
         return concurrency::task_from_result<CALayerXaml^>(nullptr);
     }
     else {

Haven't tried setting a breakpoints in that lambda etc yet.

@ehren
Copy link
Contributor Author

ehren commented May 26, 2016

Looks like the lambda needs to check if the task is cancelled before doing anything - seeing if I've got a clean fix.

@ehren
Copy link
Contributor Author

ehren commented May 26, 2016

Taking off for today but this change is not the right fix -- app just hangs or rather stays idle (probably something isn't firing):

diff --git a/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp b/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
index d3771a1..1c8a046 100644
--- a/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
+++ b/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
@@ -1691,7 +1691,16 @@ concurrency::task<CALayerXaml^> EventedStoryboard::SnapshotLayer(CALayerXaml^ la
         RenderTargetBitmap^ snapshot = ref new RenderTargetBitmap();
         return concurrency::create_task(snapshot->RenderAsync(layer, (int)(layer->CurrentWidth * CALayerXaml::s_screenScale), 0))
             .then([snapshot, layer](concurrency::task<void> result) {
-            // Return a new 'copy' layer with the rendered content
+
+            try
+            {
+                result.get();
+            }
+            catch (const task_canceled&)
+            {
+                return layer;
+            }
+
             CALayerXaml^ newLayer = CALayerXaml::CreateLayer();
             newLayer->_CopyPropertiesFrom(layer);

@jaredhms
Copy link
Contributor

I don't understand why the task is getting canceled though, because we're definitely not doing any PPL cancelations. Maybe the RenderAsync is failing with a Platform::Exception? We'll follow up in a bit with another suggested change to try. Thanks for the details.

@ehren
Copy link
Contributor Author

ehren commented May 27, 2016

If I use this patch:

diff --git a/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp b/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
index d3771a1..72f9b00 100644
--- a/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
+++ b/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
@@ -1689,9 +1689,13 @@ concurrency::task<CALayerXaml^> EventedStoryboard::SnapshotLayer(CALayerXaml^ la
     }
     else {
         RenderTargetBitmap^ snapshot = ref new RenderTargetBitmap();
-        return concurrency::create_task(snapshot->RenderAsync(layer, (int)(layer->CurrentWidth * CALayerXaml::s_screenScale), 0))
-            .then([snapshot, layer](concurrency::task<void> result) {
-            // Return a new 'copy' layer with the rendered content
+        return concurrency::create_task([snapshot, layer] {
+            __debugbreak();
+
+            snapshot->RenderAsync(layer, (int)(layer->CurrentWidth * CALayerXaml::s_screenScale), 0);
+        }).then([snapshot, layer](concurrency::task<void> result) {
+            __debugbreak();
+
             CALayerXaml^ newLayer = CALayerXaml::CreateLayer();
             newLayer->_CopyPropertiesFrom(layer);

to step into the RenderAsync I get the following stack (though curiously setting the breakpoints seems to cause the crash to happen at an earlier point in my app):

    combase.dll!SendReport(HRESULT error, unsigned int cchMax, const wchar_t * message, unsigned short pSid, void * pExceptionObject, IUnknown *) Line 387  C++
>   combase.dll!RoOriginateError(HRESULT error, HSTRING__ * message) Line 490   C++
    vccorlib140d_app.dll!Windows::Foundation::Diagnostics::OriginateError(HRESULT error, HSTRING__ * message) Line 211  C++
    vccorlib140d_app.dll!Platform::Details::ReCreateException(long hrEx) Line 137   C++
    vccorlib140d_app.dll!__abi_WinRTraiseWrongThreadException() Line 538    C++
    UIKIT.DLL!__abi_WinRTraiseException(long __hrArg) Line 1117 C++
    UIKIT.DLL!__abi_ThrowIfFailed(long __hrArg) Line 102    C++
    UIKIT.DLL!Windows::UI::Xaml::Media::Imaging::IRenderTargetBitmap::RenderAsync(Windows::UI::Xaml::UIElement ^ __param0, int __param1, int __param2)  C++
    UIKIT.DLL!XamlCompositor::Controls::EventedStoryboard::SnapshotLayer::__l7::<lambda>() Line 1696    C++
    [External Code] 
    [Async Call]    
    UIKIT.DLL!XamlCompositor::Controls::EventedStoryboard::SnapshotLayer(XamlCompositor::Controls::CALayerXaml ^ layer) Line 1692   C++
    UIKIT.DLL!DisplayAnimation::AddTransitionAnimation(DisplayNode * node, const char * type, const char * subtype) Line 249    C++
    UIKIT.DLL!DisplayAnimationTransition::AddToNode(DisplayNode * node) Line 382    Objective-C++
    UIKIT.DLL!DisplayNode::AddAnimation(DisplayAnimation * anim) Line 906   Objective-C++
    UIKIT.DLL!QueuedAnimation::Process() Line 1118  Objective-C++
    UIKIT.DLL!DispatchCompositorTransactions::__l10::<lambda>() Line 663    C++
    [External Code] 
    [Async Call]    
    UIKIT.DLL!DispatchCompositorTransactions(std::deque<std::shared_ptr<ICompositorTransaction>,std::allocator<std::shared_ptr<ICompositorTransaction> > > && subTransactions, std::deque<std::shared_ptr<ICompositorAnimationTransaction>,std::allocator<std::shared_ptr<ICompositorAnimationTransaction> > > && animationTransactions, std::map<DisplayNode *,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::shared_ptr<ICompositorTransaction>,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::shared_ptr<ICompositorTransaction> > > >,std::less<DisplayNode *>,std::allocator<std::pair<DisplayNode * const,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::shared_ptr<ICompositorTransaction>,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::shared_ptr<ICompositorTransaction> > > > > > > && propertyTransactions, std::deque<std::shared_ptr<ICompositorTransaction>,std::allocator<std::shared_ptr<ICompositorTransaction> > > && movementTransactions) Line 662    C++
    UIKIT.DLL!DisplayTransaction::Process() Line 1252   Objective-C++
    UIKIT.DLL!DispatchCompositorTransactions(std::deque<std::shared_ptr<ICompositorTransaction>,std::allocator<std::shared_ptr<ICompositorTransaction> > > && subTransactions, std::deque<std::shared_ptr<ICompositorAnimationTransaction>,std::allocator<std::shared_ptr<ICompositorAnimationTransaction> > > && animationTransactions, std::map<DisplayNode *,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::shared_ptr<ICompositorTransaction>,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::shared_ptr<ICompositorTransaction> > > >,std::less<DisplayNode *>,std::allocator<std::pair<DisplayNode * const,std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::shared_ptr<ICompositorTransaction>,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::shared_ptr<ICompositorTransaction> > > > > > > && propertyTransactions, std::deque<std::shared_ptr<ICompositorTransaction>,std::allocator<std::shared_ptr<ICompositorTransaction> > > && movementTransactions) Line 654    C++
    UIKIT.DLL!DisplayTransaction::Process() Line 1252   Objective-C++
    UIKIT.DLL!CAXamlCompositor::ProcessTransactions() Line 1538 Objective-C++
    UIKIT.DLL!_i_UIApplication__notify_(UIApplication * self, objc_selector * _cmd, unsigned int activity) Line 355 Objective-C++
    FOUNDATION.DLL!_i_NSRunLoopState___notifyObservers_(NSRunLoopState * self, objc_selector * _cmd, unsigned int mode) Line 200    Objective-C++
    FOUNDATION.DLL!_i_NSRunLoop__limitDateForMode_(NSRunLoop * self, objc_selector * _cmd, NSString * mode) Line 198    Objective-C++
    FOUNDATION.DLL!_i_NSRunLoop__runMode_beforeDate_(NSRunLoop * self, objc_selector * _cmd, NSString * mode, NSDate * date) Line 259   Objective-C++
    FOUNDATION.DLL!_i_NSRunLoop__run(NSRunLoop * self, objc_selector * _cmd) Line 301   Objective-C++

error is RPC_E_WRONG_THREAD.

And then if I continue, I'll hit the breakpoint in the .then lambda where I can see the task is cancelled.

At this point I still don't think I'm doing something silly in my app (like dispatching an animation off the main thread.....)

@mnithish
Copy link
Member

@ehren thanks for the details. The RPC_E_WRONG_THREAD is because you have used a lambda without specifying the continuation task context to use. You need to specify task_continuation_context::use_current for the lambda to execute on the thread it was called on.

Can you try the below patch and let me know how it goes?

--- a/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
+++ b/Frameworks/UIKit/StarboardXaml/CALayerXaml.cpp
@@ -1694,13 +1694,22 @@ concurrency::task<CALayerXaml^> EventedStoryboard::SnapshotLayer(CALayerXaml^ la
     }
     else {
         RenderTargetBitmap^ snapshot = ref new RenderTargetBitmap();
-
         return concurrency::create_task(snapshot->RenderAsync(layer, (int)(layer->CurrentWidth * CALayerXaml::s_screenScale), 0))
             .then([snapshot, layer](concurrency::task<void> result) {
+
+            try
+            {
+                result.get();
+            }
+            catch (Platform::Exception ^ex)
+            {
+                return (CALayerXaml^)nullptr;
+            }
+
             // Return a new 'copy' layer with the rendered content
             CALayerXaml^ newLayer = CALayerXaml::CreateLayer();
             newLayer->_CopyPropertiesFrom(layer);

@ehren
Copy link
Contributor Author

ehren commented May 27, 2016

@jaredhms that works perfectly!

@ehren
Copy link
Contributor Author

ehren commented May 27, 2016

Sorry meant @mnithish

Thanks!

@mnithish
Copy link
Member

Great, thanks for testing it out @ehren. We will make sure this goes into our next week's drop.

@rajsesh rajsesh closed this as completed in 17cf90a Jun 3, 2016
weswmsft pushed a commit that referenced this issue Jun 9, 2016
This change fixes crash in WinRT RenderAsync when an invalid Layer
is passed to it. Though the API was doing the same before, PPL
task chaining change for the fiber-less UI exposed this issue as
the exception now gets propogated through the chain.

Fixes #517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants