-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Tracking] [Performance] Investigate creating our own KeyboardAvoidingView #10273
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
Comments
HOLD on #9841 |
Taking this off HOLD |
not prioritized yet |
cc @Szymon20000 |
YES |
Thanks Rory, the solution part of this is really fascinating and it sounds like maybe there are some big performance gains hiding away in Reanimated 3. I am having a little trouble with the "problem" section of this and think it needs refining. Or at a minimum break concerns into separate issues to tackle one at a time. I'm admittedly having trouble believing that we aren't just holding something wrong (as that's usually the case).
Can we unlock this somehow? There must be some basic cases where the behaviors should be used and it seems possible to articulate what they do and develop some best practices and guidance?
Could we figure out if we can delete this and replace it with a regular
This too?
And this?
Agree, but what does it have to do with rolling our own
What's an example of this? Is it something we have or can create issues to address/improve?
Could use an example here as well.
And it's because of the One thing learned from today is that barely anyone has a proper understanding of how this component works. 😂 So I'd love to keep exploring |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a production regression has occurred a Root Cause Analysis is required. Please follow the instructions here. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a production regression has occurred a Root Cause Analysis is required. Please follow the instructions here. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
No update here yet, but looking forward to working on this. Fortunately |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a production regression has occurred a Root Cause Analysis is required. Please follow the instructions here. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a production regression has occurred a Root Cause Analysis is required. Please follow the instructions here. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
PR for the last non-held issue is on staging and should hit production tomorrow! |
Working through a regression on the last outstanding issue. |
Last issue is getting close! Still working through that regression, though it's likely to be merged this week. |
What is the status on this? I ended up investigating using I will leave the code here for later use if we can have a fix in reanimated. /*
* The KeyboardAvoidingView is only used on ios and android
*/
import React from 'react';
import Animated, {
useAnimatedKeyboard,
useAnimatedStyle,
} from 'react-native-reanimated';
const KeyboardAvoidingView = (props) => {
const keyboard = useAnimatedKeyboard({isStatusBarTranslucentAndroid: true});
const animatedStyle = useAnimatedStyle(() => ({
paddingBottom: keyboard.height.value,
}));
return (
// eslint-disable-next-line react/jsx-props-no-spreading, react/prop-types
<Animated.View {...props} style={[props.style, animatedStyle]} />
);
};
KeyboardAvoidingView.displayName = 'KeyboardAvoidingView';
export default KeyboardAvoidingView; |
In terms of this issue, all linked issues above are merged and nothing is being actively worked on for |
@tomekzaw Want to take a look at @janicduplessis's bug report here? Edit: Looks like this was probably fixed in software-mansion/react-native-reanimated#3958 – just needs to included in a new release Edit again: JK, that PR was released in |
@roryabraham Sure, I will be more than happy to help here. You're right, software-mansion/react-native-reanimated#3958 is already merged and released so we'll just need to upgrade to 3.0.2 first. As for the
Edit: #2 should be fixed with software-mansion/react-native-reanimated#4266 |
@tomekzaw @roryabraham I have KeyboardAvoidingView for iOS implemented using |
As for the this tracking issue, I kind of think we should close this issue since all the related issues are now done. Maybe we should create a separate issue for upgrading Reanimated? |
As part of this issue and my #16356, we (cc @roryabraham ) decided to contribute the implementation of KeyboardAvoidingView I did as part of the PR to Reanimated. This way they will be able to track and fix all the bugs related to Another thing I did - reported a bug that stops us from upgrading Reanimated version which fixes some other bugs: |
|
Alright, I think we did it and have officially fixed all issues linked to this tracking initiative. We also already have the regression tests, so I think it's to close this one out. |
Someone please re-open and correct me if I'm wrong! |
Here is the PR that implements KeyboardAvoidingView in Reanimated: |
The implementation of KeyboardAvoidingView is pretty much ready, finishing the example used for testing, it mimics our usage I'm working at #16356 . Also, we're currently testing this KeyboardAvoidingView implementation on Android on another project. |
Uh oh!
There was an error while loading. Please reload this page.
Coming from https://expensify.slack.com/archives/C01GTK53T8Q/p1659722402266779?thread_ts=1659347778.519049&cid=C01GTK53T8Q
Outstanding
Fixed
Problem
First a few observations:
All that is to say, it feels like our usage of keyboard-avoiding stuff is a bit inconsistent/all-over-the-place, and maybe it's a good time to step back and see if we can consolidate some of this and make it a bit more consistent.
Moreover, we've noticed issues such as this one where the keyboard-avoiding stuff isn't necessarily working as expected. There have been other similar bugs in the past. For example, we have some screens where we use timeouts to wait for navigation transitions to finish before opening the keyboard, etc... Furthermore, many of these bugs have been sort of inconsistent (maybe suggesting that they are caused by race conditions). Lastly, I've noticed that the keyboard is just really sluggish and slow to open on iOS.
Solution
Now this part is more of a hunch, but I have a theory that many of these bugs are caused because Reanimated (the animation library used by react-navigation) and the React Native KeyboardAvoidingView/KeyboardSpacer components aren't playing nice together. Why? Because Reanimated runs animations synchronously on the UI thread, while the KeyboardAvoidingView components will update asynchronously between the UI thread and the layout/render thread. This makes it hard to keep them in sync / behaving as expected.
I did a bit of research and noticed that Reanimated 3 is set to introduce a
useAnimatedKeyboard
hook. This would allow us to create a simple KeyboardAvoidingView of our own that is animated synchronously on the UI thread. I think this would be better for performance (which I have noticed is lackluster on iOS staging+production), and hopefully make opening/closing the keyboard much snappier. Furthermore, since (all?) our animations would be running in Reanimated, I have a hunch that many of these inconsistent bugs might go away.So my proposal (or at minimum, an idea that I think is worth looking into) is that we:
The text was updated successfully, but these errors were encountered: