Skip to content

Crash when accessing PlatformColor('Complement') #15189

@chrisglein

Description

@chrisglein

Problem Description

This is when using one of the defined accent color constants from the PlatformColor implementation, specifically Complement

Of note... looks like all the other values defined in that set work fine. So maybe Complement should just be removed?
Image

Faulting area of code from Theme.cpp
https://github.com/microsoft/react-native-windows/blob/63e9eaaa2249c3f7b46200203cb69c006c5770a9/vnext/Microsoft.ReactNative/Fabric/Composition/Theme.cpp

  auto uiColor = s_uiColorTypes.find(platformColor);
  if (uiColor != s_uiColorTypes.end()) {
    auto uiSettings{winrt::Windows::UI::ViewManagement::UISettings()};
    color = uiSettings.GetColorValue(uiColor->second); // <--- HERE
    auto pair = std::make_pair(true, color);
    m_colorCache[platformColor] = pair;
    return true;
  }

Callstack snippet:

 	KernelBase.dll!RaiseException(unsigned long dwExceptionCode, unsigned long dwExceptionFlags, unsigned long nNumberOfArguments, const unsigned __int64 * lpArguments) Line 954	C
 	vcruntime140_app.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 82	C++
 	Microsoft.ReactNative.dll!winrt::throw_hresult(const winrt::hresult result, const std::source_location & sourceInformation) Line 5041	C++
 	[Inline Frame] Microsoft.ReactNative.dll!winrt::check_hresult(const winrt::hresult) Line 5159	C++
 	Microsoft.ReactNative.dll!winrt::impl::consume_Windows_UI_ViewManagement_IUISettings3<winrt::Windows::UI::ViewManagement::UISettings>::GetColorValue(const winrt::Windows::UI::ViewManagement::UIColorType & desiredColor) Line 817	C++
>	Microsoft.ReactNative.dll!winrt::Microsoft::ReactNative::Composition::implementation::Theme::TryGetPlatformColor(const std::string & platformColor, winrt::Windows::UI::Color & color) Line 180	C++
 	Microsoft.ReactNative.dll!winrt::Microsoft::ReactNative::Composition::implementation::Theme::Color(const facebook::react::Color & color) Line 449	C++
 	Microsoft.ReactNative.dll!winrt::Microsoft::ReactNative::Composition::implementation::Theme::D2DColor(const facebook::react::Color & color) Line 521	C++
 	Microsoft.ReactNative.dll!winrt::Microsoft::ReactNative::Composition::implementation::ParagraphComponentView::DrawTextW() Line 280	C++

Steps To Reproduce

PlatformColor('Complement')

Expected Results

PlatformColor with a bad constant should not crash (in Paper it resolves to transparent). PlatformColor actually has a fallback mechanism where you pass in an array of options. At most I'd expect a log / yellow box (although we didn't do that on Paper).

CLI version

15.0.1

Environment

System:
  OS: Windows 11 10.0.27954
  CPU: "(24) x64 AMD Ryzen Threadripper PRO 3945WX 12-Cores     "
  Memory: 33.19 GB / 63.86 GB
Binaries:
  Node:
    version: 18.18.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 4.1.1
    path: C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm:
    version: 9.8.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.22621.0
      - 10.0.26100.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.14.36518.9 (Visual Studio Community 2022)
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.80.2
    wanted: ^0.80.2
  react-native-windows:
    installed: 0.80.0-preview.4
    wanted: ^0.80.0-preview.4
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Community Modules

None

Target React Native Architecture

New Architecture (WinAppSDK) Only

Target Platform Version

None

Visual Studio Version

None

Build Configuration

None

Snack, code example, screenshot, or link to a repository

No response

Metadata

Metadata

Assignees

Labels

Area: FabricSupport Facebook FabricNew ArchitectureBroad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabricbug

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions