608
609
if (gate(flags => flags.enableSchedulingProfiler)) {
610
expect(getMarks()).toMatchInlineSnapshot(`
611
- Array [
612
- "--render-start-16",
613
- "--component-render-start-Example",
614
- "--component-render-stop",
615
- "--render-stop",
616
- "--commit-start-16",
617
- "--react-version-17.0.3",
618
- "--profiler-version-1",
619
- "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
620
- "--layout-effects-start-16",
621
- "--schedule-state-update-1-Example",
622
- "--layout-effects-stop",
623
- "--render-start-1",
624
- "--component-render-start-Example",
625
- "--component-render-stop",
626
- "--render-stop",
627
- "--commit-start-1",
628
- "--react-version-17.0.3",
629
- "--profiler-version-1",
630
- "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
631
- "--commit-stop",
632
- "--commit-stop",
633
- ]
634
- `);
611
+ Array [
612
+ "--render-start-16",
613
+ "--component-render-start-Example",
614
+ "--component-render-stop",
615
+ "--render-stop",
616
+ "--commit-start-16",
617
+ "--react-version-17.0.3",
618
+ "--profiler-version-1",
619
+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
620
+ "--layout-effects-start-16",
621
+ "--component-layout-effect-mount-start-Example",
622
+ "--schedule-state-update-1-Example",
623
+ "--component-layout-effect-mount-stop",
624
+ "--layout-effects-stop",
625
+ "--render-start-1",
626
+ "--component-render-start-Example",
627
+ "--component-render-stop",
628
+ "--render-stop",
629
+ "--commit-start-1",
630
+ "--react-version-17.0.3",
631
+ "--profiler-version-1",
632
+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
633
+ "--commit-stop",
634
+ "--commit-stop",
635
+ ]
636
+ `);
637
}
638
});
639
654
655
if (gate(flags => flags.enableSchedulingProfiler)) {
656
expect(getMarks()).toMatchInlineSnapshot(`
655
- Array [
656
- "--schedule-render-16",
657
- "--render-start-16",
658
- "--component-render-start-Example",
659
- "--component-render-stop",
660
- "--render-stop",
661
- "--commit-start-16",
662
- "--react-version-17.0.3",
663
- "--profiler-version-1",
664
- "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
665
- "--layout-effects-start-16",
666
- "--layout-effects-stop",
667
- "--commit-stop",
668
- "--passive-effects-start-16",
669
- "--schedule-state-update-16-Example",
670
- "--passive-effects-stop",
671
- "--render-start-16",
672
- "--component-render-start-Example",
673
- "--component-render-stop",
674
- "--render-stop",
675
- "--commit-start-16",
676
- "--react-version-17.0.3",
677
- "--profiler-version-1",
678
- "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
679
- "--commit-stop",
680
- ]
681
- `);
657
+ Array [
658
+ "--schedule-render-16",
659
+ "--render-start-16",
660
+ "--component-render-start-Example",
661
+ "--component-render-stop",
662
+ "--render-stop",
663
+ "--commit-start-16",
664
+ "--react-version-17.0.3",
665
+ "--profiler-version-1",
666
+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
667
+ "--layout-effects-start-16",
668
+ "--layout-effects-stop",
669
+ "--commit-stop",
670
+ "--passive-effects-start-16",
671
+ "--component-passive-effect-mount-start-Example",
672
+ "--schedule-state-update-16-Example",
673
+ "--component-passive-effect-mount-stop",
674
+ "--passive-effects-stop",
675
+ "--render-start-16",
676
+ "--component-render-start-Example",
677
+ "--component-render-stop",
678
+ "--render-stop",
679
+ "--commit-start-16",
680
+ "--react-version-17.0.3",
681
+ "--profiler-version-1",
682
+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
683
+ "--commit-stop",
684
+ ]
685
+ `);
686
}
687
});
688
858
`);
859
}
860
});
861
+
862
+ it('should mark passive and layout effects', async () => {
863
+ function ComponentWithEffects() {
864
+ React.useLayoutEffect(() => {
865
+ Scheduler.unstable_yieldValue('layout 1 mount');
866
+ return () => {
867
+ Scheduler.unstable_yieldValue('layout 1 unmount');
868
+ };
869
+ }, []);
870
+
871
+ React.useEffect(() => {
872
+ Scheduler.unstable_yieldValue('passive 1 mount');
873
+ return () => {
874
+ Scheduler.unstable_yieldValue('passive 1 unmount');
875
+ };
876
+ }, []);
877
+
878
+ React.useLayoutEffect(() => {
879
+ Scheduler.unstable_yieldValue('layout 2 mount');
880
+ return () => {
881
+ Scheduler.unstable_yieldValue('layout 2 unmount');
882
+ };
883
+ }, []);
884
+
885
+ React.useEffect(() => {
886
+ Scheduler.unstable_yieldValue('passive 2 mount');
887
+ return () => {
888
+ Scheduler.unstable_yieldValue('passive 2 unmount');
889
+ };
890
+ }, []);
891
+
892
+ React.useEffect(() => {
893
+ Scheduler.unstable_yieldValue('passive 3 mount');
894
+ return () => {
895
+ Scheduler.unstable_yieldValue('passive 3 unmount');
896
+ };
897
+ }, []);
898
+
899
+ return null;
900
+ }
901
+
902
+ const renderer = ReactTestRenderer.create(<ComponentWithEffects />, {
903
+ unstable_isConcurrent: true,
904
+ });
905
+
906
+ expect(Scheduler).toFlushUntilNextPaint([
907
+ 'layout 1 mount',
908
+ 'layout 2 mount',
909
+ ]);
910
+
911
+ if (gate(flags => flags.enableSchedulingProfiler)) {
912
+ expect(getMarks()).toMatchInlineSnapshot(`
913
+ Array [
914
+ "--schedule-render-16",
915
+ "--render-start-16",
916
+ "--component-render-start-ComponentWithEffects",
917
+ "--component-render-stop",
918
+ "--render-stop",
919
+ "--commit-start-16",
920
+ "--react-version-17.0.3",
921
+ "--profiler-version-1",
922
+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
923
+ "--layout-effects-start-16",
924
+ "--component-layout-effect-mount-start-ComponentWithEffects",
925
+ "--component-layout-effect-mount-stop",
926
+ "--component-layout-effect-mount-start-ComponentWithEffects",
927
+ "--component-layout-effect-mount-stop",
928
+ "--layout-effects-stop",
929
+ "--commit-stop",
930
+ ]
931
+ `);
932
+ }
933
+
934
+ clearPendingMarks();
935
+
936
+ expect(Scheduler).toFlushAndYield([
937
+ 'passive 1 mount',
938
+ 'passive 2 mount',
939
+ 'passive 3 mount',
940
+ ]);
941
+
942
+ if (gate(flags => flags.enableSchedulingProfiler)) {
943
+ expect(getMarks()).toMatchInlineSnapshot(`
944
+ Array [
945
+ "--passive-effects-start-16",
946
+ "--component-passive-effect-mount-start-ComponentWithEffects",
947
+ "--component-passive-effect-mount-stop",
948
+ "--component-passive-effect-mount-start-ComponentWithEffects",
949
+ "--component-passive-effect-mount-stop",
950
+ "--component-passive-effect-mount-start-ComponentWithEffects",
951
+ "--component-passive-effect-mount-stop",
952
+ "--passive-effects-stop",
953
+ ]
954
+ `);
955
+ }
956
+
957
+ clearPendingMarks();
958
+
959
+ renderer.unmount();
960
+
961
+ expect(Scheduler).toFlushAndYield([
962
+ 'layout 1 unmount',
963
+ 'layout 2 unmount',
964
+ 'passive 1 unmount',
965
+ 'passive 2 unmount',
966
+ 'passive 3 unmount',
967
+ ]);
968
+
969
+ if (gate(flags => flags.enableSchedulingProfiler)) {
970
+ expect(getMarks()).toMatchInlineSnapshot(`
971
+ Array [
972
+ "--schedule-render-16",
973
+ "--render-start-16",
974
+ "--render-stop",
975
+ "--commit-start-16",
976
+ "--react-version-17.0.3",
977
+ "--profiler-version-1",
978
+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
979
+ "--component-layout-effect-unmount-start-ComponentWithEffects",
980
+ "--component-layout-effect-unmount-stop",
981
+ "--component-layout-effect-unmount-start-ComponentWithEffects",
982
+ "--component-layout-effect-unmount-stop",
983
+ "--layout-effects-start-16",
984
+ "--layout-effects-stop",
985
+ "--commit-stop",
986
+ "--passive-effects-start-16",
987
+ "--component-passive-effect-unmount-start-ComponentWithEffects",
988
+ "--component-passive-effect-unmount-stop",
989
+ "--component-passive-effect-unmount-start-ComponentWithEffects",
990
+ "--component-passive-effect-unmount-stop",
991
+ "--component-passive-effect-unmount-start-ComponentWithEffects",
992
+ "--component-passive-effect-unmount-stop",
993
+ "--passive-effects-stop",
994
+ ]
995
+ `);
996
+ }
997
+ });
998
});