[Android][Fabric] Edge-to-edge Modal first layout subtracts system insets, then jumps to full height (RN 0.87.1)
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 57/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- C++
- Estrelas
- 127k
- Forks
- 25.5k
- Merge médio
- 3d 22h
- PRs com merge (30d)
- 235
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de react/react-native
-
Needs: Author Feedback Needs: Repro
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
react/react-native#60059 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Needs: Triage :mag:
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
react/react-native#60000 ·
Mantenedores costumam responder em até 2 dias
-
`yarn test-ios` exits before building RNTester: `objc-test.sh` launches the WebSocket server script #59433 deletedTalvez já em andamento @lazerg assumiu há 4 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
react/react-native#59939 ·
Mantenedores costumam responder em até 2 dias
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primaryTalvez já em andamento @alleneubank assumiu há 6 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
react/react-native#59919 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
react/react-native#59722 ·
Mantenedores costumam responder em até 2 dias
Todas as issues de react/react-native
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
petercorke/robotics-toolbox-python#943 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
area:build bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
NatronGitHub/openfx-arena#71 ·
Mantenedores costumam responder em até 1 dia
-
upstream-watcher: Netflix/vmaf cf677baaa039 is not portedTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertaupstream-blocked
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
ROCm/FastFlowLM#1057 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
NatronGitHub/openfx-gmic#45 ·
Mantenedores costumam responder em até 1 dia