mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
remove enable_shared_from_this from NativeAnimatedNodesManager (#51589)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51589 changelog: [internal] With D75140890, there is a guarantee that `startOnRenderCallback_` won't be called after the owning class is destroyed. There shouldn't be any events flowing through Fabric when the RN instance is torn down. Passing this to eventEmitterListener_ should be safe. This helps with C++ binary size a little bit. Reviewed By: rshest Differential Revision: D75148616 fbshipit-source-id: 5110736c2ddcff738fce395bd0b9844d44e8dcb2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
44ebf31f3b
commit
bf974e8de1
+3
-9
@@ -427,13 +427,11 @@ std::shared_ptr<EventEmitterListener>
|
||||
NativeAnimatedNodesManager::ensureEventEmitterListener() noexcept {
|
||||
if (!eventEmitterListener_) {
|
||||
eventEmitterListener_ = std::make_shared<EventEmitterListener>(
|
||||
[weakSelf = weak_from_this()](
|
||||
[this](
|
||||
Tag tag,
|
||||
const std::string& eventName,
|
||||
const EventPayload& payload) -> bool {
|
||||
if (auto self = weakSelf.lock()) {
|
||||
self->handleAnimatedEvent(tag, eventName, payload);
|
||||
}
|
||||
handleAnimatedEvent(tag, eventName, payload);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@@ -442,11 +440,7 @@ NativeAnimatedNodesManager::ensureEventEmitterListener() noexcept {
|
||||
|
||||
void NativeAnimatedNodesManager::startRenderCallbackIfNeeded() {
|
||||
if (startOnRenderCallback_) {
|
||||
startOnRenderCallback_([weakSelf = weak_from_this()]() {
|
||||
if (auto self = weakSelf.lock()) {
|
||||
self->onRender();
|
||||
}
|
||||
});
|
||||
startOnRenderCallback_([this]() { onRender(); });
|
||||
|
||||
if (isOnRenderThread_) {
|
||||
// Calling startOnRenderCallback_ will register a UI tick listener.
|
||||
|
||||
+1
-2
@@ -41,8 +41,7 @@ template <>
|
||||
struct Bridging<EndResult>
|
||||
: NativeAnimatedTurboModuleEndResultBridging<EndResult> {};
|
||||
|
||||
class NativeAnimatedNodesManager
|
||||
: public std::enable_shared_from_this<NativeAnimatedNodesManager> {
|
||||
class NativeAnimatedNodesManager {
|
||||
public:
|
||||
using DirectManipulationCallback =
|
||||
std::function<void(Tag, const folly::dynamic&)>;
|
||||
|
||||
Reference in New Issue
Block a user