Skip to content
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

fix(Camera.tsx): processor calling stale worklet and callback #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tastydev
Copy link

This fixes a huge bug when depending on state values inside the callback of the frameProcessor. As the frameProcessor had an empty dependency array it always called a stale function identity callback of the worklet which got passed initially.

I.E callback prop calls a function which holds an if clause which depends on a useState value, it has never seen the new useState value if it changed as the new identity/recreated callback function would not be used inside the worklet and frameProcessor.

This fix is important to prevent confusion. I had to debug it for 4 hrs :P

This fixes a huge bug when depending on state values inside the callback of the frameProcessor. As the frameProcessor had an empty dependency array it always called a stale function identity callback of the worklet which got passed initially.

I.E onCallback calls a function which holds an if clause which depends on a useState value it has never seen the new useState value if it changed as the new identity/recreated callback function would not be used inside the Worklet and frameProcessor
@gev2002
Copy link
Owner

gev2002 commented Oct 31, 2024

Hello @tastydev . Thanks for your support of the package, but I can't merge it now, I'll do a review later.

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.

2 participants