Skip to content

Conversation

@rshest
Copy link
Contributor

@rshest rshest commented Jun 14, 2023

Summary:

Changelist

[Internal] -

There was one particular permutation of input arguments to Performance.measure that wasn't handled correctly on the native side, namely when there is only the start mark argument present, but not the end time/mark, e.g.:

Performance.measure('myMeasure', 'someStartMark');

In this case, according to the standard, the end time should be taken as the current one:

The end timestamp is one of:
...
-the value returned by Performance.now(), if no end mark is specified or can be determined from other values.

It was taken as 0 instead, making the total duration negative and consequently getting it filtered out by the default durationThreshold of 0.

I've added a corresponding missing clause in the native unit tests. This also required a slight extension to the PerformanceObserver API to allow for mocking the current timestamp provider.

Differential Revision: D46728261

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Jun 14, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46728261

… correctly (facebook#37888)

Summary:
Pull Request resolved: facebook#37888

# Changelog:
[Internal] -

There was one particular permutation of input arguments to `Performance.measure` that wasn't handled correctly on the native side, namely when there is only the start mark argument present, but not the end time/mark, e.g.:
```
Performance.measure('myMeasure', 'someStartMark');
```

In this case, [according to the standard](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure), the end time should be taken as the current one:
> The end timestamp is one of:
> ...
>  -the value returned by Performance.now(), if no end mark is specified or can be determined from other values.

It was taken as 0 instead, making the total duration negative and consequently getting it filtered out by the default `durationThreshold` of 0.

I've added a corresponding missing clause in the native unit tests. This also required a slight extension to the `PerformanceObserver` API to allow for mocking the current timestamp provider.

Reviewed By: rubennorte

Differential Revision: D46728261

fbshipit-source-id: fcfcb355d13ce90babceeac398b53de914f1eb35
@rshest rshest force-pushed the export-D46728261 branch from 78ca878 to 2ef1723 Compare June 14, 2023 16:55
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46728261

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,757,664 -5
android hermes armeabi-v7a 8,070,235 -2
android hermes x86 9,250,263 -2
android hermes x86_64 9,099,402 -4
android jsc arm64-v8a 9,318,867 -3
android jsc armeabi-v7a 8,508,770 -3
android jsc x86 9,382,360 -2
android jsc x86_64 9,635,605 -1

Base commit: b3cc19c
Branch: main

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 14, 2023
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 4475572.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants