Skip to content

Commit d0e402f

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Call onRender inline instead of from startRenderCallbackIfNeeded (#51750)
Summary: Pull Request resolved: #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
1 parent 116fb6d commit d0e402f

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ void NativeAnimatedNodesManager::handleAnimatedEvent(
404404
// `startRenderCallbackIfNeeded` will call platform specific code to
405405
// register UI tick listener.
406406
startRenderCallbackIfNeeded();
407+
// Calling startOnRenderCallback_ will register a UI tick listener.
408+
// The UI ticker listener will not be called until the next frame.
409+
// That's why, in case this is called from the UI thread, we need to
410+
// proactivelly trigger the animation loop to avoid showing stale
411+
// frames.
412+
onRender();
407413
}
408414
}
409415
}
@@ -426,14 +432,6 @@ NativeAnimatedNodesManager::ensureEventEmitterListener() noexcept {
426432
void NativeAnimatedNodesManager::startRenderCallbackIfNeeded() {
427433
if (startOnRenderCallback_) {
428434
startOnRenderCallback_([this]() { onRender(); });
429-
430-
if (isOnRenderThread_) {
431-
// Calling startOnRenderCallback_ will register a UI tick listener.
432-
// The UI ticker listener will not be called until the next frame.
433-
// That's why, in case this is called from the UI thread, we need to
434-
// proactivelly trigger the animation loop to avoid showing stale frames.
435-
onRender();
436-
}
437435
}
438436
}
439437

0 commit comments

Comments
 (0)