1

Hello there,

I’m facing the following error while resetting the navigation to Home after a successful login. The app crashes as soon as the navigation resets. I’m able to reproduce the crash on a physical Samsung Galaxy S22, M52, and A11. The iOS devices are working fine.

Version I'm using:

"@react-navigation/bottom-tabs": "^6.0.9",
"@react-navigation/native": "^6.0.2",
"@react-navigation/native-stack": "^6.0.4",
"react-native": "0.76.3",
"react-native-screens": "^4.3.0",

Solutions I Tried:

-> I’ve seen other solutions where people suggest using Math.floor for numerical conversion and avoiding setting font sizes in points. However, in my case, I’m not using any of these conversions.

-> Another thing I tried was migrating to Navigation 7 with RN 0.77.0, but it didn’t help resolve the issue.

-> I also tried upgrading react-native-screens to 4.9.1, but no luck.

-> I’m not using any progress bars or reanimated carousels.

Any help would be appreciated. Here’s the full error:

03-09 20:22:19.169 E/AndroidRuntime( 2546): com.facebook.react.common.JavascriptException: Error: Exception in HostFunction: Loss of precision during arithmetic conversion: (long) 13.63636334080342
03-09 20:22:19.169 E/AndroidRuntime( 2546): 
03-09 20:22:19.169 E/AndroidRuntime( 2546): This error is located at:
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RNSScreenStackHeaderConfig
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in HeaderConfig
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RNSScreen
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspender
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspense
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Freeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in DelayedFreeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in InnerScreen
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in SceneView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspender
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspense
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Freeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in DelayedFreeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RNSScreenStack
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in ScreenStack
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NativeStackViewInner
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RCTView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in SafeAreaProviderCompat
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NativeStackView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in PreventRemoveProvider
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NavigationContent
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NativeStackNavigator
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in HomeStacks
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in StaticContainer
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in EnsureSingleNavigator
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in SceneView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RCTView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in DebugContainer
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in MaybeNestedStack
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RCTView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RNSScreen
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspender
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspense
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Freeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in DelayedFreeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in InnerScreen
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in SceneView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspender
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Suspense
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Freeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in DelayedFreeze
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RNSScreenStack
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in ScreenStack
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NativeStackViewInner
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RCTView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in SafeAreaProviderCompat
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NativeStackView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in PreventRemoveProvider
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NavigationContent
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NativeStackNavigator
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RootNavigator
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in EnsureSingleNavigator
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in BaseNavigationContainer
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in ThemeProvider
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in NavigationContainerInner
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RNCSafeAreaProvider
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in SafeAreaProvider
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in AppContainer
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RCTView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in PersistGate
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Provider
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in AppHoc
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RNGestureHandlerRootView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in GestureHandlerRootView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in gestureHandlerRootHOC(AppHoc)
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in RCTView
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in Unknown
03-09 20:22:19.169 E/AndroidRuntime( 2546):     in AppContainer, js engine: hermes, stack:
1
  • Would you mind to share your navigation flow? Commented Mar 10 at 6:03

2 Answers 2

2

After extensive research and many new builds, I found that the problem seems to be related to Fabric. I turned off the new architecture in gradle.properties, and it started working. It looks like some Samsung devices are having conflicts with Fabric.

I’ll do more research and update here on why the new architecture is causing issues with navigation.

For now, the solution that worked for me was to turn off the new architecture in the gradle.properties file for Android.

/android/gradle.properties

newArchEnabled=false
Sign up to request clarification or add additional context in comments.

3 Comments

This isn't good.. You don't want to be stuck in the past with newArchEnabled=false
@Andrei Correct. That’s why I’m checking why the new architecture is causing issues with the navigation. I’m trying to update Navigation to v7 and React Native to the latest 0.79 version. If you find any other solution or the cause of this issue, do let me know.
I can confirm the same issue happens to me even with latest react-navigation. The only solution is disabling the newArch
0

I had the same issue, but mine came from the utility functions I used for responsive design.

I had to round up each return value to a whole number using Math.ceil() and it fixed the issue.

Here are the utility functions with round up return values:

import {Dimensions} from "react-native";

const {width, height} = Dimensions.get("window");

// Define base dimensions for scaling
const baseWidth = 375;
const baseheight = 812;

/**
 * Scale a given size based on the device's horizontal dimension.
 *
 * @param {number} size - The size to be scaled.
 * @returns {number} The scaled size.
 */
export const horizontalScale = (size: number) =>
  Math.ceil((width / baseWidth) * size);

/**
 * Scale a given size based on the device's vertical dimension.
 *
 * @param {number} size - The size to be scaled.
 * @returns {number} The scaled size.
 */
export const verticalScale = (size: number) =>
  Math.ceil((height / baseheight) * size);

/**
 * Scale a given size based on both horizontal and vertical dimensions.
 *
 * @param {number} size - The size to be scaled.
 * @param {number} factor - The factor to adjust the scaling.
 * @returns {number} The scaled size.
 */
export const moderateScale = (size: number, factor = 0.8) =>
  Math.ceil(size + (horizontalScale(size) - size) * factor);

1 Comment

How did you identify the root cause?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.