-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Reapply onyx upgrade use cache with fixes #24041
Reapply onyx upgrade use cache with fixes #24041
Conversation
ceb3aad
to
bcc91e6
Compare
bcc91e6
to
cd62597
Compare
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
Just as a side note: the code of the initial IOU onyx values has been 2 years old, i tried to check every use case and it seems to be safe to be removed now |
…rade-use-cache-with-fixes
Still waiting for to get merged |
…rade-use-cache-with-fixes
…rade-use-cache-with-fixes
We are seeing issue #23962 on this build. It is fixed in Staging and PROD. Should we log it again? |
@mvtglobally - I believe @hannojg fixed this, we are rebuilding a new build now with the fix. |
@AndrewGable so it was a bug? |
@hannojg regression is completed. |
Thanks for letting me know and for testing! I still have to fix the last issue. Will let you know when it's good for testing (probably in the next few hours!) |
Triggered a new build |
🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪 |
@mvtglobally The new builds are ready, can your team please test again? Thanks! |
@mollfpr can you check as well please? |
Asked QA for a review |
@situchan have you been able to check this one out? |
on it now |
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.
Looks good so far.
if (isEmojiPickerVisible) { | ||
Keyboard.dismiss(); | ||
} |
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.
What issue was fixed by this removal?
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 one #24041 (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.
This was originally added in #8221 to fix emoji select on first tap not working on android.
I confirmed that's not reproducible after revert.
8.mov
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.
Hi, in my test, after removing this code, the keyboard no longer appears when dismissing the emoji modal on Android native.
test.mp4
How about moving Keyboard.dismiss()
into the onPress
handler in EmojiPickerButton
? This could fix #24041 (comment) without impacting Android platform.
App/src/components/EmojiPicker/EmojiPickerButton.js
Lines 47 to 53 in 00efce4
onPress={() => { | |
if (!EmojiPickerAction.emojiPickerRef.current.isEmojiPickerVisible) { | |
EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor.current, undefined, () => {}, props.reportAction); | |
} else { | |
EmojiPickerAction.emojiPickerRef.current.hideEmojiPicker(); | |
} | |
}} |
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.
Hey @ntdiary
You are saying
the keyboard no longer appears
The code here is about dismissing the keyboard. I'd never expect this code to open the keyboard?
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.
Ah, this may seem a bit unbelievable 😂, but let me explain a bit more: as shown in the image above, for android, if we don't manually call blur
( or dismiss
), the focus state inside the composer input box will not change when opening the emoji modal. Then after we close the modal, even though we call focus
on the composer input box, because the internal focus state did not change, the part where the keyboard is supposed to show gets ignored.
So here, dismiss
can clean up the internal focus state, allowing the subsequent focus
to successfully show the keyboard.
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.
oh wow, I didn't know that, thanks for sharing!! So you say we should add this code back? 😊
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 was also surprised when I first discovered this android behavior. And don't worry, I just made a note here, we still have another issue and may do something there as needed. 😄
@@ -339,6 +327,8 @@ class BaseOptionsSelector extends Component { | |||
selectTextOnFocus | |||
blurOnSubmit={Boolean(this.state.allOptions.length)} | |||
spellCheck={false} | |||
autoFocus={this.props.autoFocus} | |||
shouldDelayFocus={this.props.shouldDelayFocus} |
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.
Confirmed that this fixes Keyboard opens multiple times when selecting members to request money.
Curious about the root cause though?
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 mostly an order of event issue.
By this we call textInputRef.focus
in the useEffect of the BaseTextInput.js
component. This call will happen later than a call in componentDidMount
. A (simplified) general rule in react is is that componentDidMount will always run before any useEffect hooks in the current batch of work.
Now, when we navigate to a new screen there is some code in react-navigation that will dismiss the keyboard when we transition to a new screen. When the focus happens on the class component componentDidMount the order of events is the following:
- Transition to a new screen starts
- Component gets rendered, calls
.focus()
. The keyboard starts to open - Transition causes
Keyboard.dismiss
to get called - (If we are lucky in terms of timing), the timeout of
selectTextOnFocus
kicks in and focuses the input again (keyboard opens again) [if you are curious check the JS code of the react-native-web textinput component]
Now, we call the focus from the useEffect, and the order of events is roughly this:
- Transition to a new screen starts
- Component gets rendered
- Transition causes
Keyboard.dismiss
to get called - useEffect fires focusing the input
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.
Tested all mentioned issues in this PR. All are not reproducible.
Still testing more cases
@@ -83,7 +83,6 @@ const defaultProps = { | |||
isSubmitButtonVisible: true, | |||
formState: { | |||
isLoading: false, | |||
errors: null, |
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.
NAB: I assume crash was fixed in onyx repo. Now what's this removal for?
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 crash wasn't fixed in the onyx repo. It is invalid when looking at the logic of the component to have errors as null. It's never expected to be null.
Its a fix for this bug:
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.
Can't find the exact bug ticket at the moment. I know it was one of the bugs that was found during going through the regressions here: https://expensify.slack.com/archives/C01GTK53T8Q/p1690897222550089
Have to leave for vacation in a few minutes so I can't find it right now, sorry 😓
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.
Nvm. Hopefully this PR and #18648 would be merged without further change requests from you. Have a good vacation!
Looks pass on mWeb. We are checking other platforms https://github.com/Expensify/App/assets/43995119/d28158f7-b4c1-4783-be84-b557628d87a4 |
@situchan could you fill out the checklist please? |
Reviewer Checklist
Screenshots/VideosWebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
Screenshots/Videos1.mov2.mov3.mov
4.mov5.mov6.mov7.mov |
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.
We did good amount of tests but still there might be edge cases we missed, which will be discovered by our good bug reporters.
After merge, I will keep watching slack channel if any bug is reported related to this PR, so that we can fix quickly before being deploy blocker.
Navigation.navigate(ROUTES.getMoneyRequestRoute(iouType, reportID)); | ||
return resetMoneyRequestInfo(`${iouType}${reportID}`).then(() => { | ||
Navigation.navigate(ROUTES.getMoneyRequestRoute(iouType, reportID)); | ||
}); |
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.
It's pretty uncommon to have to wait for a merge to navigate. If we are going to chain off of Onyx.merge()
I think we should leave some kind of comment to explain why this is the exception to the rule.
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 the problem here is that now when we have withOnyx improvement we may sometimes read outdate value. For instance we have a screen that operates on value "X". Let say we had a flow that first modifies the value "X" then navigates to our screen. Before what was happening is withOnyx wrapped screen was waiting for onyx values by waiting for connect method and then info about value "X". in connect method there were a lot of promises so we were sure that our modification was succeeded before we actually rendered content of the new screen. Now it's possible that we will modify the "X" navigate to screen read previous value of "X" from cache then once modification takes place we render the component one more time.
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.
waiting for merge prevents reading outdate value from what I understand
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 we can easily miss some cases as previously we didn't need to care about it as we were sure that we won't read from onyx before the modification happen.
Maybe we should persist what is stale and don't read from cache when it is or indicate that we don't worry about reading outdated data.
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.
Maybe we can do it in a bit safer way (but you better now how many such cases we can have in the app. Maybe those from the pr are the only ones)
If we don't mind reading outdated data (want to show messages as soon as possible we can add a flag)
withOnyx({
allowReadingStaleData: true
})
Then on every merge/set/remove we update two simple maps so we know if the data in cache is up to date
StaleStorageLastOperation[key] = operation_number_that_modifies_the_key
toDoOperations.push(operationId)
Then
isDataStale = (key) => (toDoOperation.has(StaleStorageLastOperation[key])).
if the data is stale we don't get it from cache in withOnyx wrapper unless someone set allowReadingStaleData
to true
} | ||
Navigation.navigate(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); | ||
Promise.all(promises).then(() => { |
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.
Similar comment here. Pushing all these merge promises into the array has made this code harder to reason about I think. We should document every reason why we will need to await an Onyx.merge()
call.
Can someone clarify for me what further action is happening here? I have an issue that's waiting on this PR deploying. |
@sophiepintoraetz seems like the automation here failed, but it should be deployed now so you can take your issue off hold |
Details
Recently we tried to merge this performance improvement PR:
but it caused a bunch of regressions. This PR is reapplying the changes + fixes the found regressions
Fixes:
I asked @Beamanator if we can run a full regression test suite, as this PR includes very heavy onyx changes!
Fixed Issues
$ #22644
PROPOSAL:
Tests
Offline tests
n/a
QA Steps
Same as testing
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Screen.Recording.2023-08-02.at.14.18.54.mov
Mobile Web - Chrome
mweb-Android.mov
Mobile Web - Safari
mWeb-ios.mp4
Desktop
Uploading desktop.mov…
iOS
ios.mp4
Android
Screen.Recording.2023-08-02.at.14.27.25.mov