Skip to content

Commit

Permalink
Merge pull request #46315 from janicduplessis/@janic/fix-osr
Browse files Browse the repository at this point in the history
Fix comment linking bugs
  • Loading branch information
roryabraham authored Aug 19, 2024
2 parents 2db3b94 + 012ac2d commit 9cfe9c1
Show file tree
Hide file tree
Showing 7 changed files with 595 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,87 @@
diff --git a/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js b/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js
index e338d90..70a59bf 100644
index e338d90..238989f 100644
--- a/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js
+++ b/node_modules/@react-native/virtualized-lists/Lists/VirtualizedList.js
@@ -1219,7 +1219,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
@@ -89,6 +89,7 @@ type State = {
firstVisibleItemKey: ?string,
// When > 0 the scroll position available in JS is considered stale and should not be used.
pendingScrollUpdateCount: number,
+ lastItemCount: number,
};

function getScrollingThreshold(threshold: number, visibleLength: number) {
@@ -404,12 +405,13 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {

const minIndexForVisible =
this.props.maintainVisibleContentPosition?.minIndexForVisible ?? 0;
+ const itemCount = this.props.getItemCount(this.props.data);

this.state = {
cellsAroundViewport: initialRenderRegion,
renderMask: VirtualizedList._createRenderMask(props, initialRenderRegion),
firstVisibleItemKey:
- this.props.getItemCount(this.props.data) > minIndexForVisible
+ itemCount > minIndexForVisible
? VirtualizedList._getItemKey(this.props, minIndexForVisible)
: null,
// When we have a non-zero initialScrollIndex, we will receive a
@@ -420,6 +422,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
this.props.initialScrollIndex > 0
? 1
: 0,
+ lastItemCount: itemCount,
};
}

@@ -701,16 +704,15 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
// first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
// sure we're rendering a reasonable range here.
const itemCount = newProps.getItemCount(newProps.data);
- if (itemCount === prevState.renderMask.numCells()) {
+ if (itemCount === prevState.renderMask.numCells() && itemCount === prevState.lastItemCount) {
return prevState;
}
-
let maintainVisibleContentPositionAdjustment: ?number = null;
const prevFirstVisibleItemKey = prevState.firstVisibleItemKey;
const minIndexForVisible =
newProps.maintainVisibleContentPosition?.minIndexForVisible ?? 0;
const newFirstVisibleItemKey =
- newProps.getItemCount(newProps.data) > minIndexForVisible
+ itemCount > minIndexForVisible
? VirtualizedList._getItemKey(newProps, minIndexForVisible)
: null;
if (
@@ -758,6 +760,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
maintainVisibleContentPositionAdjustment != null
? prevState.pendingScrollUpdateCount + 1
: prevState.pendingScrollUpdateCount,
+ lastItemCount: itemCount,
};
}

@@ -1159,7 +1162,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
}
}

- componentDidUpdate(prevProps: Props) {
+ componentDidUpdate(prevProps: Props, prevState: State) {
const {data, extraData} = this.props;
if (data !== prevProps.data || extraData !== prevProps.extraData) {
// clear the viewableIndices cache to also trigger
@@ -1181,6 +1184,11 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
if (hiPriInProgress) {
this._hiPriInProgress = false;
}
+
+ if (this.state.cellsAroundViewport.first !== prevState.cellsAroundViewport.first ||
+ this.state.cellsAroundViewport.last !== prevState.cellsAroundViewport.last) {
+ this._maybeCallOnEdgeReached();
+ }
}

_cellRefs: {[string]: null | CellRenderer<any>} = {};
@@ -1219,7 +1227,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
zoomScale: 1,
};
_scrollRef: ?React.ElementRef<any> = null;
Expand All @@ -11,7 +90,7 @@ index e338d90..70a59bf 100644
_sentEndForContentLength = 0;
_updateCellsToRenderBatcher: Batchinator;
_viewabilityTuples: Array<ViewabilityHelperCallbackTuple> = [];
@@ -1550,16 +1550,16 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
@@ -1550,16 +1558,16 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
onStartReached != null &&
this.state.cellsAroundViewport.first === 0 &&
isWithinStartThreshold &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
diff --git a/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm b/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm
index b4cfb3d..7aa00e5 100644
index b4cfb3d..fdfae56 100644
--- a/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm
+++ b/node_modules/react-native/React/Fabric/Mounting/RCTMountingManager.mm
@@ -49,6 +49,9 @@ static void RCTPerformMountInstructions(
{
SystraceSection s("RCTPerformMountInstructions");
@@ -265,6 +265,9 @@ static void RCTPerformMountInstructions(

auto surfaceId = mountingCoordinator.getSurfaceId();

+ [CATransaction begin];
+ [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
+
for (const auto &mutation : mutations) {
switch (mutation.type) {
case ShadowViewMutation::Create: {
@@ -147,6 +150,7 @@ static void RCTPerformMountInstructions(
}
}
}
mountingCoordinator.getTelemetryController().pullTransaction(
[&](const MountingTransaction &transaction, const SurfaceTelemetry &surfaceTelemetry) {
[self.delegate mountingManager:self willMountComponentsWithRootTag:surfaceId];
@@ -278,6 +281,8 @@ static void RCTPerformMountInstructions(
_observerCoordinator.notifyObserversMountingTransactionDidMount(transaction, surfaceTelemetry);
[self.delegate mountingManager:self didMountComponentsWithRootTag:surfaceId];
});
+
+ [CATransaction commit];
}

@implementation RCTMountingManager {
- (void)setIsJSResponder:(BOOL)isJSResponder
Loading

0 comments on commit 9cfe9c1

Please sign in to comment.