-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: migrate FlatList to FlashList for rooms lists #6995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deepak0x
wants to merge
4
commits into
RocketChat:develop
Choose a base branch
from
deepak0x:feat/flashlist-android-lists
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+128
−51
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
68be302
feat: migrate FlatList to FlashList for rooms and message lists
deepak0x a3fd229
feat: migrate RoomsListView FlatList to FlashList
deepak0x 2968649
fix: add getItemType to FlashList for separate recycling pools
deepak0x 9a1d3a5
fix: include subscribedRoom in FlashList extraData for correct isFocu…
deepak0x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import React, { createRef } from 'react'; | ||
| import { render } from '@testing-library/react-native'; | ||
|
|
||
| import List from './List'; | ||
| import { RoomContext } from '../../context'; | ||
| import { type TAnyMessageModel } from '../../../../definitions'; | ||
|
|
||
| const messages = [{ id: '1' }, { id: '2' }] as TAnyMessageModel[]; | ||
|
|
||
| const renderList = (isAutocompleteVisible: boolean) => | ||
| render( | ||
| <RoomContext.Provider value={{ room: {}, selectedMessages: [], isAutocompleteVisible }}> | ||
| <List | ||
| listRef={createRef()} | ||
| jumpToBottom={jest.fn()} | ||
| data={messages} | ||
| keyExtractor={item => item.id} | ||
| renderItem={() => null} | ||
| /> | ||
| </RoomContext.Provider> | ||
| ); | ||
|
|
||
| describe('RoomView List accessibility', () => { | ||
| it('hides message list from accessibility tree while autocomplete is visible', () => { | ||
| const { UNSAFE_getByProps } = renderList(true); | ||
| const list = UNSAFE_getByProps({ testID: 'room-view-messages' }); | ||
|
|
||
| expect(list.props.accessibilityElementsHidden).toBe(true); | ||
| expect(list.props.importantForAccessibility).toBe('no-hide-descendants'); | ||
| }); | ||
|
|
||
| it('keeps message list visible to accessibility tree while autocomplete is hidden', () => { | ||
| const { UNSAFE_getByProps } = renderList(false); | ||
| const list = UNSAFE_getByProps({ testID: 'room-view-messages' }); | ||
|
|
||
| expect(list.props.accessibilityElementsHidden).toBe(false); | ||
| expect(list.props.importantForAccessibility).toBe('yes'); | ||
| }); | ||
| }); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # FlashList migration | ||
|
|
||
| The rooms list (`RoomsListView`) uses `@shopify/flash-list` instead of `FlatList` for better performance on Android. | ||
|
|
||
| The room message list (`RoomView`) continues to use `Animated.FlatList` because it relies on the `inverted` prop and `onScrollToIndexFailed` which are not supported by FlashList v2. | ||
|
|
||
| ## Comparing CPU usage (Android) | ||
|
|
||
| On a physical device with the app installed: | ||
|
|
||
| 1. Reset and capture baseline (optional, if comparing two builds): | ||
| ```bash | ||
| adb shell dumpsys gfxinfo chat.rocket.reactnative reset | ||
| ``` | ||
| 2. Use the app (scroll rooms list, open a room, scroll messages, receive messages, jump to message, scroll to bottom). | ||
| 3. Dump CPU and graphics stats: | ||
| ```bash | ||
| adb shell dumpsys cpuinfo | grep -E "chat.rocket|Total" | ||
| adb shell dumpsys gfxinfo chat.rocket.reactnative | ||
| ``` | ||
| 4. From `gfxinfo` compare: | ||
| - **Janky frames** (lower is better) | ||
| - **50th / 90th / 95th / 99th percentile** frame times (lower is better) | ||
| - **Number Slow UI thread** (lower is better) | ||
|
|
||
| Run the same flow on the same device for a pre-migration build and the FlashList build, then compare the numbers. |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.