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

Unfreeze UI objects 🥶 -> 😎 #4401

Merged
merged 1 commit into from
Apr 27, 2023
Merged

Conversation

piaskowyk
Copy link
Member

@piaskowyk piaskowyk commented Apr 24, 2023

Summary

The goal of freezing is to freeze JS objects used on the UI thread. But we don't need and don't want to freeze objects used only on the UI thread.

Test plan

  const sv1 = useSharedValue([0]);
  const sv2 = useSharedValue({ prop: [0] });
  runOnUI(() => {
    'worklet';
    sv1.value[0]++;
    sv2.value.prop[0]++;
    console.log(sv1.value, sv2.value.prop, Object.isFrozen(sv1.value));
  })()

Output before:

 LOG  RENDER -----------------------------------
 LOG  [1] [1] false
 LOG  RENDER -----------------------------------
 LOG  [1] [1] true
 LOG  RENDER -----------------------------------
 LOG  [1] [1] true

Output after:

 LOG  RENDER -----------------------------------
 LOG  [1] [1] false
 LOG  RENDER -----------------------------------
 LOG  [2] [2] false
 LOG  RENDER -----------------------------------
 LOG  [3] [3] false

@piaskowyk piaskowyk changed the title Unfreeze UI objects Unfreeze UI objects 🥶 Apr 24, 2023
@piaskowyk piaskowyk changed the title Unfreeze UI objects 🥶 Unfreeze UI objects 🥶 -> 😎 Apr 24, 2023
@tjzel
Copy link
Contributor

tjzel commented Apr 25, 2023

🥶 🍨

@piaskowyk piaskowyk marked this pull request as ready for review April 27, 2023 08:59
@piaskowyk piaskowyk added this pull request to the merge queue Apr 27, 2023
Merged via the queue into main with commit cac0930 Apr 27, 2023
1 check passed
@piaskowyk piaskowyk deleted the @piaskowyk/unfreez-ui-object branch April 27, 2023 09:00
fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this pull request Jun 5, 2023
## Summary

The goal of freezing is to freeze JS objects used on the UI thread. But
we don't need and don't want to freeze objects used only on the UI
thread.

## Test plan

```js
  const sv1 = useSharedValue([0]);
  const sv2 = useSharedValue({ prop: [0] });
  runOnUI(() => {
    'worklet';
    sv1.value[0]++;
    sv2.value.prop[0]++;
    console.log(sv1.value, sv2.value.prop, Object.isFrozen(sv1.value));
  })()
```

Output before:
```
 LOG  RENDER -----------------------------------
 LOG  [1] [1] false
 LOG  RENDER -----------------------------------
 LOG  [1] [1] true
 LOG  RENDER -----------------------------------
 LOG  [1] [1] true
```

Output after:
```
 LOG  RENDER -----------------------------------
 LOG  [1] [1] false
 LOG  RENDER -----------------------------------
 LOG  [2] [2] false
 LOG  RENDER -----------------------------------
 LOG  [3] [3] false
```
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.

None yet

3 participants