-
Notifications
You must be signed in to change notification settings - Fork 124
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
Calling invalidate in RNCMaskedView #214
Merged
Naturalclar
merged 1 commit into
react-native-masked-view:master
from
koplyarov:call-invalidate-in-masked-view
Dec 11, 2023
Merged
Calling invalidate in RNCMaskedView #214
Naturalclar
merged 1 commit into
react-native-masked-view:master
from
koplyarov:call-invalidate-in-masked-view
Dec 11, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FonDorn
approved these changes
Dec 10, 2023
Hey @Naturalclar. Can you merge these changes and make a new version? |
Naturalclar
approved these changes
Dec 11, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Released v0.3.1 🚀 |
renovate bot
referenced
this pull request
in valora-inc/wallet
Dec 14, 2023
… ^0.3.1 (#4636) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@react-native-masked-view/masked-view](https://togithub.com/react-native-masked-view/masked-view) | [`^0.3.0` -> `^0.3.1`](https://renovatebot.com/diffs/npm/@react-native-masked-view%2fmasked-view/0.3.0/0.3.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@react-native-masked-view%2fmasked-view/0.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@react-native-masked-view%2fmasked-view/0.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@react-native-masked-view%2fmasked-view/0.3.0/0.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@react-native-masked-view%2fmasked-view/0.3.0/0.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>react-native-masked-view/masked-view (@​react-native-masked-view/masked-view)</summary> ### [`v0.3.1`](https://togithub.com/react-native-masked-view/masked-view/releases/tag/v0.3.1) [Compare Source](https://togithub.com/react-native-masked-view/masked-view/compare/v0.3.0...v0.3.1) #### What's Changed - Calling invalidate in RNCMaskedView by [@​koplyarov](https://togithub.com/koplyarov) in [https://github.com/react-native-masked-view/masked-view/pull/214](https://togithub.com/react-native-masked-view/masked-view/pull/214) #### New Contributors - [@​koplyarov](https://togithub.com/koplyarov) made their first contribution in [https://github.com/react-native-masked-view/masked-view/pull/214](https://togithub.com/react-native-masked-view/masked-view/pull/214) **Full Changelog**: react-native-masked-view/masked-view@v0.3.0...v0.3.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone America/Los_Angeles. 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/valora-inc/wallet). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44Ny4yIiwidXBkYXRlZEluVmVyIjoiMzcuODcuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: valora-bot <valorabot@valoraapp.com>
@koplyarov thx for fixing it ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request adds an
invalidate()
call toRNCMaskedView.onDescendantInvalidated
This addresses the following issue: sometimes, the MaskedView would display a stale content even though React re-render happened in one of the children
Details
As far as I understand, the issue was happening because in
RNCMaskedView.dispatchDraw
we would render the content of the masked view into an off-screen buffer (link) before the children would have been re-drawn (link), and later the offscreen buffer would be used by the hardware rendering even though it contains a stale snapshot of the children.A simple solution is to invalidate the masked view whenever a child is invalidated. This causes an additional
draw()
call to be scheduled for the parent view, and it gets handled at the point where the children have been already updated.Pros: It's simple and it works. 🙂
Cons: It triggers an additional draw where we basically re-render all children into the off-screen buffer. Though it seems that it was being redrawn even more often before #98, so I guess it's acceptable. 🤷♂️
Test Plan
Video: https://youtu.be/4XI00oGdgQ0
Before the change: Sometimes, the MaskedView would display a stale content even though React re-render happened in one of the children
After the change: Now the MaskedView displays the updated children correctly