-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix wrong behavior on Android web #17962
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
Fix wrong behavior on Android web #17962
Conversation
* test flatlist for android * fix linter * fix name * fix not working features * limit rerenders
|
@neil-marcellini Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@staszekscp please follow our contributing guidelines. Were you hired for an issue with an accepted proposal? If so please include those in the description and re-open the PR. |
|
cc: Hey @mountiny, could you have a look at that? |
|
Thanks for linking the related issue and now I see that you're from Software Mansion so I'll reopen this. I was going quickly and thought this was a random PR opened unrelated to an issue. |
|
@staszekscp thanks! it would be great to add a video too and always try to give more context for the PR :D |
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@staszekscp You got some lint issues here again, hopefully we will get rid of this with Prettier and typestript haha but make sure to check if the npm run lint is fine before submitting ready for a review
|
@s77rt could you give this one a look sooner than later, thank you very much 🙇 |
| <Freeze | ||
| freeze={shouldFreeze} | ||
| placeholder={skeletonPlaceholder} | ||
| > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of putting this in the LHNOptionList and making a platform specific implementation for that entire component, could you please create a SidebarFreeze component that wraps its children in Freeze on all platforms except for web, where it wraps the children in nothing <>?
I think that isolates the platform specific part better. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds reasonable to me, probably just a preference though. @s77rt what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will go thought the files in depth but just a quick response. I assume LHNOptionList is exactly the same and the only difference is Freeze is that right? Then It would be better to isolate that component instead as @neil-marcellini suggested. BUT why not remove the Freeze component, is it really doing something significantly good? It's anti react's life-cycle and we will remove it on navigation reboot anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realised this is a part of navigation reboot 😁 I think It was planned to remove Freeze at this point, why we are still using it. Am I missing something here? cc @neil-marcellini @mountiny (and @roryabraham I guess you know about this)
|
Sorry @mountiny for the lint issues, I keep forgetting that, because in previous projects I couldn't commit anything without passing a lint check via husky script :P I'll keep that in mind, though, so hopefully I will pass the lint check next time! |
|
Thanks for the SidebarFreeze update! I think as a general rule we should always keep platform specific components as small as possible. Please include testing videos as described in the PR author checklist. I'm not able to observe the LHN reloading under the global create menu on main. @parasharrajat is that easy to observe or do we need to add logging or otherwise debug to see if the component is updating or remounting? Also could you please write a couple sentences about the problem and how this fixes it, it's not super clear to me. I'll let @s77rt take the lead on the reviews and come back after he approves. |
|
@neil-marcellini It is a bug specific to the navigation rework, that's why it is not possible to notice it on the |
|
@neil-marcellini I still have concerns about the use of Freeze, please check comment #17962 (comment) in case you missed it |
s77rt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The custom FlatList is a workaround. bug is upstream: software-mansion/react-freeze#31
- Why not just remove Freeze?
| focusedIndex={_.findIndex(optionListItems, ( | ||
| option => option.toString() === this.props.currentReportId | ||
| ))} | ||
| isLoading={isLoading} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is an outdated change. LHNOptionsList does not accept isLoading prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why the renamed is required here (another outdated change?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated, there was a web file before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this is a workaround. The bug is upstream and it has been reported already a while ago software-mansion/react-freeze#31
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@s77rt I think we want to keep Freeze to limit the number of rerender in the stack. All the navigation will be stack based so if we wont have Freeze around the LHN, it would be rerendering in the background
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated, there was a web file before
|
@s77rt do you want me to make internal release of this branch for testing or are you fine with emulators? |
|
@mountiny I'm fine with emulators. Unfortunately we will have to discuss some more before moving with this PR
Besides the custom flat list here is a workaround, we have a bug report for that #14125 |
|
Essenatilly the implementation of the refactor means we will be pushing many reports to the stack, they wont be reused so if you will use app for a long time you will have a lot of pages. I think we need to use the Freeze for ReportScreens at least for now to ensure that those are not being rerendered in the background. I am sure also we can work with SWM to fix the react-freeze issues, they are maintainers of the library Also is this really only occurring on Android web or also on other platforms? |
|
|
Thanks, I understand that. I think what we need to do is completely test what will be influenced (performance mainly) if we remove the freeze completely. Especially Android app hopes to get better performance with dropping the use of drawer so we need to be cautious with what will be the performance consequence of these changes. Could anyone try to some quick performance audit for removing the freeze? at least in terms of FPS? |
|
Asked in Slack to discuss this https://expensify.slack.com/archives/C01GTK53T8Q/p1682548765642099 |
@neil-marcellini When you follow the steps from #16581 (comment). Notice that avatars will go grey which means they are reloading. I could also see the skeleton loader on chats. |
|
I think in the On the other hand I think it is worth to keep An alternative solution that would work to fix this specific Android web issue is to leave the Freeze component, but add a check to see if the screen transition finished. I haven't tested that, but if you prefer this kind of solution I may check this out. |
|
So I feel like:
We can work with SWM to fix the react-freeze issues, they are keen to fix anything which is wrong with it |
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parasharrajat @s77rt @staszekscp @neil-marcellini after the rect discussion I think we should be bale to use freeze for the report screen but skip its usage for the sidebar, what do you think?
|
@mountiny I'm okay with keeping Freeze I'm just questioning how to handle the issues that we assumed will be gone after navigation reboot. However I would still discourage the use of Custom FlatList, I would really prefer to keep a bug than apply a workaround. |
|
So, is this ready for review again? Please message me on NewDot when it is. |
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@s77rt Can you please give this one a review again assuming we will keep the Freeze so we know clearly what we need to address, got a bit lost in the conversation cc @staszekscp thank!
s77rt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One additional change request. And please address the other unresolved comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let remove the CustomFlatList and just use the react-native FlatList
|
@staszekscp lets follow up on this one next week |
|
Closing this PR in favour of the final one we have here #19263, the changes should be incorporated there. |
Details
Fix for wrong freeze behavior on android web - it introduces wrapper that provides Freeze component to mobile apps (where it is really needed)
Part of navigation rework by Software Mansion
The problem was caused by the
Freezecomponent - on Android web the the freezing was triggered too early (before screen's transition end). Instead of implementing some hacky solutions I decided to remove the Freeze component from the web flow, because it was causing more problems without giving much perfromance advantage there.Fixed Issues
Related to #16581 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Mobile Web - Chrome
Sorry for the qualityScreen.Recording.2023-04-26.at.21.17.37.2.mov
Mobile Web - Safari
Desktop
iOS
Android