Skip to content

Commit

Permalink
Fix deadlock in SafeAreaView
Browse files Browse the repository at this point in the history
  • Loading branch information
yayvery authored and Flewp committed Mar 11, 2024
1 parent 4a19c47 commit 5c0d4da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void removeRootView(int rootViewTag) {
*
* @return The num of root view
*/
private int getRootViewNum() {
public int getRootViewNum() {
return mOperationsQueue.getNativeViewHierarchyManager().getRootViewNum();
}

Expand Down Expand Up @@ -608,12 +608,6 @@ public void measureLayoutRelativeToParent(

/** Invoked at the end of the transaction to commit any updates to the node hierarchy. */
public void dispatchViewUpdates(int batchId) {
if (getRootViewNum() <= 0) {
// If there are no RootViews registered, there will be no View updates to dispatch.
// This is a hack to prevent this from being called when Fabric is used everywhere.
// This should no longer be necessary in Bridgeless Mode.
return;
}
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIImplementation.dispatchViewUpdates")
.arg("batchId", batchId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,12 @@ public void onBatchComplete() {
listener.willDispatchViewUpdates(this);
}
try {
mUIImplementation.dispatchViewUpdates(batchId);
// If there are no RootViews registered, there will be no View updates to dispatch.
// This is a hack to prevent this from being called when Fabric is used everywhere.
// This should no longer be necessary in Bridgeless Mode.
if (mUIImplementation.getRootViewNum() > 0) {
mUIImplementation.dispatchViewUpdates(batchId);
}
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
Expand Down

0 comments on commit 5c0d4da

Please sign in to comment.