Skip to content

Conversation

hannojg
Copy link
Member

@hannojg hannojg commented May 10, 2024

Often times this library is used next to reanimated.
In this case the worklets are transpiled by the reanimated babel plugin.
The reanimated babel plugin uses initData.sourceMap instead of RNWC current initData.__sourceMap.
This has gone unnoticed so far, cause we never checked for that property.

In this PR, which was recently merged

a check was introduced, that checks if the provided function is a worklet:

export function getWorkletDependencies(func: Function): DependencyList {
if (__DEV__) {
// In debug, perform runtime checks to ensure the given func is a safe worklet, and throw an error otherwise
const workletFunc = worklet(func);

In this function we check for the __sourceMap identifier, which won't be present when we run with reanimated.

The solution to this seems to be to use the same identifier name as in reanimated.

Without this change we will see this error with a stack where everything is a valid worklet:

Simulator Screenshot - iPhone 15 Pro Max - 2024-05-10 at 18 42 56

Fixes: #190

@hannojg hannojg requested a review from mrousavy May 10, 2024 16:46
@hannojg hannojg changed the title fix: fix compatibility when using reanimated fix: fix recent incompatibility when using reanimated May 10, 2024
Copy link
Member

@mrousavy mrousavy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.
we should probably also use the source maps somehow, no?

@ceu
Copy link

ceu commented May 13, 2024

aking the liberty of asking, roughly when will this be updated Submitted?

@hannojg hannojg linked an issue May 13, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useWorklet throws "anonymous" is not a worklet
3 participants