mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Drive shared animation backend from Fabric frame callback (#57400)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57400 In this diff we drop the custom choreographer for the backend on Android and instead plug into the one in `FabricUIManager`. This reduces the area for possible mistakes, makes it clearer how Fabric interacts with animation on a per-frame basis, and simplifies the flow around invalidation and cleanup of the React instance. The crash this is meant to avoid comes from having two separate frame callback lifecycles. The old `AnimationBackendChoreographer` owned a self-reposting callback that could keep driving `FabricUIManagerBinding.driveAnimationBackend` independently from Fabric's own lifecycle. During React instance teardown, `FabricUIManager.invalidate()` pauses Fabric's frame callback and then unregisters the native binding. If a separate backend callback survives that sequence, it can invoke the binding after the native side has been uninstalled. The shared animation backend is now driven from Fabric's existing `DISPATCH_UI` frame callback after mount items are dispatched. The Android `AnimationChoreographer` implementation only owns backend pause/resume state and conditionally forwards active frames to the shared backend. Threading-wise: - If invalidation happens before a frame starts, `mDestroyed` makes the frame no-op. - If invalidation races with an already-running frame, `ReactChoreographer.removeFrameCallback` is serialized with callback execution via the `callbackQueues` monitor, so `onHostPause()` waits for the current `DISPATCH_UI` callback to finish before `unregister()` tears down the native binding. - If the frame reposts itself in `schedule()`, the blocked removal observes and removes that callback before teardown continues. Changelog: [Android][Fixed] - Drive the shared animation backend from Fabric's frame callback during React instance teardown Reviewed By: javache, zeyap Differential Revision: D110321362 fbshipit-source-id: 77c462ee30aeec2d3af0dcd48b8eed15846ae5da
This commit is contained in:
1 parent
923e7ddcaf
commit
721b1cfcac
13 files changed
+32
-214
No files matched your search
@@ -1245,9 +1245,9 @@ class facebook::react::AdditionAnimatedNode : public facebook::react::OperatorAn
|
||||
}
|
||||
|
||||
class facebook::react::AndroidAnimationChoreographer : public facebook::react::AnimationChoreographer {
|
||||
public AndroidAnimationChoreographer(jni::alias_ref<facebook::react::JAnimationBackendChoreographer> jChoreographer);
|
||||
public virtual void pause() override;
|
||||
public virtual void resume() override;
|
||||
public void onAnimationFrameIfActive(facebook::react::AnimationTimestamp timestamp) const;
|
||||
}
|
||||
|
||||
class facebook::react::AndroidDrawerLayoutEventEmitter : public facebook::react::BaseViewEventEmitter {
|
||||
@@ -2780,12 +2780,6 @@ class facebook::react::IntersectionObserverState {
|
||||
public static facebook::react::IntersectionObserverState NotIntersecting();
|
||||
}
|
||||
|
||||
class facebook::react::JAnimationBackendChoreographer : public facebook::jni::JavaClass<facebook::react::JAnimationBackendChoreographer> {
|
||||
public static constexpr auto kJavaDescriptor;
|
||||
public void pause() const;
|
||||
public void resume() const;
|
||||
}
|
||||
|
||||
class facebook::react::JBindingsInstaller : public jni::HybridClass<facebook::react::JBindingsInstaller>, public facebook::react::BindingsInstaller {
|
||||
public static constexpr auto kJavaDescriptor;
|
||||
public ~JBindingsInstaller();
|
||||
|
||||
@@ -1241,9 +1241,9 @@ class facebook::react::AdditionAnimatedNode : public facebook::react::OperatorAn
|
||||
}
|
||||
|
||||
class facebook::react::AndroidAnimationChoreographer : public facebook::react::AnimationChoreographer {
|
||||
public AndroidAnimationChoreographer(jni::alias_ref<facebook::react::JAnimationBackendChoreographer> jChoreographer);
|
||||
public virtual void pause() override;
|
||||
public virtual void resume() override;
|
||||
public void onAnimationFrameIfActive(facebook::react::AnimationTimestamp timestamp) const;
|
||||
}
|
||||
|
||||
class facebook::react::AndroidDrawerLayoutEventEmitter : public facebook::react::BaseViewEventEmitter {
|
||||
@@ -2738,12 +2738,6 @@ class facebook::react::IntersectionObserverState {
|
||||
public static facebook::react::IntersectionObserverState NotIntersecting();
|
||||
}
|
||||
|
||||
class facebook::react::JAnimationBackendChoreographer : public facebook::jni::JavaClass<facebook::react::JAnimationBackendChoreographer> {
|
||||
public static constexpr auto kJavaDescriptor;
|
||||
public void pause() const;
|
||||
public void resume() const;
|
||||
}
|
||||
|
||||
class facebook::react::JBindingsInstaller : public jni::HybridClass<facebook::react::JBindingsInstaller>, public facebook::react::BindingsInstaller {
|
||||
public static constexpr auto kJavaDescriptor;
|
||||
public ~JBindingsInstaller();
|
||||
|
||||
@@ -1245,9 +1245,9 @@ class facebook::react::AdditionAnimatedNode : public facebook::react::OperatorAn
|
||||
}
|
||||
|
||||
class facebook::react::AndroidAnimationChoreographer : public facebook::react::AnimationChoreographer {
|
||||
public AndroidAnimationChoreographer(jni::alias_ref<facebook::react::JAnimationBackendChoreographer> jChoreographer);
|
||||
public virtual void pause() override;
|
||||
public virtual void resume() override;
|
||||
public void onAnimationFrameIfActive(facebook::react::AnimationTimestamp timestamp) const;
|
||||
}
|
||||
|
||||
class facebook::react::AndroidDrawerLayoutEventEmitter : public facebook::react::BaseViewEventEmitter {
|
||||
@@ -2777,12 +2777,6 @@ class facebook::react::IntersectionObserverState {
|
||||
public static facebook::react::IntersectionObserverState NotIntersecting();
|
||||
}
|
||||
|
||||
class facebook::react::JAnimationBackendChoreographer : public facebook::jni::JavaClass<facebook::react::JAnimationBackendChoreographer> {
|
||||
public static constexpr auto kJavaDescriptor;
|
||||
public void pause() const;
|
||||
public void resume() const;
|
||||
}
|
||||
|
||||
class facebook::react::JBindingsInstaller : public jni::HybridClass<facebook::react::JBindingsInstaller>, public facebook::react::BindingsInstaller {
|
||||
public static constexpr auto kJavaDescriptor;
|
||||
public ~JBindingsInstaller();
|
||||
|
||||
Reference in new issue
Block a user