-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RNMobile] Fix a crash related to Reanimated when closing the editor #52320
Conversation
Seems there's some kind of incompatibility on calling a JS function from a worklet invoked from a gesture handler. For this reason, the logic to set the dropping insertion point has been updated. It now uses a Reanimated's shared value to keep the dragging over position and `useDerivedValue` hook to listen for changes.
Size Change: 0 B Total Size: 1.42 MB ℹ️ View Unchanged
|
Flaky tests detected in 7ce0719. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5462626319
|
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.
The test plan passed for me using an iPhone SE and Samsung Galaxy S20 5G FE. 🎉
I left a few comments, mostly for my own education. Please do not consider them blockers.
packages/block-editor/src/components/use-block-drop-zone/index.native.js
Show resolved
Hide resolved
packages/block-editor/src/components/use-block-drop-zone/index.native.js
Show resolved
Hide resolved
packages/block-editor/src/components/use-block-drop-zone/index.native.js
Show resolved
Hide resolved
packages/block-editor/src/components/use-block-drop-zone/index.native.js
Show resolved
Hide resolved
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.
Approving based on #52320 (review), but feel free to seek additional review before merging if desired.
Thank you @dcalhoun for reviewing the PR 🙇 , I appreciate it. I'm ok with one approval, although it would be great if @geriux could take a quick look since was originally involved in these changes, at least to confirm that this approach makes sense. Thanks! |
@dcalhoun let me know if you could also take a look at the companion Gutenberg Mobile PR. It just updates the Gutenberg reference. Thanks 🙇 ! |
Math.abs( x - prevX ) >= UPDATE_TARGET_BLOCK_INDEX_THRESHOLD || | ||
Math.abs( y - prevY ) >= UPDATE_TARGET_BLOCK_INDEX_THRESHOLD |
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.
Cool and nice approach!
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.
Changes look good to me and it works as expected 🚀 Hopefully this will fix the issue in production 🤞
Related PR: wordpress-mobile/gutenberg-mobile#5938
What?
When working on the RN upgrade 0.71.11, we spotted a very similar crash to this one. Now that it has been fixed in the RN upgrade, we could also incorporate it into
trunk
in case it solves other crashes related to Reanimated before the upgrade lands.Why?
This PR aims to fix several crashes we identified in the app, but that we couldn't reproduce back then:
How?
Seems there's some kind of incompatibility on calling a JS function from a Reanimated's worklet (reference) invoked from a gesture handler (reference). For this reason, the logic to set the dropping insertion point has been updated. It now uses a Reanimated's shared value to keep the dragging over position and
useDerivedValue
hook to listen for changes.More info about the fix can be found here.
Testing Instructions
As we couldn't find a consistent way to reproduce the Reanimated crashes, we won't be able to test that this PR fixes them. However, we can ensure that the drag & drop functionality works.
8. Observe that when dropping the block, it's added to the same position as indicated by the insertion indicator.
Testing Instructions for Keyboard
N/A
Screenshots or screencast
N/A