Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not mock global.performance when connected to chrome debugger #2761

Merged
merged 2 commits into from Dec 17, 2021

Conversation

michaelknoch
Copy link
Contributor

Description

Description and motivation for this PR.
global._chronoNow doesn't seem to be defined when connected to chrome debugger but global.performance is defined already. So I think there is no need to mock in that case.

Fixes #2760

Changes

do not mock global.performance when connected to chrome debugger (same behaviour as for web)

Checklist

  • Included code example that can be used to test this change
  • Updated TS types
  • Added TS types tests
  • Added unit / integration tests
  • Updated documentation
  • Ensured that CI passes

@@ -371,7 +371,7 @@ if (!NativeReanimatedModule.useOnlyV1) {
: (workletValueSetterJS as <T>(value: T) => void)
);

if (!isWeb() && isConfigured()) {
if (!isWeb() && !isChromeDebugger() && isConfigured()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know much about the console mocking here, we could also just mock global.performance if really needed:

if (!global.performance && global._chronoNow) {
        global.performance = {
            now: global._chronoNow,
        }
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even without chrome debugger global.performance and global._chronoNow seem both to be undefined. should we remove the mock in general? I can't see any purpose for it (tested on iOS, maybe things are different on android)

@michaelknoch
Copy link
Contributor Author

would be great to get your opinion on this @piaskowyk, because as far as I can see you recently worked in that area

@piaskowyk piaskowyk self-requested a review December 17, 2021 20:53
@piaskowyk piaskowyk self-assigned this Dec 17, 2021
@piaskowyk
Copy link
Member

Hey @michaelknoch 👋
You are right, I am glad that you fix it! Thanks!

Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@piaskowyk piaskowyk merged commit 25bf9a3 into software-mansion:main Dec 17, 2021
mrousavy added a commit to mrousavy/react-native-reanimated that referenced this pull request Dec 20, 2021
piaskowyk pushed a commit that referenced this pull request Dec 22, 2021
aeddi pushed a commit to aeddi/react-native-reanimated that referenced this pull request Mar 22, 2022
…tware-mansion#2761)

## Description

Description and motivation for this PR.
`global._chronoNow` doesn't seem to be defined when connected to chrome debugger but `global.performance` is defined already. So I think there is no need to mock in that case.

Fixes software-mansion#2760

## Changes
do not mock `global.performance` when connected to chrome debugger (same behaviour as for web)

<!--

## Screenshots / GIFs


<img width="495" alt="Screenshot 2021-12-17 at 12 48 34" src="https://user-images.githubusercontent.com/5617793/146547028-4f6e6b73-154c-4f31-8b59-5ddae9c1e024.png">

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before

### After

-->


## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
aeddi pushed a commit to aeddi/react-native-reanimated that referenced this pull request Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

global.performance.now is not a function
2 participants