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

Update view tag on componentDidUpdate #4440

Merged
merged 1 commit into from
May 22, 2023
Merged

Update view tag on componentDidUpdate #4440

merged 1 commit into from
May 22, 2023

Conversation

Latropos
Copy link
Contributor

@Latropos Latropos commented May 9, 2023

Summary

Fixes #3769

Each time componentDidUpdate is triggered we have to subscribe for events again. However we used to use the same viewTag, although the viewTag may change each time the view is updated. This mean that the given view will stop receiving any events.

Look at the above-linked issue to see the description of bug in the recordings. In the console you can see viewTag used to subscribe for events. In a buggy example it doesn't change when you modify the orientation of the scroll.

BEFORE
Screen.Recording.2023-05-09.at.12.31.53.mov
AFTER
Screen.Recording.2023-05-09.at.12.32.28.mov

Test plan

Tested on example from the issue: https://snack.expo.dev/fTGYvJ2t5

@Latropos Latropos marked this pull request as ready for review May 9, 2023 11:49
@tomekzaw tomekzaw changed the title Update view tag on componendDidUpdate Update view tag on componentDidUpdate May 9, 2023
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.

Everything looks ok 👍
Did you test it with other events and with a fast refresh also? According to git blame, this changes was introduced to fix refresh problem and memory leaks:

Could you check if those changes don't break anything related to the above PR?

Could you attach the example source code to issue description?

@Latropos
Copy link
Contributor Author

@piaskowyk It looks that I've changed code from this PR: #3988, since I've modified how do we obtain viewTag. So I've tested that I am still able to fix attaching a scroll event if the scrollable component is not the root view

@Latropos Latropos requested a review from piaskowyk May 16, 2023 06:23
@Latropos
Copy link
Contributor Author

@piaskowyk I've tested with refresh control, and measured time for old and new approach. It looks that the new one is two times faster 🚀

@Latropos Latropos added this pull request to the merge queue May 22, 2023
Merged via the queue into main with commit d05b452 May 22, 2023
@Latropos Latropos deleted the acynk/update-view-tag branch May 22, 2023 11:31
fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this pull request Jun 5, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

<!-- Explain the motivation for this PR. Include "Fixes #<number>" if
applicable. -->

Fixes software-mansion#3769

Each time `componentDidUpdate` is triggered we have to subscribe for
events again. However we used to use the same viewTag, although the
viewTag may change each time the view is updated. This mean that the
given view will stop receiving any events.

Look at the above-linked issue to see the description of bug in the
recordings. In the console you can see viewTag used to subscribe for
events. In a buggy example it doesn't change when you modify the
orientation of the scroll.
<table>
<tr><td>BEFORE</td><td>


https://github.com/software-mansion/react-native-reanimated/assets/56199675/e8db724a-620f-4da1-ac44-bdc73e4d936b

</td></tr>
<tr><td>AFTER</td><td>


https://github.com/software-mansion/react-native-reanimated/assets/56199675/b2a8d2c1-0476-4ddf-b543-b7c0b768389e


</td></tr>
</table>  

## Test plan

<!-- Provide a minimal but complete code snippet that can be used to
test out this change along with instructions how to run it and a
description of the expected behavior. -->
Tested on example from the issue: https://snack.expo.dev/fTGYvJ2t5

Co-authored-by: Aleksandra Cynk <aleksandracynk@swmansion.com>
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.

[Android] animated scroll handler breaks when changing ScrollView's horizontal prop
2 participants