Fabric: Trivial implementation of prelumiary view allocation on iOS
Summary: @public We have this feature in the current version of RN, so it would be nice to support that in Fabric as well. This should save us tens of ms of views creation during mounting. And that's quite easy to do! Reviewed By: fkgozali Differential Revision: D8701992 fbshipit-source-id: 4e3049df009ffd65bb43043de388e81795e5e559
This commit is contained in:
parent
5d9326be29
commit
2166d2bb79
|
@ -43,6 +43,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
*/
|
||||
- (ReactTag)tagByComponentView:(UIView<RCTComponentViewProtocol> *)componentView;
|
||||
|
||||
/**
|
||||
* Creates a component view with a given type and puts it to the recycle pool.
|
||||
*/
|
||||
- (void)preliminaryCreateComponentViewWithName:(NSString *)componentName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
#endif
|
||||
|
||||
const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 256;
|
||||
const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
|
||||
|
||||
@implementation RCTComponentViewRegistry {
|
||||
NSMapTable<id, UIView<RCTComponentViewProtocol> *> *_registry;
|
||||
|
@ -121,6 +121,13 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 256;
|
|||
[self _enqueueComponentViewWithName:componentName componentView:componentView];
|
||||
}
|
||||
|
||||
- (void)preliminaryCreateComponentViewWithName:(NSString *)componentName
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
[self _enqueueComponentViewWithName:componentName
|
||||
componentView:[self _createComponentViewWithName:componentName]];
|
||||
}
|
||||
|
||||
- (UIView<RCTComponentViewProtocol> *)componentViewByTag:(ReactTag)tag
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
|
|
|
@ -26,10 +26,18 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
/**
|
||||
* Transfroms mutation insturctions to mount items and execute them.
|
||||
* The order of mutation tnstructions matters.
|
||||
* Can be called from any thread.
|
||||
*/
|
||||
- (void)mutateComponentViewTreeWithMutationInstructions:(facebook::react::TreeMutationInstructionList)instructions
|
||||
rootTag:(ReactTag)rootTag;
|
||||
|
||||
/**
|
||||
* Suggests preliminary creation of a component view of given type.
|
||||
* The receiver is free to ignore the request.
|
||||
* Can be called from any thread.
|
||||
*/
|
||||
- (void)preliminaryCreateComponentViewWithName:(NSString *)componentName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -181,4 +181,11 @@ using namespace facebook::react;
|
|||
[self.delegate mountingManager:self didMountComponentsWithRootTag:rootTag];
|
||||
}
|
||||
|
||||
- (void)preliminaryCreateComponentViewWithName:(NSString *)componentName
|
||||
{
|
||||
RCTExecuteOnMainQueue(^{
|
||||
[self->_componentViewRegistry preliminaryCreateComponentViewWithName:componentName];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@class RCTMountingManager;
|
||||
|
||||
/**
|
||||
* Exacly same semantic as `facebook::react::SchedulerDelegate`.
|
||||
* Exactly same semantic as `facebook::react::SchedulerDelegate`.
|
||||
*/
|
||||
@protocol RCTSchedulerDelegate
|
||||
|
||||
|
|
|
@ -67,7 +67,10 @@ using namespace facebook::react;
|
|||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)schedulerDidComputeMutationInstructions:(facebook::react::TreeMutationInstructionList)instructions rootTag:(ReactTag)rootTag
|
||||
#pragma mark - RCTSchedulerDelegate
|
||||
|
||||
- (void)schedulerDidComputeMutationInstructions:(facebook::react::TreeMutationInstructionList)instructions
|
||||
rootTag:(ReactTag)rootTag
|
||||
{
|
||||
[_mountingManager mutateComponentViewTreeWithMutationInstructions:instructions
|
||||
rootTag:rootTag];
|
||||
|
@ -75,7 +78,7 @@ using namespace facebook::react;
|
|||
|
||||
- (void)schedulerDidRequestPreliminaryViewAllocationWithComponentName:(NSString *)componentName
|
||||
{
|
||||
// TODO: To be implemeted.
|
||||
[_mountingManager preliminaryCreateComponentViewWithName:componentName];
|
||||
}
|
||||
|
||||
#pragma mark - Internal Surface-dedicated Interface
|
||||
|
|
Loading…
Reference in New Issue