Repository navigation
Commit 9a4ef4d
authored
Initialize display metrics before reading them in ReactHostImpl.onConfigurationChanged (#60054)
Summary:
**Problem:** A configuration change, such as a light/dark mode switch, can crash the app with `IllegalStateException: DisplayMetricsHolder must be initialized` while a `ReactHost` is still starting.
**Reproduction:** Start a `ReactHost` without an attached surface, then switch the system dark mode before the `ReactInstance` finishes construction.
**Fix:** `ReactHostImpl.onConfigurationChanged` now initializes the display metrics if they are not set yet. It does this before it reads the previous font scale. When the metrics were not set, the old and new font scales match, so no relayout is requested. Behavior after a full start does not change.
Changelog:
[Android][Fixed] - Fix `IllegalStateException` from `DisplayMetricsHolder` when a configuration change arrives while a `ReactHost` is still starting
Reviewed By: rubennorte
Differential Revision: D129827368
Pull Request resolved: #600541 parent 4a82359 commit 9a4ef4d
2 files changed
Lines changed: 19 additions & 0 deletions
File tree
- packages/react-native/ReactAndroid/src
- main/java/com/facebook/react/runtime
- test/java/com/facebook/react/runtime
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| 736 | + | |
| 737 | + | |
736 | 738 | | |
737 | 739 | | |
738 | 740 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
205 | 222 | | |
0 commit comments