Skip to content

Commit 699d284

Browse files
committed
Skip optimizations for NodeApiJsiRuntime.cpp
1 parent d598943 commit 699d284

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

vnext/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@
158158
</ClCompile>
159159
<ClCompile Include="$(NodeApiJsiSrcDir)NodeApiJsiRuntime.cpp">
160160
<PrecompiledHeader>NotUsing</PrecompiledHeader>
161+
<!--
162+
Workaround for a Visual Studio 2026 (v145) C++ optimizer bug. With
163+
optimizations on, this translation unit is miscompiled such that the
164+
pointer-value-scope teardown in NodeApiJsiRuntime hands Hermes a stale
165+
napi_value, crashing in hermes!JSProxy::defineOwnProperty (via
166+
napi_create_reference) during rapid UI updates - e.g. the
167+
e2e-test-app-fabric visitAllPages test. Building this file without
168+
optimization (verified equivalent to `#pragma optimize("", off)`)
169+
avoids it. We must also opt out of /GL here so the disabled
170+
optimization survives link-time code generation. NodeApiJsiRuntime.cpp
171+
is externally provided, so the workaround lives here rather than in the
172+
source. Scoped to v145+ (the bug does not reproduce on v143); remove
173+
when the compiler bug is fixed.
174+
-->
175+
<Optimization Condition="$(PlatformToolsetVersion)&gt;=145">Disabled</Optimization>
176+
<WholeProgramOptimization Condition="$(PlatformToolsetVersion)&gt;=145">false</WholeProgramOptimization>
161177
</ClCompile>
162178
</ItemGroup>
163179
<ItemGroup Condition="'$(BuildMSRNCxxNodeApiJsiLoader)' != 'false'">

0 commit comments

Comments
 (0)