mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
f2e0b2f45f
Summary: PreAllocation currently always happens at revision 0 (after ShadowNode creation), and all CREATE mutations are triggered for ShadowNodes at revision 1 or higher (since CREATE mutations are generated by the differ, it means that all ShadowNodes have revision 1 or higher when CompleteRoot is called). This means that between PreAllocation and CREATE, we /always/ expect at least one clone. It is possible for a node to be "non-view-forming" at revision 0, causing view preallocation to be skipped, and "view-forming" at revision 1 (causing the CREATE mutation to be thrown away, since all CREATE mutations of revision 0 or 1 are thrown away). This causes a crash. It is extremely marginal, but there are repros in the wild. Thus, I'm introducing one new UIManager and Scheduler delegate method that allows the mounting layer to be notified of clones. If a clone from rev 0->1 results in a node going from non-view-forming to view-forming, we can preallocate then, as well. This resolves this crash, and allows us to keep experimenting safely with this View PreAllocation optimization. I believe all edge-cases are accounted for. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D29043426 fbshipit-source-id: dff11d3140ded1cbb02a5518a3aeb52dc812cc50
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include <react/renderer/core/ReactPrimitives.h>
|
|
#include <react/renderer/mounting/MountingCoordinator.h>
|
|
#include <react/renderer/mounting/ShadowView.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/*
|
|
* Abstract class for Scheduler's delegate.
|
|
*/
|
|
class SchedulerDelegate {
|
|
public:
|
|
/*
|
|
* Called right after Scheduler computed (and laid out) a new updated version
|
|
* of the tree and calculated a set of mutations which are sufficient
|
|
* to construct a new one.
|
|
*/
|
|
virtual void schedulerDidFinishTransaction(
|
|
MountingCoordinator::Shared const &mountingCoordinator) = 0;
|
|
|
|
/*
|
|
* Called right after a new ShadowNode was created.
|
|
*/
|
|
virtual void schedulerDidRequestPreliminaryViewAllocation(
|
|
SurfaceId surfaceId,
|
|
const ShadowNode &shadowView) = 0;
|
|
|
|
/*
|
|
* Called right after a ShadowNode is cloned.
|
|
*/
|
|
virtual void schedulerDidCloneShadowNode(
|
|
SurfaceId surfaceId,
|
|
const ShadowNode &oldShadowNode,
|
|
const ShadowNode &newShadowNode) = 0;
|
|
|
|
virtual void schedulerDidDispatchCommand(
|
|
const ShadowView &shadowView,
|
|
std::string const &commandName,
|
|
folly::dynamic const args) = 0;
|
|
|
|
virtual void schedulerDidSendAccessibilityEvent(
|
|
const ShadowView &shadowView,
|
|
std::string const &eventType) = 0;
|
|
|
|
/*
|
|
* Set JS responder for a view
|
|
*/
|
|
virtual void schedulerDidSetIsJSResponder(
|
|
ShadowView const &shadowView,
|
|
bool isJSResponder,
|
|
bool blockNativeResponder) = 0;
|
|
|
|
virtual ~SchedulerDelegate() noexcept = default;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|