Skip to content

Commit 85d8356

Browse files
committed
shadowTreeLockMountPhase impl
1 parent 9979b3e commit 85d8356

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ ShadowTreeRevision ShadowTree::getCurrentRevision() const {
389389

390390
void ShadowTree::mount(ShadowTreeRevision revision, bool mountSynchronously)
391391
const {
392+
std::unique_lock<std::shared_mutex> lock;
393+
bool shouldLock = ReactNativeFeatureFlags::shadowTreeLockMountPhase();
394+
if (shouldLock) {
395+
// TODO: can a mount cause another mount, so we have to care about reentrancy?
396+
lock = std::unique_lock<std::shared_mutex>(mountMutex_);
397+
}
392398
mountingCoordinator_->push(std::move(revision));
393399
delegate_.shadowTreeDidFinishTransaction(
394400
mountingCoordinator_, mountSynchronously);

packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class ShadowTree final {
151151

152152
const SurfaceId surfaceId_;
153153
const ShadowTreeDelegate& delegate_;
154+
mutable std::shared_mutex mountMutex_;
154155
mutable std::shared_mutex commitMutex_;
155156
mutable std::recursive_mutex commitMutexRecursive_;
156157
mutable CommitMode commitMode_{

0 commit comments

Comments
 (0)