Calling invalidate in RNCMaskedView #214
Merged
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.onDescendantInvalidatedThis 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.dispatchDrawwe 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