Remove feature flag for async event beat v2
Summary: Changelog: [internal] AsynchronousEventBeatV2 is shipped. Let's remove gating. Reviewed By: fkgozali Differential Revision: D29261752 fbshipit-source-id: 844cfc494c077e36945a7fa65f9368c2165d5c8c
This commit is contained in:
Родитель
090f828bdd
Коммит
f175ff5c04
|
@ -32,7 +32,6 @@
|
|||
#import <react/renderer/core/LayoutContext.h>
|
||||
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
|
||||
#import <react/renderer/scheduler/AsynchronousEventBeat.h>
|
||||
#import <react/renderer/scheduler/AsynchronousEventBeatV2.h>
|
||||
#import <react/renderer/scheduler/SchedulerToolbox.h>
|
||||
#import <react/renderer/scheduler/SynchronousEventBeat.h>
|
||||
#import <react/utils/ContextContainer.h>
|
||||
|
@ -310,18 +309,11 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
|
|||
return std::make_unique<SynchronousEventBeat>(std::move(runLoopObserver), runtimeExecutor, runtimeScheduler);
|
||||
};
|
||||
|
||||
auto enableV2AsynchronousEventBeat =
|
||||
reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_asynchronous_event_beat_v2_ios");
|
||||
|
||||
toolbox.asynchronousEventBeatFactory = [runtimeExecutor, enableV2AsynchronousEventBeat](
|
||||
EventBeat::SharedOwnerBox const &ownerBox) -> std::unique_ptr<EventBeat> {
|
||||
toolbox.asynchronousEventBeatFactory =
|
||||
[runtimeExecutor](EventBeat::SharedOwnerBox const &ownerBox) -> std::unique_ptr<EventBeat> {
|
||||
auto runLoopObserver =
|
||||
std::make_unique<MainRunLoopObserver const>(RunLoopObserver::Activity::BeforeWaiting, ownerBox->owner);
|
||||
if (enableV2AsynchronousEventBeat) {
|
||||
return std::make_unique<AsynchronousEventBeatV2>(std::move(runLoopObserver), runtimeExecutor);
|
||||
} else {
|
||||
return std::make_unique<AsynchronousEventBeat>(std::move(runLoopObserver), runtimeExecutor);
|
||||
}
|
||||
};
|
||||
|
||||
RCTScheduler *scheduler = [[RCTScheduler alloc] initWithToolbox:toolbox];
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
namespace facebook::react {
|
||||
|
||||
AsynchronousEventBeat::AsynchronousEventBeat(
|
||||
RunLoopObserver::Unique uiRunLoopObserver,
|
||||
|
@ -24,34 +23,36 @@ AsynchronousEventBeat::AsynchronousEventBeat(
|
|||
|
||||
void AsynchronousEventBeat::activityDidChange(
|
||||
RunLoopObserver::Delegate const *delegate,
|
||||
RunLoopObserver::Activity activity) const noexcept {
|
||||
RunLoopObserver::Activity) const noexcept {
|
||||
react_native_assert(delegate == this);
|
||||
induce();
|
||||
}
|
||||
|
||||
void AsynchronousEventBeat::induce() const {
|
||||
if (!isRequested_) {
|
||||
if (!isRequested_ || isBeatCallbackScheduled_) {
|
||||
return;
|
||||
}
|
||||
|
||||
isRequested_ = false;
|
||||
|
||||
// Here we know that `this` object exists because the caller has a strong
|
||||
// pointer to `owner`. To ensure the object will exist inside
|
||||
// `runtimeExecutor_` callback, we need to copy the pointer there.
|
||||
auto weakOwner = uiRunLoopObserver_->getOwner();
|
||||
|
||||
runtimeExecutor_([this, weakOwner](jsi::Runtime &runtime) mutable {
|
||||
isBeatCallbackScheduled_ = true;
|
||||
|
||||
runtimeExecutor_([this, weakOwner](jsi::Runtime &runtime) {
|
||||
isBeatCallbackScheduled_ = false;
|
||||
|
||||
auto owner = weakOwner.lock();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isRequested_) {
|
||||
return;
|
||||
if (beatCallback_) {
|
||||
beatCallback_(runtime);
|
||||
}
|
||||
|
||||
this->beat(runtime);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
} // namespace facebook::react
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
#include <react/renderer/core/EventBeat.h>
|
||||
#include <react/utils/RunLoopObserver.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
namespace facebook::react {
|
||||
|
||||
/*
|
||||
* Event beat associated with JavaScript runtime.
|
||||
|
@ -35,7 +34,8 @@ class AsynchronousEventBeat : public EventBeat,
|
|||
private:
|
||||
RunLoopObserver::Unique uiRunLoopObserver_;
|
||||
RuntimeExecutor runtimeExecutor_;
|
||||
|
||||
mutable std::atomic<bool> isBeatCallbackScheduled_{false};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
} // namespace facebook::react
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "AsynchronousEventBeatV2.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
AsynchronousEventBeatV2::AsynchronousEventBeatV2(
|
||||
RunLoopObserver::Unique uiRunLoopObserver,
|
||||
RuntimeExecutor runtimeExecutor)
|
||||
: EventBeat({}),
|
||||
uiRunLoopObserver_(std::move(uiRunLoopObserver)),
|
||||
runtimeExecutor_(std::move(runtimeExecutor)) {
|
||||
uiRunLoopObserver_->setDelegate(this);
|
||||
uiRunLoopObserver_->enable();
|
||||
}
|
||||
|
||||
void AsynchronousEventBeatV2::activityDidChange(
|
||||
RunLoopObserver::Delegate const *delegate,
|
||||
RunLoopObserver::Activity) const noexcept {
|
||||
react_native_assert(delegate == this);
|
||||
induce();
|
||||
}
|
||||
|
||||
void AsynchronousEventBeatV2::induce() const {
|
||||
if (!isRequested_ || isBeatCallbackScheduled_) {
|
||||
return;
|
||||
}
|
||||
|
||||
isRequested_ = false;
|
||||
|
||||
// Here we know that `this` object exists because the caller has a strong
|
||||
// pointer to `owner`. To ensure the object will exist inside
|
||||
// `runtimeExecutor_` callback, we need to copy the pointer there.
|
||||
auto weakOwner = uiRunLoopObserver_->getOwner();
|
||||
|
||||
isBeatCallbackScheduled_ = true;
|
||||
|
||||
runtimeExecutor_([this, weakOwner](jsi::Runtime &runtime) {
|
||||
isBeatCallbackScheduled_ = false;
|
||||
|
||||
auto owner = weakOwner.lock();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (beatCallback_) {
|
||||
beatCallback_(runtime);
|
||||
}
|
||||
});
|
||||
}
|
||||
} // namespace facebook::react
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <ReactCommon/RuntimeExecutor.h>
|
||||
#include <react/renderer/core/EventBeat.h>
|
||||
#include <react/utils/RunLoopObserver.h>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
/*
|
||||
* Event beat associated with JavaScript runtime.
|
||||
* The beat is called on `RuntimeExecutor`'s thread induced by the UI thread
|
||||
* event loop.
|
||||
*/
|
||||
class AsynchronousEventBeatV2 : public EventBeat,
|
||||
public RunLoopObserver::Delegate {
|
||||
public:
|
||||
AsynchronousEventBeatV2(
|
||||
RunLoopObserver::Unique uiRunLoopObserver,
|
||||
RuntimeExecutor runtimeExecutor);
|
||||
|
||||
void induce() const override;
|
||||
|
||||
#pragma mark - RunLoopObserver::Delegate
|
||||
|
||||
void activityDidChange(
|
||||
RunLoopObserver::Delegate const *delegate,
|
||||
RunLoopObserver::Activity activity) const noexcept override;
|
||||
|
||||
private:
|
||||
RunLoopObserver::Unique uiRunLoopObserver_;
|
||||
RuntimeExecutor runtimeExecutor_;
|
||||
|
||||
mutable std::atomic<bool> isBeatCallbackScheduled_{false};
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
Загрузка…
Ссылка в новой задаче