Skip to content

Commit

Permalink
Fix null crash when using maintainVisibleContentPosition on Android (#…
Browse files Browse the repository at this point in the history
…38891)

Summary:
`mFirstVisibleView` is a weak ref so it can also be null when dereferencing.

This was reported on the original PR here #35049 (comment)

## Changelog:

[ANDROID] [FIXED] - Fix null crash when using maintainVisibleContentPosition on Android

Pull Request resolved: #38891

Test Plan: Not sure exactly in what cases this can happen, but the fix is trivial and makes sense.

Reviewed By: cortinico

Differential Revision: D48192154

Pulled By: rshest

fbshipit-source-id: 57a38a22a0e216a33603438355bde0013c014fbf
  • Loading branch information
janicduplessis authored and facebook-github-bot committed Aug 10, 2023
1 parent ad18f81 commit 1a1a798
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ private void updateScrollPositionInternal() {
}

View firstVisibleView = mFirstVisibleView.get();
if (firstVisibleView == null) {
return;
}

Rect newFrame = new Rect();
firstVisibleView.getHitRect(newFrame);

Expand Down

0 comments on commit 1a1a798

Please sign in to comment.