Page MenuHomePhabricator

[native] Avoid calling invariant from worklet
ClosedPublic

Authored by ashoat on Jan 5 2024, 7:12 AM.
Tags
None
Referenced Files
F3400807: D10554.id35294.diff
Mon, Dec 2, 9:00 AM
F3400803: D10554.id35295.diff
Mon, Dec 2, 8:59 AM
F3400257: D10554.diff
Mon, Dec 2, 6:48 AM
Unknown Object (File)
Fri, Nov 8, 2:59 AM
Unknown Object (File)
Fri, Nov 8, 2:58 AM
Unknown Object (File)
Oct 31 2024, 1:53 AM
Unknown Object (File)
Oct 3 2024, 10:51 AM
Unknown Object (File)
Oct 3 2024, 10:51 AM
Subscribers

Details

Summary

While working on testing D10553, I noticed the following error:

Screenshot 2024-01-05 at 9.55.20 AM.png (2×1 px, 1 MB)

This regression was caused by my changes in D10004. I added an invariant to satisfy Flow there, but I didn't consider that I was adding a function call to a worklet. Reanimated worklets can only call other functions that are worklets; otherwise, the call should be proxied via runOnJS.

This diff updates the call to just throw new Error instance, which works just as well for Flow. I'm not sure if using Error within a worklet will cause an issue, but it shouldn't matter because the control flow should never enter this conditional, and if it does then we're going to be erroring anyways.

Test Plan

Before this diff, swiping a message would trigger the error in the screenshot above. After this diff, the error is no longer triggered.

Diff Detail

Repository
rCOMM Comm
Branch
ashoat/worklet-invariant
Lint
No Lint Coverage
Unit
No Test Coverage