From 034a685049b4563fe7ac50e5f4e2134d2b18d2d5 Mon Sep 17 00:00:00 2001 From: Andy Himberger Date: Fri, 31 May 2019 15:20:53 -0700 Subject: [PATCH] require AttachRoot to be called from UI thread --- vnext/ReactUWP/Views/ReactControl.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/vnext/ReactUWP/Views/ReactControl.cpp b/vnext/ReactUWP/Views/ReactControl.cpp index ed5eb6a0715..37056d18fff 100644 --- a/vnext/ReactUWP/Views/ReactControl.cpp +++ b/vnext/ReactUWP/Views/ReactControl.cpp @@ -121,12 +121,15 @@ void ReactControl::AttachRoot() noexcept }); }); - // Schedule initialization that must happen on the UI thread - m_reactInstance->DefaultNativeMessageQueueThread()->runOnQueue([this]() { - m_touchEventHandler->AddTouchHandlers(m_xamlRootView); - auto initialProps = m_initialProps; - m_reactInstance->AttachMeasuredRootView(m_pParent, std::move(initialProps)); - }); + // We assume Attach has been called from the UI thread +#ifdef DEBUG + auto coreWindow = winrt::CoreWindow::GetForCurrentThread(); + assert(coreWindow != nullptr); +#endif + + m_touchEventHandler->AddTouchHandlers(m_xamlRootView); + auto initialProps = m_initialProps; + m_reactInstance->AttachMeasuredRootView(m_pParent, std::move(initialProps)); m_isAttached = true; }