Commit a6e0abc
Fix Crash When Measuring Text in Stopped Surface
Summary:
`FabricUIManager.prepareTextLayout()` crashes when measuring text for a surface that has already been stopped. It looks up the surface's `ThemedReactContext` via `surfaceMountingManager.getContext()`, which returns `null` after `stopSurface()` completes.
The only thing the `Context` is used for downstream is `context.assets` (the `AssetManager`) for custom font resolution. Since `AssetManager` from the application context is equivalent for this purpose (fonts are app-global, not activity-specific), we refactor the API to pass `AssetManager` directly from `mReactApplicationContext`, eliminating the surface lookup entirely.
This also makes the API clearer: the prepared layout does not depend on activity context (e.g. for light/dark theme).
Changelog: [Android][Fixed] - Fix crash when measuring text in a stopped surface
Differential Revision: D957632521 parent 41a1941 commit a6e0abc
5 files changed
Lines changed: 30 additions & 29 deletions
File tree
- packages/react-native
- ReactAndroid/src/main/java/com/facebook/react
- fabric
- views
- textinput
- text
- ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
650 | 649 | | |
651 | 650 | | |
652 | 651 | | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
653 | 657 | | |
654 | 658 | | |
655 | 659 | | |
656 | 660 | | |
657 | | - | |
658 | 661 | | |
659 | 662 | | |
660 | 663 | | |
661 | 664 | | |
662 | 665 | | |
663 | 666 | | |
664 | | - | |
665 | | - | |
666 | 667 | | |
667 | 668 | | |
668 | 669 | | |
669 | | - | |
| 670 | + | |
670 | 671 | | |
671 | 672 | | |
672 | 673 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| |||
Lines changed: 22 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
220 | | - | |
| 221 | + | |
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
299 | | - | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| |||
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
355 | | - | |
| 356 | + | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
| |||
472 | 473 | | |
473 | 474 | | |
474 | 475 | | |
475 | | - | |
| 476 | + | |
476 | 477 | | |
477 | 478 | | |
478 | 479 | | |
| |||
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
531 | | - | |
| 532 | + | |
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
| |||
539 | 540 | | |
540 | 541 | | |
541 | 542 | | |
542 | | - | |
| 543 | + | |
543 | 544 | | |
544 | 545 | | |
545 | 546 | | |
| |||
550 | 551 | | |
551 | 552 | | |
552 | 553 | | |
553 | | - | |
| 554 | + | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
559 | | - | |
| 560 | + | |
560 | 561 | | |
561 | 562 | | |
562 | 563 | | |
| |||
568 | 569 | | |
569 | 570 | | |
570 | 571 | | |
571 | | - | |
| 572 | + | |
572 | 573 | | |
573 | 574 | | |
574 | 575 | | |
| |||
740 | 741 | | |
741 | 742 | | |
742 | 743 | | |
743 | | - | |
| 744 | + | |
744 | 745 | | |
745 | 746 | | |
746 | 747 | | |
| |||
757 | 758 | | |
758 | 759 | | |
759 | 760 | | |
760 | | - | |
| 761 | + | |
761 | 762 | | |
762 | 763 | | |
763 | 764 | | |
| |||
779 | 780 | | |
780 | 781 | | |
781 | 782 | | |
782 | | - | |
| 783 | + | |
783 | 784 | | |
784 | 785 | | |
785 | 786 | | |
786 | 787 | | |
787 | 788 | | |
788 | 789 | | |
789 | | - | |
| 790 | + | |
790 | 791 | | |
791 | 792 | | |
792 | 793 | | |
793 | 794 | | |
794 | 795 | | |
795 | | - | |
| 796 | + | |
796 | 797 | | |
797 | 798 | | |
798 | | - | |
| 799 | + | |
799 | 800 | | |
800 | 801 | | |
801 | 802 | | |
| |||
809 | 810 | | |
810 | 811 | | |
811 | 812 | | |
812 | | - | |
| 813 | + | |
| 814 | + | |
813 | 815 | | |
814 | 816 | | |
815 | 817 | | |
816 | 818 | | |
817 | 819 | | |
818 | 820 | | |
819 | 821 | | |
820 | | - | |
| 822 | + | |
821 | 823 | | |
822 | 824 | | |
823 | 825 | | |
| |||
922 | 924 | | |
923 | 925 | | |
924 | 926 | | |
925 | | - | |
| 927 | + | |
926 | 928 | | |
927 | 929 | | |
928 | 930 | | |
| |||
935 | 937 | | |
936 | 938 | | |
937 | 939 | | |
938 | | - | |
| 940 | + | |
939 | 941 | | |
940 | 942 | | |
941 | 943 | | |
| |||
945 | 947 | | |
946 | 948 | | |
947 | 949 | | |
948 | | - | |
| 950 | + | |
949 | 951 | | |
950 | 952 | | |
951 | 953 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1015 | 1015 | | |
1016 | 1016 | | |
1017 | 1017 | | |
1018 | | - | |
| 1018 | + | |
1019 | 1019 | | |
1020 | 1020 | | |
1021 | 1021 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
308 | 307 | | |
309 | 308 | | |
310 | 309 | | |
| |||
335 | 334 | | |
336 | 335 | | |
337 | 336 | | |
338 | | - | |
339 | 337 | | |
340 | 338 | | |
341 | 339 | | |
| |||
0 commit comments