Compilation error with USE_ANIMATION_BACKEND enabled

Open Beginner friendly
#11,554 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, cpp, react-native, typescript

Research direction

Start in Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp and inspect roundTextMetrics alongside the USE_ANIMATION_BACKEND build guards. Reproduce the Android New Architecture build with that flag enabled and check whether the function is unused in that configuration. Done when the build succeeds without the reported -Wunneeded-internal-declaration error.

Written by the indexing model from the issue text.

Description

Missing repro Platform: Android
Description

Hi,

There is a compilation error when building an application with reanimated 4.8.0 & worklets 0.14.0 with "USE_ANIMATION_BACKEND": true

/Users/viljami/Projects/foobar/node_modules/react-native-reanimated/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp:33:13: error: function 'roundTextMetrics' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] 33 | static void roundTextMetrics(folly::dynamic &updates) { | ^~~~~~~~~~~~~~~~ 1 error generated.

It can be resolved by adding 'maybe_unused' with a patch:


index ef1b65a..9410cc8 100644
--- a/node_modules/react-native-reanimated/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp
+++ b/node_modules/react-native-reanimated/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp
@@ -30,7 +30,7 @@ static inline std::shared_ptr<const ShadowNode> shadowNodeFromValue(
   }
 }
 
-static void roundTextMetrics(folly::dynamic &updates) {
+[[maybe_unused]] static void roundTextMetrics(folly::dynamic &updates) {
   for (const auto *propName : TEXT_METRIC_PROP_NAMES) {
     auto *value = updates.get_ptr(propName);
     if (value != nullptr && value->isNumber()) {

Steps to reproduce
  1. Toggle "USE_ANIMATION_BACKEND": true
  2. Try to compile the application
Snack or a link to a repository

https://snack.expo.io/

Reanimated version

4.8.0

Worklets version

0.14.0

React Native version

0.88.1

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native CLI

Architecture

New Architecture (Fabric renderer)

Reanimated feature flags

Yes

React Native release level

None

Build type

Release app & dev bundle

Device

Android emulator

Host machine

macOS

Device model

No response

Acknowledgements

Yes

Dominant language
TypeScript
Stars
11.1k
Forks
1.6k
Avg merge
3d 9h
Merged PRs (30d)
255

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from software-mansion/react-native-reanimated

All issues in software-mansion/react-native-reanimated

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.