Dev app crashes when switching color scheme while Text element with DynamicColorIOS is used
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C++
- Estrellas
- 127k
- Forks
- 25.3k
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 4
Descripción
Description
The React Native app in development mode will crash when switching the color scheme (through system or the app) while there's a Text element using DynamicColorIOS. (see App.tsx in repro)
The error message shown in Xcode is:
Assertion failure: self.size() > 3 || std::none_of( self.begin(), self.end(), [&](auto const& k) { return self.key_eq()(key, k); })
Message:
File: .../ReproducerApp/ios/Pods/Headers/Public/RCT-Folly/folly/container/detail/F14SetFallback.h
Line: 239
Function: findImpl
(It's a FOLLY_SAFE_DCHECK assertion written here)
Stack trace shows the assertion failure occurs while calling _cache.get here in RCTTextLayoutManager.mm:
- (NSAttributedString *)_nsAttributedStringFromAttributedString:(AttributedString)attributedString
{
auto sharedNSAttributedString = _cache.get(attributedString, [](AttributedString attributedString) {
return wrapManagedObject(RCTNSAttributedStringFromAttributedString(attributedString));
});
return unwrapManagedObject(sharedNSAttributedString);
}
Fun fact is that due to the assertion statement (self.size() > 3 || ...), if we add more Text elements on the screen, the app won't crash.
This also doesn't affect release builds since that assertion seems to be dev-only.
Steps to reproduce
- Run the app through Xcode.
- Switch color scheme.
- Notice the crash.
React Native Version
0.76.0, 0.76.4, 0.76.5
Affected Platforms
Runtime - iOS
Areas
(not sure) Fabric - The New Renderer
Output of npx react-native info
System:
OS: macOS 14.5
CPU: (8) arm64 Apple M1
Memory: 203.86 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.15.0
path: ~/.asdf/installs/nodejs/20.15.0/bin/node
Yarn:
version: 1.22.22
path: ~/.asdf/installs/nodejs/20.15.0/bin/yarn
npm:
version: 10.7.0
path: ~/.asdf/plugins/nodejs/shims/npm
Watchman:
version: 2024.06.24.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /Users/z/.asdf/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.2
- iOS 18.2
- macOS 15.2
- tvOS 18.2
- visionOS 2.2
- watchOS 11.2
Android SDK: Not Found
IDEs:
Android Studio: 2024.2 AI-242.23339.11.2421.12550806
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.1
path: /opt/homebrew/opt/openjdk/bin/javac
Ruby:
version: 3.0.2
path: /Users/z/.asdf/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.5
wanted: 0.76.5
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
Assertion failure: self.size() > 3 || std::none_of( self.begin(), self.end(), [&](auto const& k) { return self.key_eq()(key, k); })
Message:
File: .../ReproducerApp/ios/Pods/Headers/Public/RCT-Folly/folly/container/detail/F14SetFallback.h
Line: 239
Function: findImpl
Reproducer
https://github.com/zetavg/rn-crash-DynamicColorIOS-color-scheme-switch
Screenshots and Videos
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el reproductor vinculado y RCTTextLayoutManager.mm, especialmente con _nsAttributedStringFromAttributedString: y la llamada a _cache.get alrededor de la línea 337. Ejecuta la aplicación mediante Xcode, cambia la combinación de colores con un elemento Text que use DynamicColorIOS e inspecciona el comportamiento de la caché y de la aserción. La tarea está terminada cuando la aplicación iOS de desarrollo ya no se bloquee en este escenario.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp, ios, react-native
- Área
- mobile
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100