Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - Animated.event useNativeDriver:true sets incorrect translate position when moving fast #50496

Open
kocburak opened this issue Apr 4, 2025 · 4 comments

Comments

@kocburak
Copy link

kocburak commented Apr 4, 2025

Description

I have 2 transform translateY animation. When the useNativeDriver:false, there is no issue except performance. I can see the animation moves couple frames behind from native animation. When the useNativeDriver:true, while moving fast the component jumps around (usually to final position if there were no distruption to moementum scroll)

Steps to reproduce

  1. Install the application to you andorid using npx expo run:android --device while useNativeDriver: true
  2. Make a slide with momentum and while momentum exists stop and make small movement and remove you finger from screen. (see the video)

React Native Version

0.77.2

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

info Fetching system and libraries information...
System:
  OS: Windows 10 10.0.19045
  CPU: (16) x64 Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz
  Memory: 17.67 GB / 31.84 GB
Binaries:
  Node:
    version: 22.14.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 11.2.0
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "22"
      - "33"
      - "33"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 35.0.1
    System Images:
      - android-34 | Google APIs Intel x86_64 Atom
      - android-35 | AOSP ATD Intel x86_64 Atom
      - android-35 | Intel x86_64 Atom
      - android-35 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.22621.0
IDEs:
  Android Studio: AI-242.23726.103.2422.13016713
  Visual Studio:
    - 17.13.35825.156 (Visual Studio Community 2022)
Languages:
  Java: 17.0.7
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 15.1.3
    wanted: ^15.1.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.2
    wanted: ^0.77.2
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.78.2 is now available (your project is running on v0.77.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.78.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.77.2&to=0.78.2
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows".

Stacktrace or Logs

N/A

Reproducer

https://snack.expo.dev/@kocburak/usenativedriverbug

Screenshots and Videos

Screen_Recording_20250404_190621.mp4
@kocburak
Copy link
Author

kocburak commented Apr 5, 2025

I tried it on ios there is no issue.

@kocburak kocburak changed the title useNativeDriver:true sets incorrect translate position when moving fast Android - Animated.event useNativeDriver:true sets incorrect translate position when moving fast Apr 8, 2025
@kocburak
Copy link
Author

kocburak commented Apr 8, 2025

I looked the value usingdisclaimerTranslateY.addListener(value => { console.log(value) }) and the values were correct even though the placement on the screen was wrong. If you need more clarification about the topic I am willing to help.

@kocburak
Copy link
Author

kocburak commented Apr 8, 2025

I narrowed it down to: Animated.diffClamp function. When I remove this line there is no issue regarding the useNativeDriver:true

@kocburak
Copy link
Author

kocburak commented Apr 8, 2025

When I looked into DiffClampAnimatedNode.kt file I noticed val animatedNode = nativeAnimatedNodesManager.getNodeById(inputNodeTag) line. Is it possible that we are reading from wrong Tag ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant