Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "RNIsland UIA fragment root should report parents fragment root",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix crash running on server 2016",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
1 change: 1 addition & 0 deletions vnext/ExperimentalFeatures.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>
<PropertyGroup Condition="'$(SolutionName)'=='ReactWindows-Desktop'">
<RnwNewArch>false</RnwNewArch>
<UseExperimentalWinUI3>true</UseExperimentalWinUI3>
Comment thread
JesseCol marked this conversation as resolved.
</PropertyGroup>
<PropertyGroup>
<ReactExperimentalFeaturesSet>true</ReactExperimentalFeaturesSet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ HRESULT __stdcall CompositionRootAutomationProvider::GetRuntimeId(SAFEARRAY **pR

*pRetVal = nullptr;

if (!m_island)
return E_FAIL;

auto id = reinterpret_cast<INT_PTR>(winrt::get_unknown(m_island));
Comment thread
JesseCol marked this conversation as resolved.
Outdated

*pRetVal = SafeArrayCreateVector(VT_I4, 0, 3);
if (*pRetVal == nullptr)
return E_OUTOFMEMORY;

auto rgiRuntimeId = static_cast<int*>((*pRetVal)->pvData);

rgiRuntimeId[0] = UiaAppendRuntimeId;
rgiRuntimeId[1] = LODWORD(id);
rgiRuntimeId[2] = HIDWORD(id);

return S_OK;
}

Expand Down Expand Up @@ -153,8 +168,18 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_FragmentRoot(IRawElemen
if (pRetVal == nullptr)
Comment thread
JesseCol marked this conversation as resolved.
return E_POINTER;

AddRef();
*pRetVal = this;
*pRetVal = nullptr;
Comment thread
JesseCol marked this conversation as resolved.

if (m_island)
{
auto parentRoot = m_island.FragmentRootAutomationProvider();
auto spFragment = parentRoot.try_as<IRawElementProviderFragmentRoot>();
if (spFragment)
{
*pRetVal = spFragment.detach();
return S_OK;
}
}

return S_OK;
}
Expand Down Expand Up @@ -249,8 +274,6 @@ HRESULT __stdcall CompositionRootAutomationProvider::Navigate(
if (pRetVal == nullptr)
return E_POINTER;

// Fragment roots do not enable navigation to a parent or siblings; navigation among fragment roots is handled by the
// default window providers. Elements in fragments must navigate only to other elements within that fragment.
if (direction == NavigateDirection_FirstChild || direction == NavigateDirection_LastChild) {
if (auto rootView = rootComponentView()) {
auto uiaProvider = rootView->EnsureUiaProvider();
Expand All @@ -260,6 +283,15 @@ HRESULT __stdcall CompositionRootAutomationProvider::Navigate(
return S_OK;
}
}
} else if (direction == NavigateDirection_Parent) {
if (m_island) {
auto parent = m_island.ParentAutomationProvider();
auto spFragment = parent.try_as<IRawElementProviderFragment>();
if (spFragment) {
*pRetVal = spFragment.detach();
return S_OK;
}
}
}
*pRetVal = nullptr;
return S_OK;
Expand Down
20 changes: 19 additions & 1 deletion vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,24 @@ std::unique_ptr<facebook::jsi::PreparedScriptStore> CreatePreparedScriptStore()
}

#ifdef USE_FABRIC

typedef HRESULT(__stdcall *SetThreadDescriptionFn)(HANDLE, PCWSTR);
void SetJSThreadDescription() noexcept {
// Office still supports Server 2016 so we need to use Run Time Dynamic Linking and cannot just use:
// ::SetThreadDescription(GetCurrentThread(), L"React-Native JavaScript Thread");

auto moduleHandle = GetModuleHandleW(L"kernelbase.dll");
// The description is just for developer experience, so we can skip it if kernelbase isn't already loaded
if (!moduleHandle)
return;

auto proc = GetProcAddress(moduleHandle, "SetThreadDescription");
if (!proc)
return;

reinterpret_cast<SetThreadDescriptionFn>(proc)(GetCurrentThread(), L"React-Native JavaScript Thread");
}

void ReactInstanceWin::InitializeBridgeless() noexcept {
InitUIQueue();

Expand Down Expand Up @@ -636,7 +654,7 @@ void ReactInstanceWin::InitializeBridgeless() noexcept {
Mso::Copy(m_whenDestroyed)));

m_jsMessageThread.Load()->runOnQueueSync([&]() {
::SetThreadDescription(GetCurrentThread(), L"React-Native JavaScript Thread");
SetJSThreadDescription();
auto timerRegistry =
::Microsoft::ReactNative::TimerRegistry::CreateTimerRegistry(m_reactContext->Properties());
auto timerRegistryRaw = timerRegistry.get();
Expand Down