Call onRender inline instead of from startRenderCallbackIfNeeded (#51750)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51750

changelog: [internal]

inline call `onRender()` instead of calling it from `startRenderCallbackIfNeeded`. This has identical functionality but allows to use Fantom to test C++ Animated. In Fantom, there is only one thread the existing mechanism in C++ Animated uses thread locals to capture which thread in the UI thread. Therefore, some assumptions are broken. This is just an easy workaround around the problem.

Reviewed By: javache, zeyap

Differential Revision: D75787084

fbshipit-source-id: 8d70ef2d13e4ab14807deb7ca4cb0844980f5901
This commit is contained in:
Samuel Susla authored and Facebook GitHub Bot committed 2025-06-03 04:43:35 -07:00
1 parent 116fb6dab0
commit d0e402f3d9
1 file changed
+6 -8
@@ -404,6 +404,12 @@ void NativeAnimatedNodesManager::handleAnimatedEvent(
// `startRenderCallbackIfNeeded` will call platform specific code to
// register UI tick listener.
startRenderCallbackIfNeeded();
// Calling startOnRenderCallback_ will register a UI tick listener.
// The UI ticker listener will not be called until the next frame.
// That's why, in case this is called from the UI thread, we need to
// proactivelly trigger the animation loop to avoid showing stale
// frames.
onRender();
}
}
}
@@ -426,14 +432,6 @@ NativeAnimatedNodesManager::ensureEventEmitterListener() noexcept {
void NativeAnimatedNodesManager::startRenderCallbackIfNeeded() {
if (startOnRenderCallback_) {
startOnRenderCallback_([this]() { onRender(); });
if (isOnRenderThread_) {
// Calling startOnRenderCallback_ will register a UI tick listener.
// The UI ticker listener will not be called until the next frame.
// That's why, in case this is called from the UI thread, we need to
// proactivelly trigger the animation loop to avoid showing stale frames.
onRender();
}
}
}