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

[0.76] AccessibilityValue in View throws exception: "Exception in HostFunction: Loss of precision during arithmetic conversion: (long) " #47635

Open
vincicat opened this issue Nov 15, 2024 · 22 comments
Labels
Needs: Triage 🔍 Newer Patch Available Platform: Android Android applications. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@vincicat
Copy link

vincicat commented Nov 15, 2024

Description

Similar to react-native-elements/react-native-elements#3955 Sharcoux/slider#102 callstack/react-native-paper#4544, when any non-zero value is given to AccessibilityValue.now on Android & iOS, conversion occurs and an exception will be thrown.

(remark: Using Math.round() to avoid any (long) value will fix the issue temporarily.)

Both Expo (0.52) and bare React Native App (0.76.1 + SDK 34, 0.76.2 + SDK 35) can reproduce the bug. Expo 0.51 will not, so it is very likely related to New Architecture.

Same issue found in iOS 18 in some cases, but expo demo can show that

Steps to reproduce

  1. go to demo
  2. switch to Android/iOS and make sure expo == 0.52
  3. click "Start Progress" to see the crash

React Native Version

0.76.2

Affected Platforms

Runtime - Android
Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

Binaries:
  Node:
    version: 23.1.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.9.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.11.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

Android:

Exception in HostFunction: Loss of precision during arithmetic conversion: (long) 0.00001

iOS:

Exception in HostFunction: Loss of precision during arithmetic conversion: (long long) 0.00001

Reproducer

https://snack.expo.dev/OEofab5meHPozAXyOQg6_

Screenshots and Videos

No response

@vincicat vincicat added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Nov 15, 2024
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.2. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot react-native-bot added the Platform: Android Android applications. label Nov 15, 2024
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@DominicWrege
Copy link

I have the same issue on iOS too.

@okanisildar
Copy link

I also have this issue on iOS. Math.round() is not even a temporary solution if you need a value to be between 0 and 1 like my use case.

@DominicWrege
Copy link

DominicWrege commented Nov 19, 2024

I am using the @react-native-picker/picker which causes the crash.

@vincicat
Copy link
Author

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

updated to 0.76.2, issue remains

@vincicat
Copy link
Author

@DominicWrege @okanisildar
Sorry to hear that but I don't have that issue on iOS, see if you can isolate the issue with an expo snack demo for iOS

@zbynekjadrnicek
Copy link

zbynekjadrnicek commented Nov 21, 2024

I have the same error after update to SDK 52. I use ProgressBar from react native paper and when I set its progress ratio to decimals, like 0.123, it throws error. But progress=1 works well.

@okanisildar
Copy link

okanisildar commented Nov 21, 2024

@vincicat you can check this expo snack.

@DominicWrege
Copy link

DominicWrege commented Nov 21, 2024

@vincicat

The floating-point item font size causes the crash in my case.

Snack example

@vincicat
Copy link
Author

@vincicat

The floating-point item font size causes the crash in my case.

Snack example

Thank you.
I think your case should open another ticket in the library to see if that is the library issue (*very likely, as it is okay to use floating point number in style by changing font size in other component of the snack...)

@vincicat
Copy link
Author

vincicat commented Nov 22, 2024

@vincicat you can check this expo snack.

Thank you so much.

Can confirm that issue occurs on iOS too.
see if react-native-elements/react-native-elements#3955 can help

@vincicat vincicat changed the title [android][0.76] AccessibilityValue in View throws exception: "Exception in HostFunction: Loss of precision during arithmetic conversion: (long) " [0.76] AccessibilityValue in View throws exception: "Exception in HostFunction: Loss of precision during arithmetic conversion: (long) " Nov 22, 2024
@vincicat
Copy link
Author

@react-native-bot can you add the label "Platform:iOS" into that issue?

@thonymv
Copy link

thonymv commented Nov 22, 2024

I'm getting the same error in RN 0.76.3, caused by inserting a float into AccessibilityValue.now in the LinearProgress component's source code of the react-native-elements library.
image

@functionzz
Copy link

I'm getting the same issue via implementation of a ProgressBar from 'react-native-paper'.

Older versions like 4.12.6 and newer versions like 5.12.5 both have the same problem.

@DominicWrege
Copy link

@vincicat

The floating-point item font size causes the crash in my case.

Snack example

Thank you.

I think your case should open another ticket in the library to see if that is the library issue (*very likely, as it is okay to use floating point number in style by changing font size in other component of the snack...)

That is an approach 👍.
With 0.75 it worked. Maybe its a combination of booth. Our I am holding it the wrong way.

@dnhan1707
Copy link

hi @vincicat , does this issue happen in other versions as well??

@dnhan1707
Copy link

dnhan1707 commented Nov 27, 2024

For this issue, the LinearProgress is using accessibilityValue which have to be integer

image

So you may want to use other library.
React Native recommends to use other community packages

image

Here is the link:
https://reactnative.directory/?search=progressbar

@vincicat
Copy link
Author

hi @vincicat , does this issue happen in other versions as well??

thanks @dnhan1707
I can confirm that we are good when using RN 0.75 and older (as old as 0.70) on the Android & iOS when NewArch is disabled
so this is a surprise that the doc said this should be an integer starting from RN 0.70...

linonetwo added a commit to tiddly-gittly/TidGi-Mobile that referenced this issue Nov 29, 2024
Warning: Error: Exception in HostFunction: Loss of precision during arithmetic conversion: (long long) 52.493322164093

This error is located at:
    in RCTView (created by View)
    in View (created by ProgressBar)
    in ProgressBar (created by Importer)
    in RCTView (created by View)
    in View (created by Styled(View))
    in Styled(View) (created by Importer)
    in Importer (created by SceneView)
    in StaticContainer

callstack/react-native-paper#4544
facebook/react-native#47635
@linonetwo
Copy link

Workaround for users of ProgressBar from 'react-native-paper':

- <ProgressBar progress={skinnyHtmlDownloadPercentage} color={MD3Colors.neutral30} />
+ <ProgressBar animatedValue={skinnyHtmlDownloadPercentage} color={MD3Colors.neutral30} />

@BeDev83
Copy link

BeDev83 commented Dec 8, 2024

Workaround for users of ProgressBar from 'react-native-paper':

- <ProgressBar progress={skinnyHtmlDownloadPercentage} color={MD3Colors.neutral30} />
+ <ProgressBar animatedValue={skinnyHtmlDownloadPercentage} color={MD3Colors.neutral30} />

This works, thank you!

@dnhan1707
Copy link

dnhan1707 commented Dec 9, 2024

The workaround fix would be removing the now: clamp(value) or we can set it to now: 0 in the LinearProgress.js
I already tested it and work well

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Newer Patch Available Platform: Android Android applications. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

10 participants