Fix an incorrect method of looking up previous keys#407
Closed
Conversation
1 task
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-native.mp4Android: mWeb Chromeandroid-chrome-2023-10-30_15.07.23.mp4iOS: Nativeios-native-2023-10-30_16.21.41.mp4iOS: mWeb Safariios-safari-2023-10-30_16.24.08.mp4MacOS: Chrome / Safarichrome-desktop-2023-10-30_15.00.23.mp4MacOS: Desktopmac-desktop-2023-10-30_16.26.27.mp4 |
|
Note: I'm testing against |
Contributor
|
@mountiny Will do! |
|
Ah yes with #408 that now works fine against v1.0.109!
chrome-desktop-2023-10-30_12.23.39.mp4 |
Collaborator
Author
|
Hm, the failing test is leading me to believe I didn't have the right solution. I'm still digging into this. |
|
Haha unfortunate timing! 😅 |
Collaborator
Author
|
OK, after testing this for a while, I checked out the branch from #408 and to my surprise, the original problem could not be reproduced with the infinite avatars. I think my solution here was kind of maybe working around the root of the problem. I think this can be closed. |
42 tasks
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.
This was reported while testing Expensify/App#29169 (comment)
Details
I was able to reproduce the issue with the infinite loading of avatars. While debugging the problem, I found that it was
ReportScreen.jswhich was infinitely re-rendering. This manifested in the infinite loading of avatars. SinceReportScreenis at the top of the view hierarchy, I concluded the issue was definitely inwithOnyx().To debug it further, I began to inspect what happened when
componentDidUpdateruns, and then checks to see if the key changed (eg.previousKey !== newKey). I found that the logic was properly detecting that the key changed, sowithOnyxcorrectly tried to reconnect with the new key. When the new connection happened, the logic is supposed to remember what the previous key was (eg.mapOnyxToState[statePropertyName].previousKey = key;). This triggerscomponentDidUpdate()again and I found that thepreviousKeywas always wrong. It wasn't actually changing, sowithOnyxwent into an infinite loop trying to reconnect to the same keys over and over again.I fixed it by utilizing
prevPropsandprevStatearguments fromcomponentDidUpdate()to more accurately calculate what the previous and current keys were, rather than relying on a reference tomapOnyxToState[statePropertyName].previousKey. This now correctly picked up the change to keys and prevents the infinite connection.Related Issues
Expensify/App#29169
Automated Tests
None
Manual Tests
This requires a little bit of setup.
Setup in NewDot
mainwith version1.0.100of Onyx), log in as a user and be sure you have an avatar uploadedSetup NewDot to run the Onyx fix
react-native-onyxdirectory and runnpm run build && cp -r dist ~/Expensidev/App/node_modules/react-native-onyxto copy the changes from this PR into NewDot (you may need to adjust the file paths)npm run webAuthor Checklist
### Related Issuessection aboveTestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.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)Avataris modified, I verified thatAvataris working as expected in all cases)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
cannot test because no access to network console
Mobile Web - Safari
cannot test because no access to network console
Desktop
iOS
cannot test because no access to network console
Android
cannot test because no access to network console