Commit a5297ec
authored
Don't flush synchronous work if we're in the middle of a ViewTransition async sequence (facebook#32760)
Starting a View Transition is an async sequence. Since React can get a
sync update in the middle of sequence we sometimes interrupt that
sequence.
Currently, we don't actually cancel the View Transition so it can just
run as a partial. This ensures that we fully skip it when that happens,
as well as warn.
However, it's very easy to trigger this with just a setState in
useLayoutEffect right now. Therefore if we're inside the preparing
sequence of a startViewTransition, this delays work that would've
normally flushed in a microtask. ~Maybe we want to do the same for
Default work already scheduled through a scheduler Task.~ Edit: This was
already done.
`flushSync` currently will still lead to an interrupted View Transition
(with a warning). There's a tradeoff here whether we want to try our
best to preserve the guarantees of `flushSync` or favor the animation.
It's already possible to suspend at the root with `flushSync` which
means it's not always 100% guaranteed to commit anyway. We could treat
it as suspended. But let's see how much this is a problem in practice.1 parent 2541146 commit a5297ec
File tree
11 files changed
+110
-46
lines changed- fixtures/view-transition/src/components
- packages
- react-art/src
- react-dom-bindings/src/client
- react-native-renderer/src
- react-noop-renderer/src
- react-reconciler/src
- forks
- react-test-renderer/src
11 files changed
+110
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
541 | | - | |
| 541 | + | |
542 | 542 | | |
543 | 543 | | |
544 | | - | |
| 544 | + | |
545 | 545 | | |
546 | | - | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
547 | 549 | | |
548 | | - | |
| 550 | + | |
549 | 551 | | |
550 | 552 | | |
551 | 553 | | |
| |||
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1687 | 1687 | | |
1688 | 1688 | | |
1689 | 1689 | | |
1690 | | - | |
| 1690 | + | |
1691 | 1691 | | |
1692 | 1692 | | |
1693 | 1693 | | |
| |||
1764 | 1764 | | |
1765 | 1765 | | |
1766 | 1766 | | |
1767 | | - | |
| 1767 | + | |
1768 | 1768 | | |
1769 | 1769 | | |
1770 | 1770 | | |
1771 | 1771 | | |
1772 | 1772 | | |
1773 | 1773 | | |
1774 | 1774 | | |
1775 | | - | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
1776 | 1782 | | |
1777 | 1783 | | |
1778 | 1784 | | |
1779 | | - | |
| 1785 | + | |
1780 | 1786 | | |
1781 | 1787 | | |
1782 | 1788 | | |
| |||
1900 | 1906 | | |
1901 | 1907 | | |
1902 | 1908 | | |
1903 | | - | |
| 1909 | + | |
1904 | 1910 | | |
1905 | 1911 | | |
1906 | 1912 | | |
| |||
2072 | 2078 | | |
2073 | 2079 | | |
2074 | 2080 | | |
2075 | | - | |
| 2081 | + | |
2076 | 2082 | | |
2077 | 2083 | | |
2078 | 2084 | | |
| |||
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
656 | | - | |
657 | | - | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
658 | 663 | | |
659 | 664 | | |
660 | | - | |
| 665 | + | |
661 | 666 | | |
662 | 667 | | |
663 | 668 | | |
| |||
668 | 673 | | |
669 | 674 | | |
670 | 675 | | |
671 | | - | |
| 676 | + | |
672 | 677 | | |
673 | 678 | | |
674 | 679 | | |
675 | 680 | | |
676 | 681 | | |
677 | | - | |
| 682 | + | |
678 | 683 | | |
679 | 684 | | |
680 | 685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
830 | 829 | | |
| 830 | + | |
| 831 | + | |
831 | 832 | | |
832 | 833 | | |
833 | | - | |
834 | | - | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
835 | 841 | | |
836 | 842 | | |
837 | 843 | | |
| |||
843 | 849 | | |
844 | 850 | | |
845 | 851 | | |
846 | | - | |
| 852 | + | |
847 | 853 | | |
848 | 854 | | |
849 | 855 | | |
850 | 856 | | |
851 | 857 | | |
852 | | - | |
| 858 | + | |
853 | 859 | | |
854 | 860 | | |
855 | 861 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
Lines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 11 | + | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
| |||
21 | 18 | | |
22 | 19 | | |
23 | 20 | | |
24 | | - | |
| 21 | + | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
| |||
33 | 30 | | |
34 | 31 | | |
35 | 32 | | |
36 | | - | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
| |||
144 | 141 | | |
145 | 142 | | |
146 | 143 | | |
147 | | - | |
| 144 | + | |
148 | 145 | | |
149 | 146 | | |
150 | 147 | | |
| |||
183 | 180 | | |
184 | 181 | | |
185 | 182 | | |
186 | | - | |
| 183 | + | |
187 | 184 | | |
188 | 185 | | |
189 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
314 | 319 | | |
315 | 320 | | |
316 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
665 | 670 | | |
666 | 671 | | |
667 | 672 | | |
| 673 | + | |
668 | 674 | | |
669 | 675 | | |
670 | 676 | | |
| |||
3503 | 3509 | | |
3504 | 3510 | | |
3505 | 3511 | | |
3506 | | - | |
3507 | | - | |
3508 | | - | |
3509 | | - | |
| 3512 | + | |
| 3513 | + | |
3510 | 3514 | | |
3511 | 3515 | | |
3512 | 3516 | | |
| |||
3516 | 3520 | | |
3517 | 3521 | | |
3518 | 3522 | | |
3519 | | - | |
| 3523 | + | |
3520 | 3524 | | |
3521 | 3525 | | |
3522 | 3526 | | |
| |||
3646 | 3650 | | |
3647 | 3651 | | |
3648 | 3652 | | |
| 3653 | + | |
| 3654 | + | |
3649 | 3655 | | |
3650 | 3656 | | |
3651 | 3657 | | |
| |||
3915 | 3921 | | |
3916 | 3922 | | |
3917 | 3923 | | |
3918 | | - | |
| 3924 | + | |
3919 | 3925 | | |
3920 | 3926 | | |
3921 | 3927 | | |
| |||
3975 | 3981 | | |
3976 | 3982 | | |
3977 | 3983 | | |
| 3984 | + | |
| 3985 | + | |
3978 | 3986 | | |
3979 | 3987 | | |
3980 | 3988 | | |
| |||
4025 | 4033 | | |
4026 | 4034 | | |
4027 | 4035 | | |
| 4036 | + | |
| 4037 | + | |
4028 | 4038 | | |
4029 | 4039 | | |
| 4040 | + | |
| 4041 | + | |
| 4042 | + | |
| 4043 | + | |
| 4044 | + | |
| 4045 | + | |
| 4046 | + | |
| 4047 | + | |
| 4048 | + | |
| 4049 | + | |
| 4050 | + | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
4030 | 4057 | | |
4031 | 4058 | | |
4032 | 4059 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
0 commit comments