Skip to content

Commit

Permalink
Avoid pre-allocating views for non-layoutable shadow nodes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Nov 11, 2018
1 parent 94d49e5 commit 33b9661
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion React/Fabric/RCTScheduler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void schedulerDidFinishTransaction(Tag rootTag, const ShadowViewMutationList &mu
[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)];
}
Expand Down
9 changes: 8 additions & 1 deletion ReactCommon/fabric/uimanager/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
4 changes: 3 additions & 1 deletion ReactCommon/fabric/uimanager/SchedulerDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 33b9661

Please sign in to comment.