Page MenuHomePhabricator

[native] Avoid calling invariant from worklet
ClosedPublic

Authored by ashoat on Jan 5 2024, 7:12 AM.
Tags
None
Referenced Files
F2776757: D10554.diff
Fri, Sep 20, 6:19 AM
Unknown Object (File)
Tue, Sep 3, 4:44 AM
Unknown Object (File)
Sat, Aug 31, 10:26 PM
Unknown Object (File)
Thu, Aug 29, 6:56 AM
Unknown Object (File)
Thu, Aug 29, 6:55 AM
Unknown Object (File)
Thu, Aug 29, 6:55 AM
Unknown Object (File)
Thu, Aug 29, 6:55 AM
Unknown Object (File)
Wed, Aug 28, 4:57 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable