[Android][Fabric] Edge-to-edge Modal first layout subtracts system insets, then jumps to full height (RN 0.87.1)
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 57/100
Línea de trabajo
Start with DisplayMetricsHolder.kt and ModalHostViewComponentDescriptor.cpp, which the report identifies as the path that supplies the initial Fabric modal size; compare that calculation with the later size update in ReactModalHostView.kt. The report includes an RNTester reproducer in RNTesterPlayground.js and a candidate Kotlin change. Reproduce the first-layout measurements, then verify that an edge-to-edge modal starts at its full window height without regressing non-edge-to-edge behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Summary
On Android with Fabric and edgeToEdgeEnabled=true, a newly mounted core React Native Modal first lays out its full-size child using the screen height minus the top and bottom system insets, then lays it out again using the actual full edge-to-edge window height.
On the tested emulator this is 816 dp -> 914.2857 dp. The difference is exactly the system insets. This reproduces with a plain Modal and View, without Copilot or any other overlay component in the probe.
Expected: initial Fabric modal bounds match the actual edge-to-edge dialog bounds; a full-size child starts at 914.2857 dp in this configuration.
Actual: first onLayout is 816 dp, followed by 914.2857 dp. Consumers that calculate bottom-anchored positions or cache the first measurement can visibly jump or retain an incorrect position. Dimensions.get('window') and Dimensions.get('screen') already report the correct 914.2857 dp.
Environment and scope
- Reproduced at runtime on React Native 0.87.1, React 19.2.3, Hermes, Fabric/New Architecture.
- Pixel 8 emulator, Android API 35, arm64-v8a, targetSdk 36, portrait, three-button navigation.
- Screen: 1080 x 2400 px, density 2.625; logical size about 411.4286 x 914.2857 dp.
- edgeToEdgeEnabled=true; Reduce Motion off.
- This report concerns Android initial layout; it does not claim an equivalent iOS issue.
- The same unconditional subtraction exists in the 0.86.0 source, but 0.86.0 was not runtime-tested in this investigation.
Native code path
- ModalHostViewComponentDescriptor.cpp, v0.87.1 creates initial Fabric state via FabricUIManager.getEncodedScreenSizeWithoutVerticalInsets.
- DisplayMetricsHolder.kt, v0.87.1 obtains statusBars | navigationBars | displayCutout insets and unconditionally subtracts insets.top + insets.bottom from screenDisplayMetrics.heightPixels.
- ReactModalHostView.kt, v0.87.1 already treats statusBarTranslucent and navigationBarTranslucent as enabled when isEdgeToEdgeFeatureFlagOn is true. The real dialog has the full screen height; its subsequent onSizeChanged updates Fabric state to that size.
Measured arithmetic:
screen height: 2400 px / 2.625 = 914.2857 dp
insets: top 132 px + bottom 126 px = 258 px = 98.2857 dp
initial Fabric height: (2400 - 258) / 2.625 = 816 dp
actual native dialog height: 2400 / 2.625 = 914.2857 dp
Edge-to-edge does not make WindowInsets zero; it changes whether content extends beneath those areas. The initial-state calculation appears to omit that distinction.
Small candidate fix and verification
In DisplayMetricsHolder.kt:
+import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
-val verticalInsets = insets.top + insets.bottom
+val verticalInsets = if (isEdgeToEdgeFeatureFlagOn) 0 else insets.top + insets.bottom
For an isolated native A/B test, this Kotlin class was recompiled and replaced in the 0.87.1 debug AAR, then the Android app was rebuilt and installed. Only DisplayMetricsHolder.class differed in the final experimental AAR; other classes, Kotlin module metadata and native libraries were unchanged. This was not a full RN C++ source rebuild.
Results (three fresh modal mounts per variant):
| Variant | Stock 0.87.1 | With candidate native fix |
|---|---|---|
| transparent, animationType=none | 816 -> 914.2857 | 914.2857 only |
| both translucent props explicitly true | 816 -> 914.2857 | 914.2857 only |
| transparent=false | 816 -> 914.2857 | 914.2857 only |
| hardwareAccelerated=true | 816 -> 914.2857 | 914.2857 only |
| flex:1 child instead of absoluteFill | 816 -> 914.2857 | 914.2857 only |
| mount child after onShow | 914.2857 only | 914.2857 only |
The five immediate-content variants reproduced the incorrect initial size in 15/15 openings. With the candidate fix, all 18/18 openings across the six variants reported only the correct size. No timeout, requestAnimationFrame, animation or manual remeasurement was needed in the fixed immediate-content cases.
Mounting content only after onShow worked as a JS workaround in the three checks, but avoids observing the initial layout rather than correcting it. onShow ordering relative to the second layout varied in the immediate-content tests.
The candidate preserves the previous calculation when the edge-to-edge flag is false. It still needs upstream coverage for other Android versions, navigation modes, rotation, multi-window and non-edge-to-edge/translucent combinations; these have not been verified here.
Related reports
- #35804 / #46359: earlier Android modal height issue/fix. This report concerns the initial Fabric state calculation in 0.87.1, where that older fix is already present.
- #52450: initial measurement problems inside Android Modal; related timing area, but here the first height is a specific nonzero screen-minus-insets value.
Steps to reproduce
- Use a React Native 0.87.1 Android app with Hermes/Fabric and edgeToEdgeEnabled=true in android/gradle.properties; rebuild the native app.
- Use the linked App.tsx as the root component. It uses only React and core React Native components. No Copilot, images, navigation or safe-area library is required by this example.
- Run on a portrait Pixel 8 API 35 emulator with three-button navigation (the measured setup used targetSdk 36).
- Open React Native DevTools Console and press Open Modal. Observe the full-size child onLayout events; animationType is none.
- Close and reopen the Modal. On the affected setup each fresh mount starts at 816 dp and then reports 914.2857 dp.
- Also try statusBarTranslucent and navigationBarTranslucent together: these did not correct the first layout in the tests.
- Apply the native candidate fix and ensure the changed Kotlin code is compiled into react-android (editing node_modules alone does not change the prebuilt Maven AAR). Rebuild/install and repeat: first layout should now be 914.2857 dp without the intermediate 816 dp.
The Gist is a reduced App.tsx reproducer, not a complete published project. Measurements in this report were collected with equivalent core Modal/View probes mounted inside an existing RN 0.87.1 app; a fresh-template end-to-end run of the Gist has not yet been performed.
React Native Version
0.87.1
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
Relevant excerpt of `npx @react-native-community/cli info` (local paths omitted):
System:
OS: macOS 26.6.2
CPU: (16) arm64 Apple M3 Max
Binaries:
Node: 22.22.3
Yarn: 3.6.4
npm: 10.9.8
Watchman: 2026.01.12.00
Managers:
CocoaPods: 1.16.2
SDKs:
Android SDK API Levels: 24, 31, 33, 34, 35, 36, 37
Android NDK: 22.1.7171670 (CLI-reported installed SDK value)
IDEs:
Android Studio: 2024.2
Xcode: 26.4.1/17E202
Languages:
Java: 17.0.18 (CLI environment)
Ruby: 3.3.10
npmPackages:
@react-native-community/cli: 20.2.0
react: 19.2.3
react-native: 0.87.1
Android:
hermesEnabled: true
newArchEnabled: true
Runtime tested: Pixel 8 emulator / Android API 35 / arm64-v8a.
Project targetSdk: 36. edgeToEdgeEnabled=true.
The experimental Gradle build used Android Studio's bundled JBR; CLI-reported Java/NDK entries above describe the CLI environment, not necessarily the selected build toolchain.
Stacktrace or Logs
Normalized captured onLayout measurements (not a crash):
Stock RN 0.87.1, plain transparent Modal, animationType=none:
first: {x: 0, y: 0, width: 411.4285583496094, height: 816}
second: {x: 0, y: 0, width: 411.4285583496094, height: 914.2857055664062}
Dimensions.window and Dimensions.screen during test:
{width: 411.42857142857144, height: 914.2857142857143, scale: 2.625, fontScale: 1}
With candidate DisplayMetricsHolder fix:
first and only: {x: 0, y: 0, width: 411.4285583496094, height: 914.2857055664062}
Before: all 15 immediate-content openings across five variants had 816 -> 914.2857.
After: all 18 openings across six variants had only 914.2857.
See the description for the variant matrix and native test method.
MANDATORY Reproducer
https://github.com/react/react-native/pull/59358
RNTester Playground reproducer: packages/rn-tester/js/examples/Playground/RNTesterPlayground.js. Checkout/build instructions are in the PR's Test Plan. The example retains every onLayout height on screen and in the console, with no animation or delayed mounting.
The original standalone App.tsx snippet remains available as supplementary context: https://gist.github.com/litinskii/3228812e0c49118fb68af23915750541
Screenshots and Videos
No response
- Lenguaje dominante
- C++
- Estrellas
- 127k
- Forks
- 25.5k
- Merge medio
- 3 d 22 h
- PR fusionados (30 d)
- 235
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de react/react-native
-
Needs: Author Feedback Needs: Repro
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
react/react-native#60059 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Needs: Triage :mag:
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
react/react-native#60000 ·
Los mantenedores suelen responder en 2 días
-
`yarn test-ios` exits before building RNTester: `objc-test.sh` launches the WebSocket server script #59433 deletedPosiblemente ocupada @lazerg la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
react/react-native#59939 ·
Los mantenedores suelen responder en 2 días
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primaryPosiblemente ocupada @alleneubank la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
react/react-native#59919 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
react/react-native#59722 ·
Los mantenedores suelen responder en 2 días
Todos los issues de react/react-native
Issues similares
-
[fuzzer-found][mlir][tosa] `TransposeOp::reifyResultShapes` crashes on unranked tensor inputAbiertocrash generated by fuzzer mlir
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
llvm/llvm-project#243218 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
petercorke/robotics-toolbox-python#943 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
realtime
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
NVIDIA/cuda-quantum#5913 ·
Los mantenedores suelen responder en 1 día
-
[hidapi] update to 0.16.0Abiertocategory:port-update
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
area:build bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
NatronGitHub/openfx-arena#71 ·
Los mantenedores suelen responder en 1 día