@@ -60,43 +60,38 @@ export function prepareProfilingDataFrontendFromBackendAndStore(
60
60
throw Error ( `Could not find profiling snapshots for root ${ rootID } ` ) ;
61
61
}
62
62
63
- const filteredCommitData = [ ] ;
64
- const filteredOperations = [ ] ;
65
-
66
- // Filter empty commits from the profiler data.
67
- // It is very important to keep operations and commit data arrays perfect in sync.
68
- // So we must use the same criteria to filter both.
69
- // If these two arrays were to get out of sync, the profiler would runtime error.
70
- // We choose to filter on commit metadata, rather than the operations array,
71
- // because the latter may have false positives,
72
- // (e.g. a commit that re-rendered a component with the same treeBaseDuration as before).
73
- commitData . forEach ( ( commitDataBackend , commitIndex ) => {
74
- if ( commitDataBackend . fiberActualDurations . length > 0 ) {
75
- filteredCommitData . push ( {
76
- changeDescriptions :
77
- commitDataBackend . changeDescriptions != null
78
- ? new Map ( commitDataBackend . changeDescriptions )
79
- : null ,
80
- duration : commitDataBackend . duration ,
81
- fiberActualDurations : new Map (
82
- commitDataBackend . fiberActualDurations ,
83
- ) ,
84
- fiberSelfDurations : new Map ( commitDataBackend . fiberSelfDurations ) ,
85
- interactionIDs : commitDataBackend . interactionIDs ,
86
- priorityLevel : commitDataBackend . priorityLevel ,
87
- timestamp : commitDataBackend . timestamp ,
88
- } ) ;
89
- filteredOperations . push ( operations [ commitIndex ] ) ;
90
- }
91
- } ) ;
63
+ // Do not filter empty commits from the profiler data!
64
+ // We used to do this, but it was error prone (see #18798).
65
+ // A commit may appear to be empty (no actual durations) because of component filters,
66
+ // but filtering these empty commits causes interaction commit indices to be off by N.
67
+ // This not only corrupts the resulting data, but also potentially causes runtime errors.
68
+ //
69
+ // For that matter, hiding "empty" commits might cause confusion too.
70
+ // A commit *did happen* even if none of the components the Profiler is showing were involved.
71
+ const convertedCommitData = commitData . map (
72
+ ( commitDataBackend , commitIndex ) => ( {
73
+ changeDescriptions :
74
+ commitDataBackend . changeDescriptions != null
75
+ ? new Map ( commitDataBackend . changeDescriptions )
76
+ : null ,
77
+ duration : commitDataBackend . duration ,
78
+ fiberActualDurations : new Map (
79
+ commitDataBackend . fiberActualDurations ,
80
+ ) ,
81
+ fiberSelfDurations : new Map ( commitDataBackend . fiberSelfDurations ) ,
82
+ interactionIDs : commitDataBackend . interactionIDs ,
83
+ priorityLevel : commitDataBackend . priorityLevel ,
84
+ timestamp : commitDataBackend . timestamp ,
85
+ } ) ,
86
+ ) ;
92
87
93
88
dataForRoots . set ( rootID , {
94
- commitData : filteredCommitData ,
89
+ commitData : convertedCommitData ,
95
90
displayName,
96
91
initialTreeBaseDurations : new Map ( initialTreeBaseDurations ) ,
97
92
interactionCommits : new Map ( interactionCommits ) ,
98
93
interactions : new Map ( interactions ) ,
99
- operations : filteredOperations ,
94
+ operations,
100
95
rootID,
101
96
snapshots,
102
97
} ) ;
0 commit comments