Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/react-native/React/Fabric/RCTScheduler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ void schedulerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag,
[scheduler.delegate schedulerDidSynchronouslyUpdateViewOnUIThread:tag props:props];
}

void schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps> &updates) override
{
// Not implemented on iOS yet -- filled in by a later commit.
}

void schedulerDidUpdateShadowTree(const std::unordered_map<Tag, folly::dynamic> &tagToProps) override
{
// Does nothing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <jsi/JSIDynamic.h>
#include <jsi/jsi.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/animationbackend/AnimatedProps.h>
#include <react/renderer/animations/LayoutAnimationDriver.h>
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/core/EventBeat.h>
Expand Down Expand Up @@ -792,6 +793,13 @@ void FabricUIManagerBinding::schedulerShouldSynchronouslyUpdateViewOnUIThread(
}
}

void FabricUIManagerBinding::
schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId /*surfaceId*/,
const std::unordered_map<Tag, AnimatedProps>& /*updates*/) {
// Implemented in a follow-up.
}

void FabricUIManagerBinding::schedulerDidUpdateShadowTree(
const std::unordered_map<Tag, folly::dynamic>& /*tagToProps*/) {
// no-op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ class FabricUIManagerBinding : public jni::HybridClass<FabricUIManagerBinding>,

void schedulerShouldSynchronouslyUpdateViewOnUIThread(Tag tag, const folly::dynamic &props) override;

void schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps> &updates) override;

void schedulerDidUpdateShadowTree(const std::unordered_map<Tag, folly::dynamic> &tagToProps) override;

void schedulerDidCaptureViewSnapshot(Tag tag, SurfaceId surfaceId) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ void Scheduler::uiManagerShouldSynchronouslyUpdateViewOnUIThread(
}
}

void Scheduler::uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps>& updates) {
if (delegate_ != nullptr) {
delegate_->schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
surfaceId, updates);
}
}

void Scheduler::uiManagerDidUpdateShadowTree(
const std::unordered_map<Tag, folly::dynamic>& tagToProps) {
if (delegate_ != nullptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class Scheduler final : public UIManagerDelegate {
bool isJSResponder,
bool blockNativeResponder) override;
void uiManagerShouldSynchronouslyUpdateViewOnUIThread(Tag tag, const folly::dynamic &props) override;
void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps> &updates) override;
void uiManagerDidUpdateShadowTree(const std::unordered_map<Tag, folly::dynamic> &tagToProps) override;
void uiManagerDidCaptureViewSnapshot(Tag tag, SurfaceId surfaceId) override;
void uiManagerDidSetViewSnapshot(Tag sourceTag, Tag targetTag, SurfaceId surfaceId) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
#pragma once

#include <memory>
#include <unordered_map>

#include <react/renderer/core/ReactPrimitives.h>
#include <react/renderer/mounting/MountingCoordinator.h>
#include <react/renderer/mounting/ShadowView.h>

namespace facebook::react {

struct AnimatedProps;

/*
* Abstract class for Scheduler's delegate.
*/
Expand Down Expand Up @@ -64,6 +67,17 @@ class SchedulerDelegate {

virtual void schedulerShouldSynchronouslyUpdateViewOnUIThread(Tag tag, const folly::dynamic &props) = 0;

/**
* Synchronously update animated properties for multiple views on the UI
* thread. Each entry maps a Tag to the AnimatedProps that should be applied
* to that view. Platform implementations translate AnimatedProps into the
* native update mechanism (e.g. buffer protocol on Android, typed props on
* iOS).
*/
virtual void schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps> &updates) = 0;

virtual void schedulerDidUpdateShadowTree(const std::unordered_map<Tag, folly::dynamic> &tagToProps) = 0;

// View transition bitmap snapshot capture and application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,15 @@ void UIManager::synchronouslyUpdateViewOnUIThread(
}
}

void UIManager::synchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps>& updates) {
if (delegate_ != nullptr) {
delegate_->uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
surfaceId, updates);
}
}

#pragma mark ContextContainer

std::shared_ptr<const ContextContainer> UIManager::getContextContainer() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class UIManager final : public ShadowTreeDelegate {

void synchronouslyUpdateViewOnUIThread(Tag tag, const folly::dynamic &props);

void synchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps> &updates);

/*
* Provides access to a UIManagerBinding.
* The `callback` methods will not be called if the internal pointer to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace facebook::react {

struct AnimatedProps;
struct AnimationMutations;

using AnimationTimestamp = std::chrono::duration<double, std::milli>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@

#pragma once

#include <unordered_map>

#include <react/renderer/core/ReactPrimitives.h>
#include <react/renderer/core/ShadowNode.h>
#include <react/renderer/mounting/MountingCoordinator.h>
#include <react/renderer/mounting/ShadowTree.h>

namespace facebook::react {

struct AnimatedProps;

/*
* Abstract class for UIManager's delegate.
*/
Expand Down Expand Up @@ -64,6 +68,13 @@ class UIManagerDelegate {
*/
virtual void uiManagerShouldSynchronouslyUpdateViewOnUIThread(Tag tag, const folly::dynamic &props) = 0;

/*
* Synchronously update animated properties on the UI thread.
*/
virtual void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps> &updates) = 0;

/*
* Called after updateShadowTree is invoked.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ void SchedulerDelegateImpl::schedulerShouldSynchronouslyUpdateViewOnUIThread(
mountingManager_->synchronouslyUpdateViewOnUIThread(tag, props);
}

void SchedulerDelegateImpl::
schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId /*surfaceId*/,
const std::unordered_map<Tag, AnimatedProps>& /*updates*/) {
// Not implemented on CxxPlatform.
}

void SchedulerDelegateImpl::schedulerDidUpdateShadowTree(
const std::unordered_map<Tag, folly::dynamic>& tagToProps) {
mountingManager_->onUpdateShadowTree(tagToProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class SchedulerDelegateImpl : public SchedulerDelegate {

void schedulerShouldSynchronouslyUpdateViewOnUIThread(Tag tag, const folly::dynamic &props) override;

void schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(
SurfaceId surfaceId,
const std::unordered_map<Tag, AnimatedProps> &updates) override;

void schedulerDidUpdateShadowTree(const std::unordered_map<Tag, folly::dynamic> &tagToProps) override;

void schedulerDidCaptureViewSnapshot(Tag tag, SurfaceId surfaceId) override;
Expand Down
4 changes: 4 additions & 0 deletions scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -4479,6 +4479,7 @@ class facebook::react::Scheduler : public facebook::react::UIManagerDelegate {
public virtual void uiManagerShouldAddEventListener(std::shared_ptr<const facebook::react::EventListener> listener) final;
public virtual void uiManagerShouldRemoveEventListener(const std::shared_ptr<const facebook::react::EventListener>& listener) final;
public virtual void uiManagerShouldSetOnSurfaceStartCallback(facebook::react::UIManagerDelegate::OnSurfaceStartCallback&& callback) override;
public virtual void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) override;
public virtual void uiManagerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) override;
public void addEventListener(std::shared_ptr<const facebook::react::EventListener> listener);
public void animationTick() const;
Expand All @@ -4502,6 +4503,7 @@ class facebook::react::SchedulerDelegate {
public virtual void schedulerDidUpdateShadowTree(const std::unordered_map<facebook::react::Tag, folly::dynamic>& tagToProps) = 0;
public virtual void schedulerShouldMergeReactRevision(facebook::react::SurfaceId surfaceId) = 0;
public virtual void schedulerShouldRenderTransactions(const std::shared_ptr<const facebook::react::MountingCoordinator>& mountingCoordinator) = 0;
public virtual void schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) = 0;
public virtual void schedulerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) = 0;
public virtual ~SchedulerDelegate() noexcept = default;
}
Expand Down Expand Up @@ -5216,6 +5218,7 @@ class facebook::react::UIManager : public facebook::react::ShadowTreeDelegate {
public void startEmptySurface(facebook::react::ShadowTree::Unique&& shadowTree) const noexcept;
public void startSurface(facebook::react::ShadowTree::Unique&& shadowTree, const std::string& moduleName, const folly::dynamic& props, facebook::react::DisplayMode displayMode) const noexcept;
public void stopSurfaceForAnimationDelegate(facebook::react::SurfaceId surfaceId) const;
public void synchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates);
public void synchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props);
public void unregisterCommitHook(facebook::react::UIManagerCommitHook& commitHook);
public void unregisterMountHook(facebook::react::UIManagerMountHook& mountHook);
Expand Down Expand Up @@ -5283,6 +5286,7 @@ class facebook::react::UIManagerDelegate {
public virtual void uiManagerShouldAddEventListener(std::shared_ptr<const facebook::react::EventListener> listener) = 0;
public virtual void uiManagerShouldRemoveEventListener(const std::shared_ptr<const facebook::react::EventListener>& listener) = 0;
public virtual void uiManagerShouldSetOnSurfaceStartCallback(facebook::react::UIManagerDelegate::OnSurfaceStartCallback&& callback) = 0;
public virtual void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) = 0;
public virtual void uiManagerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) = 0;
public virtual ~UIManagerDelegate() noexcept = default;
}
Expand Down
4 changes: 4 additions & 0 deletions scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -4476,6 +4476,7 @@ class facebook::react::Scheduler : public facebook::react::UIManagerDelegate {
public virtual void uiManagerShouldAddEventListener(std::shared_ptr<const facebook::react::EventListener> listener) final;
public virtual void uiManagerShouldRemoveEventListener(const std::shared_ptr<const facebook::react::EventListener>& listener) final;
public virtual void uiManagerShouldSetOnSurfaceStartCallback(facebook::react::UIManagerDelegate::OnSurfaceStartCallback&& callback) override;
public virtual void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) override;
public virtual void uiManagerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) override;
public void addEventListener(std::shared_ptr<const facebook::react::EventListener> listener);
public void animationTick() const;
Expand All @@ -4499,6 +4500,7 @@ class facebook::react::SchedulerDelegate {
public virtual void schedulerDidUpdateShadowTree(const std::unordered_map<facebook::react::Tag, folly::dynamic>& tagToProps) = 0;
public virtual void schedulerShouldMergeReactRevision(facebook::react::SurfaceId surfaceId) = 0;
public virtual void schedulerShouldRenderTransactions(const std::shared_ptr<const facebook::react::MountingCoordinator>& mountingCoordinator) = 0;
public virtual void schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) = 0;
public virtual void schedulerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) = 0;
public virtual ~SchedulerDelegate() noexcept = default;
}
Expand Down Expand Up @@ -5207,6 +5209,7 @@ class facebook::react::UIManager : public facebook::react::ShadowTreeDelegate {
public void startEmptySurface(facebook::react::ShadowTree::Unique&& shadowTree) const noexcept;
public void startSurface(facebook::react::ShadowTree::Unique&& shadowTree, const std::string& moduleName, const folly::dynamic& props, facebook::react::DisplayMode displayMode) const noexcept;
public void stopSurfaceForAnimationDelegate(facebook::react::SurfaceId surfaceId) const;
public void synchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates);
public void synchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props);
public void unregisterCommitHook(facebook::react::UIManagerCommitHook& commitHook);
public void unregisterMountHook(facebook::react::UIManagerMountHook& mountHook);
Expand Down Expand Up @@ -5274,6 +5277,7 @@ class facebook::react::UIManagerDelegate {
public virtual void uiManagerShouldAddEventListener(std::shared_ptr<const facebook::react::EventListener> listener) = 0;
public virtual void uiManagerShouldRemoveEventListener(const std::shared_ptr<const facebook::react::EventListener>& listener) = 0;
public virtual void uiManagerShouldSetOnSurfaceStartCallback(facebook::react::UIManagerDelegate::OnSurfaceStartCallback&& callback) = 0;
public virtual void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) = 0;
public virtual void uiManagerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) = 0;
public virtual ~UIManagerDelegate() noexcept = default;
}
Expand Down
4 changes: 4 additions & 0 deletions scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -7060,6 +7060,7 @@ class facebook::react::Scheduler : public facebook::react::UIManagerDelegate {
public virtual void uiManagerShouldAddEventListener(std::shared_ptr<const facebook::react::EventListener> listener) final;
public virtual void uiManagerShouldRemoveEventListener(const std::shared_ptr<const facebook::react::EventListener>& listener) final;
public virtual void uiManagerShouldSetOnSurfaceStartCallback(facebook::react::UIManagerDelegate::OnSurfaceStartCallback&& callback) override;
public virtual void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) override;
public virtual void uiManagerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) override;
public void addEventListener(std::shared_ptr<const facebook::react::EventListener> listener);
public void animationTick() const;
Expand All @@ -7083,6 +7084,7 @@ class facebook::react::SchedulerDelegate {
public virtual void schedulerDidUpdateShadowTree(const std::unordered_map<facebook::react::Tag, folly::dynamic>& tagToProps) = 0;
public virtual void schedulerShouldMergeReactRevision(facebook::react::SurfaceId surfaceId) = 0;
public virtual void schedulerShouldRenderTransactions(const std::shared_ptr<const facebook::react::MountingCoordinator>& mountingCoordinator) = 0;
public virtual void schedulerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) = 0;
public virtual void schedulerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) = 0;
public virtual ~SchedulerDelegate() noexcept = default;
}
Expand Down Expand Up @@ -7780,6 +7782,7 @@ class facebook::react::UIManager : public facebook::react::ShadowTreeDelegate {
public void startEmptySurface(facebook::react::ShadowTree::Unique&& shadowTree) const noexcept;
public void startSurface(facebook::react::ShadowTree::Unique&& shadowTree, const std::string& moduleName, const folly::dynamic& props, facebook::react::DisplayMode displayMode) const noexcept;
public void stopSurfaceForAnimationDelegate(facebook::react::SurfaceId surfaceId) const;
public void synchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates);
public void synchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props);
public void unregisterCommitHook(facebook::react::UIManagerCommitHook& commitHook);
public void unregisterMountHook(facebook::react::UIManagerMountHook& mountHook);
Expand Down Expand Up @@ -7847,6 +7850,7 @@ class facebook::react::UIManagerDelegate {
public virtual void uiManagerShouldAddEventListener(std::shared_ptr<const facebook::react::EventListener> listener) = 0;
public virtual void uiManagerShouldRemoveEventListener(const std::shared_ptr<const facebook::react::EventListener>& listener) = 0;
public virtual void uiManagerShouldSetOnSurfaceStartCallback(facebook::react::UIManagerDelegate::OnSurfaceStartCallback&& callback) = 0;
public virtual void uiManagerShouldSynchronouslyUpdateAnimatedPropsOnUIThread(facebook::react::SurfaceId surfaceId, const std::unordered_map<facebook::react::Tag, facebook::react::AnimatedProps>& updates) = 0;
public virtual void uiManagerShouldSynchronouslyUpdateViewOnUIThread(facebook::react::Tag tag, const folly::dynamic& props) = 0;
public virtual ~UIManagerDelegate() noexcept = default;
}
Expand Down
Loading
Loading