You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Fabric] Crash on react_native_assert(attempts < 1024); #4660
This crash occurs when React Native tries to commit changes from a React render that takes long to calculate layout (in particular, more than one animation frame) while Reanimated animates some layout properties (e.g. width) on each animation frame.
react_native_assert failure: attempts < 1024
Assertion failed: (attempts < 1024), function commit, file ShadowTree.cpp, line 314.
The root cause of starvation here is that Reanimated is able to commit a new tree way faster than React Native (e.g. due to layout calculation) and React Native's transaction goes out of date in terms of source shadow tree:
The app crashes on react_native_assert(attempts < 1024);
In order to simulate long layout calculation, you can paste the following line:
RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
ShadowTree const &shadowTree,
RootShadowNode::Shared const &oldRootShadowNode,
RootShadowNode::Unshared const &newRootShadowNode) const noexcept {
if (propsRegistry_->isLastReanimatedRoot(newRootShadowNode)) {
// ShadowTree commited by Reanimated, no need to apply updates from
// PropsRegistry
return newRootShadowNode;
}
// ShadowTree not commited by Reanimated, apply updates from PropsRegistry
+ for (int i = 0; i < 100000000; ++i);
auto surfaceId = newRootShadowNode->getSurfaceId();
auto rootNode = newRootShadowNode->ShadowNode::clone(ShadowNodeFragment{});
You can also decrease the attempts threshold:
// After multiple attempts, we failed to commit the transaction.
// Something internally went terribly wrong.
- react_native_assert(attempts < 1024);+ react_native_assert(attempts < 50);
}
Activity
tomekzaw commentedon Jul 2, 2023
Workaround 1
Edit
ReanimatedCommitHook.cppand remove the following piece of code:RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit( ShadowTree const &shadowTree, RootShadowNode::Shared const &oldRootShadowNode, RootShadowNode::Unshared const &newRootShadowNode) const noexcept { - if (propsRegistry_->isLastReanimatedRoot(newRootShadowNode)) { - // ShadowTree commited by Reanimated, no need to apply updates from - // PropsRegistry - return newRootShadowNode; - } // ShadowTree not commited by Reanimated, apply updates from PropsRegistrybillnbell commentedon Jul 8, 2023
I am getting this too!
snowdigital commentedon Jul 27, 2023
Maybe i have simular issue, when reanimated starts animating something it quickly bumps memory usage to maximum and crashes then, is it same?
tomekzaw commentedon Sep 11, 2023
Fixed by @michalmaka in #4833.