Repository navigation
Conversation
Patch 002 skips 0x0 layouts, so a list can receive a native scroll event before it has a layout manager. FlashList's onScroll then called recordInteraction -> updateViewableItems -> getWindowSize, which threw 'LayoutManager is not initialized, window size is unavailable'. Return early from updateViewableItems, recordInteraction and computeItemViewability until the list has a layout. Co-authored-by: Linh Vo <linhvovan29546@users.noreply.github.com>
Contributor
Author
|
I created this PR from an upstream branch because To take ownership of this branch and push updates, run: Then you can close this PR and open a new one from your fork. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
Stops the iOS HybridApp crash
LayoutManager is not initialized, window size is unavailable, thrown from FlashList'sonScroll(SentryAPP-MHA).Why it happens: Our FlashList patch 002 (skip layout when hidden) returns early when a list first measures at 0×0, so FlashList never creates its
layoutManager. Upstream always creates it on the first layout. If a native scroll event arrives before the first real layout (for example, iOS adjusting the content inset with no user touch), FlashList'sonScrollcallsrecordInteraction()→updateViewableItems(). That readsgetWindowSize()before it checks whether the list has any viewability listeners, so even lists with no viewability callbacks (likeWorkspaces_List) throw.What this changes: Patch 002 now also guards the scroll/viewability path it leaves without a layout manager:
ViewabilityManager.updateViewableItemsreturns early when there are no viewability listeners or!rvManager.hasLayout(), before callinggetWindowSize().RecyclerViewManager.recordInteractionreturns early when!hasLayout().hasInteractedstays unset until the list can measure anything, soviewabilityConfig.waitForInteractionstill works on the next scroll.RecyclerViewManager.computeItemViewabilityreturns early when!hasLayout(). This covers lists withonViewableItemsChanged, which would otherwise throw fromcomputeVisibleIndices()on the same event.Lists that already have a layout behave exactly as before. The patch 002 entry in
patches/@shopify/flash-list/details.mdis updated.Unit tests:
tests/unit/FlashListTest.tsxadds two tests onRecyclerViewManagerwith no layout. Both fail on the unpatched code with the Sentry error, and pass with this change. The second test also checks that viewable items are still reported after the first layout, and that the early scroll does not count as the interaction forwaitForInteraction.AI tests run locally:
npm test -- tests/unit/FlashListTest.tsx: pass (3/3). The 2 new tests fail without the fix.TableTest,TableSelectionTest,BaseSelectionListTest,BaseSelectionListSectionsTest,SearchAutocompleteListTest,EmojiPickerMenuComponentTest,tests/unit/components/SelectionList): pass (12 suites, 188 tests).@shopify/flash-listpatches apply in order on a clean@shopify/flash-list@2.3.2with patch-package's apply logic, and the result matches the patchednode_modules.npm run lint-changed,npm run typecheck,npm run spell-changed,npm run fmt(no changes),./scripts/validatePatches.sh: pass.npm testsuite and the Storybook smoke test. The crash is native iOS only and was not reproduced on a device.Fixed Issues
$ #104502
PROPOSAL: #104502 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.
Offline tests
QA Steps
// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
// Please describe what QA needs to do to validate your changes and what areas do they need to test for regressions.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari