Skip to content

Commit

Permalink
Fix incorrect type being passed to NativePerformance.mark (facebook#4…
Browse files Browse the repository at this point in the history
…7102)

Summary:

Changelog: [internal]

In D64466057 / facebook@32f7b3b we accidentally modified the API of `NativePerformance.mark` (which we wanted to preserve and move the changes to `NativePerformance.markWithResult` after some iteration) to make `startTime` optional. This change isn't OTA safe and no automated systems caught this problem.

This fixes the issue by reverting the type back to being required and always passing it from the JS API.

Differential Revision: D64557467
  • Loading branch information
rubennorte authored and facebook-github-bot committed Oct 17, 2024
1 parent d11954e commit 3a24226
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ export default class Performance {
markOptions?.startTime,
);
} else if (NativePerformance?.mark) {
NativePerformance.mark(markName, markOptions?.startTime);
computedStartTime = markOptions?.startTime ?? performance.now();
NativePerformance?.mark?.(markName, computedStartTime);
} else {
warnNoNativePerformance();
computedStartTime = performance.now();
}

return new PerformanceMark(markName, {
startTime: computedStartTime ?? performance.now(),
startTime: computedStartTime,
detail: markOptions?.detail,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type PerformanceObserverInit = {
export interface Spec extends TurboModule {
+now?: () => number;
// TODO: remove when `markWithResult` is fully rolled out.
+mark?: (name: string, startTime?: number) => void;
+mark?: (name: string, startTime: number) => void;
// TODO: remove when `measureWithResult` is fully rolled out.
+measure?: (
name: string,
Expand Down

0 comments on commit 3a24226

Please sign in to comment.