-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: race condition with frame callbacks #6301
Conversation
/cc @szydlovsky - not sure if #6143 is the cause here |
And this is our usage of useFrameCallback - https://github.com/PedroBern/react-native-collapsible-tab-view/blob/main/src/Container.tsx#L224-L236 and https://github.com/PedroBern/react-native-collapsible-tab-view/blob/main/src/Container.tsx#L261 |
@andreialecu @AndreiCalazans It is hard to tell what caused such issue. The cleanup was definitely faulty, as it might have tried to read a useEffect(() => {
ref.current.callbackId =
frameCallbackRegistry.registerFrameCallback(callback);
const memoizedFrameCallback = ref.current;
ref.current.setActive(ref.current.isActive);
return () => {
frameCallbackRegistry.unregisterFrameCallback(memoizedFrameCallback.callbackId);
memoizedFrameCallback.callbackId = -1;
};
}, [callback, autostart]); I believe that the higher-level fix we apply, the better it is for overall reliability and potential regressions. |
I also suspected that the I haven't been able to reproduce this, but within just a few hours of releasing the update to Google Play only, there were a lot of users that received this crash, as per Sentry. The only way to test that would be to publish another live build that will be potentially be crashing still. I think this PR should be merged as is regardless, even if fixing a the problem somewhere else. The |
Hmmmph, this is tough now. I can offer a following solution: a |
Cause we probably won't be able to determine whether it is fixed or not without having it either tested by pre-launch report or live users 😄 |
I'm running this PR with |
Oh, this means we can check which potential fix actually fixes it. I'd be super grateful if You could check both options (I believe you can run pre-launch report without publishing the app, can't you?). |
Okay @andreialecu I found a consistent but not really useful way to get the error - you can get it by running a new RN app with this in App.tsx and change some code in Reanimated's node_modules code of |
Adding this PR's code to the node_modules the same way doesn't generate the error (probably because of asserts), but makes the app do some strange things and hard reload is needed. Still unsure what should we do |
Does reverting #6143 improve it? |
Doesn't seem to... |
I still think that this is currently the only way we can somehow be sure the fix works |
@andreialecu sorry to ask you again, but isn't there really any way to run this pre-launch report with some applied changes? This way we could definitely tell if potential fixes do the job or not |
Other PR that aims to fix the issue in a better and cleaner manner got merged already, hence closing |
Summary
Fixes #6299 #6158
Test plan
I haven't yet been able to reproduce the issue - we just have it in Sentry -, but I assume that this is a race condition where
setActive(false)
is called after the callback was removed, where perhaps the component was unmounted.