Skip to content

Android Release Build measure and measureInWindow values incorrect #8086

@robmcilroy1992

Description

@robmcilroy1992

What happened?

For Android (worse in 15+) there's an issue only in release builds where using measure or measureInWindow on a View gives incorrect and inconsistent x and y coordinates.

If I push/pop the screen again the same view will give me different x and y coordinates. This is due to the animation when performing push/pop.

I've put in custom push/pop animations which fixes most screens but some views are still slightly off. I suspect the translate X/Y on the default animations is confusing the renderer as to the true position of views.

animations:
      Platform.OS === "android"
        ? {
            push: {
              content: {
                enter: {
                  scaleX: {
                    from: 0.85,
                    to: 1,
                    duration: 300,
                    interpolation: { type: "decelerate" },
                  },
                  scaleY: {
                    from: 0.85,
                    to: 1,
                    duration: 300,
                    interpolation: { type: "decelerate" },
                  },
                  alpha: {
                    from: 0,
                    to: 1,
                    duration: 300,
                  },
                },
              },
            },
            pop: {
              content: {
                exit: {
                  scaleX: {
                    from: 1,
                    to: 0.85,
                    duration: 250,
                    interpolation: { type: "accelerate" },
                  },
                  scaleY: {
                    from: 1,
                    to: 0.85,
                    duration: 250,
                    interpolation: { type: "accelerate" },
                  },
                  alpha: {
                    from: 1,
                    to: 0,
                    duration: 250,
                  },
                },
              },
            },
          }
        : undefined

What was the expected behaviour?

measure or measureInWindow on a View gives correct and consistent x and y coordinates.

Was it tested on latest react-native-navigation?

  • I have tested this issue on the latest react-native-navigation release and it still reproduces.

Help us reproduce this issue!

  1. Create a release build for any Android device.
  2. Push or pop any screen and use a ref + measure/measureInWindow (we use the x and y coordinates to show a popover)
  3. You'll notice the popover is in the incorrect position, if you push/pop again you'll get different x and y coordinates

In what environment did this happen?

React Native Navigation version: 8.1.0
React Native version: 0.77.2
Has Fabric (React Native's new rendering system) enabled: Yes
Node version: 20.11
Device model: Any
Android version: 15+

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions