Avoid pre-allocating views for non-layoutable shadow nodes

Summary: This diff changes the behavior of the Scheduler.schedulerDidRequestPreliminaryViewAllocation to avoid pre-allocating views that are non-layoutables

Reviewed By: shergin

Differential Revision: D12962008

fbshipit-source-id: cb2670beafdcbd2116fbdaf2dc5d1b4726330ec2
This commit is contained in:
David Vacca 2018-11-11 15:18:09 -08:00 committed by Facebook Github Bot
parent 94d49e544d
commit 33b966139e
3 changed files with 12 additions and 3 deletions

View File

@ -27,7 +27,7 @@ public:
[scheduler.delegate schedulerDidFinishTransaction:mutations rootTag:rootTag];
}
void schedulerDidRequestPreliminaryViewAllocation(SurfaceId surfaceId, ComponentName componentName) override {
void schedulerDidRequestPreliminaryViewAllocation(SurfaceId surfaceId, ComponentName componentName, bool isLayoutable, ComponentHandle componentHandle) override {
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerDidRequestPreliminaryViewAllocationWithComponentName:RCTNSStringFromString(componentName, NSASCIIStringEncoding)];
}

View File

@ -185,8 +185,15 @@ void Scheduler::uiManagerDidFinishTransaction(
void Scheduler::uiManagerDidCreateShadowNode(
const SharedShadowNode &shadowNode) {
if (delegate_) {
auto layoutableShadowNode =
dynamic_cast<const LayoutableShadowNode *>(shadowNode.get());
auto isLayoutable = layoutableShadowNode != nullptr;
delegate_->schedulerDidRequestPreliminaryViewAllocation(
shadowNode->getRootTag(), shadowNode->getComponentName());
shadowNode->getRootTag(),
shadowNode->getComponentName(),
isLayoutable,
shadowNode->getComponentHandle());
}
}

View File

@ -33,7 +33,9 @@ class SchedulerDelegate {
*/
virtual void schedulerDidRequestPreliminaryViewAllocation(
SurfaceId surfaceId,
ComponentName componentName) = 0;
ComponentName componentName,
bool isLayoutable,
ComponentHandle componentHandle) = 0;
virtual ~SchedulerDelegate() noexcept = default;
};