Merge commit '5c24746a4837b785fa18831a3740a3a5bdd1f304' into amgleitman/0.64-merge-head

This commit is contained in:
Adam Gleitman 2021-08-25 18:09:23 -07:00
Родитель c30a62de47 5c24746a48
Коммит dcc19c9f53
7 изменённых файлов: 113 добавлений и 177 удалений

Просмотреть файл

@ -524,8 +524,8 @@ SPEC CHECKSUMS:
CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845
CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f
DoubleConversion: 2b45d0f8e156a5b02354c8a4062de64d41ccb4e0
FBLazyVector: 2df9afadfa48640d27ac577577a7cc1dcb1d2666
FBReactNativeSpec: e89c62565509f18d276a0748843ed08a995252f4
FBLazyVector: 2a63663ac5335e5ab19417382731a6027fa968b7
FBReactNativeSpec: 07fde1bc97526057192dd12c642b8d4d19402f2d
Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
Flipper-Folly: c12092ea368353b58e992843a990a3225d4533c3
@ -536,34 +536,34 @@ SPEC CHECKSUMS:
glog: 789873d01e4b200777d0a09bc23d548446758699
OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355
RCT-Folly: 55d0039b24e192081ec0b2257f7bd9f42e382fb7
RCTRequired: d6b80f88e45e754ad21eaf6ed748ac736211ddbe
RCTTypeSafety: a8b0de837d9f623658e7cb982ba9f0d24485d686
React: 98ad65062dcc6c1d0f3339ae35e0e70d56312ae6
React-ART: 1db80fc7116f53b06ed56023a2e0468642abf618
React-callinvoker: 2e8020c80dc24a49a5d3ea67958163bb356ba51e
React-Core: 91a5ffa00e75d4a0e2ee558d7f0cc7cce666192c
React-CoreModules: bb29f802c5ce404e60002bec5d4325e7ee37d941
React-cxxreact: 828a9556ed095a776dd7853c3fa78fcd7058f598
React-jsi: 80c7b516e2ddfaba82eb3444f9115cb37180859c
React-jsiexecutor: aab8afe96cb02d7043d2a57a2746d73887d34a5c
React-jsinspector: da2cb5b330bae976c185623e161ba8dde7c105b1
React-perflogger: e4fdd9850e40333db9d085822bd395cc5c1729be
React-RCTActionSheet: 48c93d32e8554f08dce5c2a7e1b6e67c152bb574
React-RCTAnimation: dad9fbcd6fbaa84883b0c1a34dc68fcdaa91ca53
React-RCTBlob: 794d81ddc1fd0b49117a2f353552a0505d5999aa
React-RCTImage: c62c82e344bedb93c039e978b627fb2d07a2d446
React-RCTLinking: f5ff318d9520a5f4f836f1107725e2eff6723634
React-RCTNetwork: 77f88d6bddb5fb561928dabc2405f522e457ecbb
React-RCTPushNotification: c0e58f0f5612feff450b8029ba64f0e94e5ab516
React-RCTSettings: 8ab17b56125bb4677cfff88e16843f613860872b
React-RCTTest: de112228d6d63b1b38dc627403c9943b2789405e
React-RCTText: b7ca64a7cadfe9d0702af594e48f3a4cd0fdef2e
React-RCTVibration: 6b5ddd1ef0ceec713a6d61053397cba44f4b973e
React-runtimeexecutor: e016fc20e57e783e68416251194e6a23a3186619
RCTRequired: 2734111c45780873381b09de39f84ea5b40c5f9b
RCTTypeSafety: 5380832101fda4113ea30265df1fc1b276c668b4
React: 951e1abdefaca839e9965e6c5c8b8cde02fd9c3a
React-ART: 9e78ec22753645aeeb88a848529118aa9671c58b
React-callinvoker: 67862617a70120d314f6e1a8928e0d822e5d4f6b
React-Core: bab4fa6aef660d13a0fe5f7729570c6ee29b2cc8
React-CoreModules: a08120b5a60c46a48e3df813c6d26aba6439ee99
React-cxxreact: 3cd014c6a5f1a54eb848b944ab85967b4c7da615
React-jsi: c27dd6bb0c0372700fa294ab67227f0fcd3387c1
React-jsiexecutor: 470bd4e0bfe716f3639e03df363ebe474e913681
React-jsinspector: 0846f4c5a5b55e0d75d31d582af10a24e79ad16c
React-perflogger: 1e770d15f54bed6bffbf3a73c8ca3bc799a025cb
React-RCTActionSheet: 54f33c5f36a9db54b3736dd1c01dbc9524aaee20
React-RCTAnimation: 219a0b36aaa702818a6df914545d68ae58ba0f00
React-RCTBlob: f14e4bfe4f2ab49d8b50f5c9320996dfbf583e76
React-RCTImage: f1a1ab51e0d92556585ec04b0a64a90685903e4a
React-RCTLinking: 5fb6bc1dde9b7f81e7581dab36b841856b5dcdd1
React-RCTNetwork: 2308606cef1fc3a816861bc4745e01acc7706fbd
React-RCTPushNotification: 2e93e16e5efcfed2221cce1cfe16bb227d9b658e
React-RCTSettings: 06421b1898e50f8a0b8dc9210675f1e5429ba97e
React-RCTTest: d784b0c5d332eef21e2733104bcc17cb76b3c616
React-RCTText: 4b84ad7be4545e6b8434242d0405e09b3ef1af97
React-RCTVibration: 70705070555d006c2104d01a0cfcc024d1602647
React-runtimeexecutor: eb550be7930775e9a5e01b671f01cb9dcdf0eca0
React-TurboModuleCxx-RNW: 18bb71af41fe34c8b12a56bef60aae7ee32b0817
React-TurboModuleCxx-WinRTPort: b1121c9038c72af8babe05b9a82a29b601d5ec3d
ReactCommon: 13554ea99fc8fdf258941cdb4a3d16d70d9d69f1
Yoga: 8cd8d527f85ffcf6f9b4943fd56b57e150ea0212
React-TurboModuleCxx-WinRTPort: a9447de6b4331a2971d3ebaee02acdeb62309cc3
ReactCommon: 62c7f36e6305343f58f75b7c8468133b860c9565
Yoga: 701fb52ff21e3bec777dd563cf0996a27b013423
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
PODFILE CHECKSUM: 2a5ebd1edccf5913eeb0748b1ce38c8dafa87a21

Просмотреть файл

@ -383,6 +383,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init);
}
- (void)gatherConstants
{
return [self gatherConstantsAndSignalJSRequireEnding:NO];
}
- (void)gatherConstantsAndSignalJSRequireEnding:(BOOL)startMarkers
{
NSString *moduleName = [self name];
@ -391,15 +396,17 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init);
RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData gatherConstants] %@", _moduleClass]), nil);
(void)[self instance];
/**
* Why do we instrument moduleJSRequireEndingStart here?
* - NativeModule requires from JS go through ModuleRegistry::getConfig().
* - ModuleRegistry::getConfig() calls NativeModule::getConstants() first.
* - This delegates to RCTNativeModule::getConstants(), which calls RCTModuleData gatherConstants().
* - Therefore, this is the first statement that executes after the NativeModule is created/initialized in a JS
* require.
*/
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart([moduleName UTF8String]);
if (startMarkers) {
/**
* Why do we instrument moduleJSRequireEndingStart here?
* - NativeModule requires from JS go through ModuleRegistry::getConfig().
* - ModuleRegistry::getConfig() calls NativeModule::getConstants() first.
* - This delegates to RCTNativeModule::getConstants(), which calls RCTModuleData gatherConstants().
* - Therefore, this is the first statement that executes after the NativeModule is created/initialized in a JS
* require.
*/
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart([moduleName UTF8String]);
}
if (!RCTIsMainQueueExecutionOfConstantsToExportDisabled() && _requiresMainQueueSetup) {
if (!RCTIsMainQueue()) {
@ -414,7 +421,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init);
}
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} else {
} else if (startMarkers) {
/**
* If a NativeModule doesn't have constants, it isn't eagerly loaded until its methods are first invoked.
* Therefore, we should immediately start JSRequireEnding
@ -425,7 +432,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init);
- (NSDictionary<NSString *, id> *)exportedConstants
{
[self gatherConstants];
[self gatherConstantsAndSignalJSRequireEnding:YES];
NSDictionary<NSString *, id> *constants = _constantsToExport;
_constantsToExport = nil; // Not needed anymore
return constants;

Просмотреть файл

@ -27,8 +27,9 @@ NS_ASSUME_NONNULL_BEGIN
* for given `componentHandle` and with given `tag`.
* #RefuseSingleUse
*/
- (RCTComponentViewDescriptor)dequeueComponentViewWithComponentHandle:(facebook::react::ComponentHandle)componentHandle
tag:(facebook::react::Tag)tag;
- (RCTComponentViewDescriptor const &)dequeueComponentViewWithComponentHandle:
(facebook::react::ComponentHandle)componentHandle
tag:(facebook::react::Tag)tag;
/**
* Puts a given native component view to the recycle pool.

Просмотреть файл

@ -66,7 +66,8 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
}
}
- (RCTComponentViewDescriptor)dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle tag:(Tag)tag
- (RCTComponentViewDescriptor const &)dequeueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
tag:(Tag)tag
{
RCTAssertMainQueue();
@ -76,10 +77,8 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
auto componentViewDescriptor = [self _dequeueComponentViewWithComponentHandle:componentHandle];
componentViewDescriptor.view.tag = tag;
_registry.insert({tag, componentViewDescriptor});
return componentViewDescriptor;
auto it = _registry.insert({tag, componentViewDescriptor});
return it.first->second;
}
- (void)enqueueComponentViewWithComponentHandle:(ComponentHandle)componentHandle

Просмотреть файл

@ -21,170 +21,101 @@
#import "RCTConversions.h"
#import "RCTMountingTransactionObserverCoordinator.h"
using namespace facebook;
using namespace facebook::react;
// `Create` instruction
static void RNCreateMountInstruction(
ShadowViewMutation const &mutation,
RCTComponentViewRegistry *registry,
RCTMountingTransactionObserverCoordinator &observerCoordinator,
SurfaceId surfaceId)
{
auto componentViewDescriptor =
[registry dequeueComponentViewWithComponentHandle:mutation.newChildShadowView.componentHandle
tag:mutation.newChildShadowView.tag];
observerCoordinator.registerViewComponentDescriptor(componentViewDescriptor, surfaceId);
}
// `Delete` instruction
static void RNDeleteMountInstruction(
ShadowViewMutation const &mutation,
RCTComponentViewRegistry *registry,
RCTMountingTransactionObserverCoordinator &observerCoordinator,
SurfaceId surfaceId)
{
auto const &oldChildShadowView = mutation.oldChildShadowView;
auto const &componentViewDescriptor = [registry componentViewDescriptorWithTag:oldChildShadowView.tag];
observerCoordinator.unregisterViewComponentDescriptor(componentViewDescriptor, surfaceId);
[registry enqueueComponentViewWithComponentHandle:oldChildShadowView.componentHandle
tag:oldChildShadowView.tag
componentViewDescriptor:componentViewDescriptor];
}
// `Insert` instruction
static void RNInsertMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{
auto const &newShadowView = mutation.newChildShadowView;
auto const &parentShadowView = mutation.parentShadowView;
auto const &childComponentViewDescriptor = [registry componentViewDescriptorWithTag:newShadowView.tag];
auto const &parentComponentViewDescriptor = [registry componentViewDescriptorWithTag:parentShadowView.tag];
[parentComponentViewDescriptor.view mountChildComponentView:childComponentViewDescriptor.view index:mutation.index];
}
// `Remove` instruction
static void RNRemoveMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{
auto const &oldShadowView = mutation.oldChildShadowView;
auto const &parentShadowView = mutation.parentShadowView;
auto const &childComponentViewDescriptor = [registry componentViewDescriptorWithTag:oldShadowView.tag];
auto const &parentComponentViewDescriptor = [registry componentViewDescriptorWithTag:parentShadowView.tag];
[parentComponentViewDescriptor.view unmountChildComponentView:childComponentViewDescriptor.view index:mutation.index];
}
// `Update Props` instruction
static void RNUpdatePropsMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{
auto const &oldShadowView = mutation.oldChildShadowView;
auto const &newShadowView = mutation.newChildShadowView;
auto const &componentViewDescriptor = [registry componentViewDescriptorWithTag:newShadowView.tag];
[componentViewDescriptor.view updateProps:newShadowView.props oldProps:oldShadowView.props];
}
// `Update EventEmitter` instruction
static void RNUpdateEventEmitterMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{
auto const &newShadowView = mutation.newChildShadowView;
auto const &componentViewDescriptor = [registry componentViewDescriptorWithTag:newShadowView.tag];
[componentViewDescriptor.view updateEventEmitter:newShadowView.eventEmitter];
}
// `Update LayoutMetrics` instruction
static void RNUpdateLayoutMetricsMountInstruction(
ShadowViewMutation const &mutation,
RCTComponentViewRegistry *registry)
{
auto const &oldShadowView = mutation.oldChildShadowView;
auto const &newShadowView = mutation.newChildShadowView;
auto const &componentViewDescriptor = [registry componentViewDescriptorWithTag:newShadowView.tag];
[componentViewDescriptor.view updateLayoutMetrics:newShadowView.layoutMetrics
oldLayoutMetrics:oldShadowView.layoutMetrics];
}
// `Update State` instruction
static void RNUpdateStateMountInstruction(ShadowViewMutation const &mutation, RCTComponentViewRegistry *registry)
{
auto const &oldShadowView = mutation.oldChildShadowView;
auto const &newShadowView = mutation.newChildShadowView;
auto const &componentViewDescriptor = [registry componentViewDescriptorWithTag:newShadowView.tag];
[componentViewDescriptor.view updateState:newShadowView.state oldState:oldShadowView.state];
}
// `Finalize Updates` instruction
static void RNFinalizeUpdatesMountInstruction(
ShadowViewMutation const &mutation,
RNComponentViewUpdateMask mask,
RCTComponentViewRegistry *registry)
{
auto const &newShadowView = mutation.newChildShadowView;
auto const &componentViewDescriptor = [registry componentViewDescriptorWithTag:newShadowView.tag];
[componentViewDescriptor.view finalizeUpdates:mask];
}
// `Update` instruction
static void RNPerformMountInstructions(
static void RCTPerformMountInstructions(
ShadowViewMutationList const &mutations,
RCTComponentViewRegistry *registry,
RCTMountingTransactionObserverCoordinator &observerCoordinator,
SurfaceId surfaceId)
{
SystraceSection s("RNPerformMountInstructions");
SystraceSection s("RCTPerformMountInstructions");
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
for (auto const &mutation : mutations) {
switch (mutation.type) {
case ShadowViewMutation::Create: {
RNCreateMountInstruction(mutation, registry, observerCoordinator, surfaceId);
auto &newChildShadowView = mutation.newChildShadowView;
auto &newChildViewDescriptor =
[registry dequeueComponentViewWithComponentHandle:newChildShadowView.componentHandle
tag:newChildShadowView.tag];
observerCoordinator.registerViewComponentDescriptor(newChildViewDescriptor, surfaceId);
break;
}
case ShadowViewMutation::Delete: {
RNDeleteMountInstruction(mutation, registry, observerCoordinator, surfaceId);
auto &oldChildShadowView = mutation.oldChildShadowView;
auto &oldChildViewDescriptor = [registry componentViewDescriptorWithTag:oldChildShadowView.tag];
observerCoordinator.unregisterViewComponentDescriptor(oldChildViewDescriptor, surfaceId);
[registry enqueueComponentViewWithComponentHandle:oldChildShadowView.componentHandle
tag:oldChildShadowView.tag
componentViewDescriptor:oldChildViewDescriptor];
break;
}
case ShadowViewMutation::Insert: {
RNUpdatePropsMountInstruction(mutation, registry);
RNUpdateEventEmitterMountInstruction(mutation, registry);
RNUpdateStateMountInstruction(mutation, registry);
RNUpdateLayoutMetricsMountInstruction(mutation, registry);
RNFinalizeUpdatesMountInstruction(mutation, RNComponentViewUpdateMaskAll, registry);
RNInsertMountInstruction(mutation, registry);
auto &oldChildShadowView = mutation.oldChildShadowView;
auto &newChildShadowView = mutation.newChildShadowView;
auto &parentShadowView = mutation.parentShadowView;
auto &newChildViewDescriptor = [registry componentViewDescriptorWithTag:newChildShadowView.tag];
auto &parentViewDescriptor = [registry componentViewDescriptorWithTag:parentShadowView.tag];
UIView<RCTComponentViewProtocol> *newChildComponentView = newChildViewDescriptor.view;
[newChildComponentView updateProps:newChildShadowView.props oldProps:oldChildShadowView.props];
[newChildComponentView updateEventEmitter:newChildShadowView.eventEmitter];
[newChildComponentView updateState:newChildShadowView.state oldState:oldChildShadowView.state];
[newChildComponentView updateLayoutMetrics:newChildShadowView.layoutMetrics
oldLayoutMetrics:oldChildShadowView.layoutMetrics];
[newChildComponentView finalizeUpdates:RNComponentViewUpdateMaskAll];
[parentViewDescriptor.view mountChildComponentView:newChildComponentView index:mutation.index];
break;
}
case ShadowViewMutation::Remove: {
RNRemoveMountInstruction(mutation, registry);
auto &oldChildShadowView = mutation.oldChildShadowView;
auto &parentShadowView = mutation.parentShadowView;
auto &oldChildViewDescriptor = [registry componentViewDescriptorWithTag:oldChildShadowView.tag];
auto &parentViewDescriptor = [registry componentViewDescriptorWithTag:parentShadowView.tag];
[parentViewDescriptor.view unmountChildComponentView:oldChildViewDescriptor.view index:mutation.index];
break;
}
case ShadowViewMutation::Update: {
auto const &oldChildShadowView = mutation.oldChildShadowView;
auto const &newChildShadowView = mutation.newChildShadowView;
auto &oldChildShadowView = mutation.oldChildShadowView;
auto &newChildShadowView = mutation.newChildShadowView;
auto &newChildViewDescriptor = [registry componentViewDescriptorWithTag:newChildShadowView.tag];
UIView<RCTComponentViewProtocol> *newChildComponentView = newChildViewDescriptor.view;
auto mask = RNComponentViewUpdateMask{};
if (oldChildShadowView.props != newChildShadowView.props) {
RNUpdatePropsMountInstruction(mutation, registry);
[newChildComponentView updateProps:newChildShadowView.props oldProps:oldChildShadowView.props];
mask |= RNComponentViewUpdateMaskProps;
}
if (oldChildShadowView.eventEmitter != newChildShadowView.eventEmitter) {
RNUpdateEventEmitterMountInstruction(mutation, registry);
[newChildComponentView updateEventEmitter:newChildShadowView.eventEmitter];
mask |= RNComponentViewUpdateMaskEventEmitter;
}
if (oldChildShadowView.state != newChildShadowView.state) {
RNUpdateStateMountInstruction(mutation, registry);
[newChildComponentView updateState:newChildShadowView.state oldState:oldChildShadowView.state];
mask |= RNComponentViewUpdateMaskState;
}
if (oldChildShadowView.layoutMetrics != newChildShadowView.layoutMetrics) {
RNUpdateLayoutMetricsMountInstruction(mutation, registry);
[newChildComponentView updateLayoutMetrics:newChildShadowView.layoutMetrics
oldLayoutMetrics:oldChildShadowView.layoutMetrics];
mask |= RNComponentViewUpdateMaskLayoutMetrics;
}
if (mask != RNComponentViewUpdateMaskNone) {
RNFinalizeUpdatesMountInstruction(mutation, mask, registry);
[newChildComponentView finalizeUpdates:mask];
}
break;
@ -284,7 +215,7 @@ static void RNPerformMountInstructions(
[self.delegate mountingManager:self willMountComponentsWithRootTag:surfaceId];
_observerCoordinator.notifyObserversMountingTransactionWillMount({surfaceId, number, telemetry});
telemetry.willMount();
RNPerformMountInstructions(mutations, self.componentViewRegistry, _observerCoordinator, surfaceId);
RCTPerformMountInstructions(mutations, self.componentViewRegistry, _observerCoordinator, surfaceId);
telemetry.didMount();
_observerCoordinator.notifyObserversMountingTransactionDidMount({surfaceId, number, telemetry});
[self.delegate mountingManager:self didMountComponentsWithRootTag:surfaceId];

Просмотреть файл

@ -21,14 +21,13 @@ void ShadowTreeRegistry::add(std::unique_ptr<ShadowTree> &&shadowTree) const {
registry_.emplace(shadowTree->getSurfaceId(), std::move(shadowTree));
}
std::unique_ptr<ShadowTree> ShadowTreeRegistry::remove(
SurfaceId surfaceId) const {
void ShadowTreeRegistry::remove(SurfaceId surfaceId) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
auto iterator = registry_.find(surfaceId);
auto shadowTree = std::unique_ptr<ShadowTree>(iterator->second.release());
registry_.erase(iterator);
return shadowTree;
if (iterator != registry_.end()) {
registry_.erase(iterator);
}
}
bool ShadowTreeRegistry::visit(

Просмотреть файл

@ -34,10 +34,9 @@ class ShadowTreeRegistry final {
/*
* Removes a `ShadowTree` instance with given `surfaceId` from the registry
* and returns it as a result.
* The ownership of the instance is also transferred to the caller.
* Can be called from any thread.
*/
std::unique_ptr<ShadowTree> remove(SurfaceId surfaceId) const;
void remove(SurfaceId surfaceId) const;
/*
* Finds a `ShadowTree` instance with a given `surfaceId` in the registry and